This repository was archived by the owner on Aug 11, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupgrade-all.sh
executable file
·148 lines (128 loc) · 4.2 KB
/
upgrade-all.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
#! /bin/bash
# This script takes all of the different package managers I use or have used and
# puts them into a single script.
# Homebrew
homebrewUpdate () {
if [[ $(command -v brew) ]] ; then
echo -e "\033[1mUpdating Homebrew lists\033[0m"
brew update # Update lists of programs
echo ""
fi
}
# Homebrew CLI Apps
homebrewCliUpgrade () {
if [[ $(command -v brew) ]] ; then
echo -e "\033[1mUpgrading Homebrew CLI apps\033[0m"
if [[ $(brew outdated) ]] ; then # Check for updates
brew upgrade # Upgrade CLI programs
echo "Removing old Homebrew CLI versions"
brew cleanup # Remove old versions of CLI programs
else
echo "All Homebrew CLI apps are up to date."
fi
echo ""
fi
}
# GUI apps & Drivers
homebrewCaskUpgrade () {
if [[ $(command -v brew) ]] ; then
echo -e "\033[1mUpgrading Homebrew cask programs (GUI apps and drivers)\033[0m"
if [[ $(brew cask outdated) ]] ; then # If there are casks to update
brew cask upgrade # Upgrade cask apps
echo "Removing old cask app versions."
brew cleanup # Cleanup
else
echo "All casks are up to date."
fi
echo ""
fi
}
# pip2
pip2Upgrade () {
if [[ $(command -v pip2) ]] ; then
echo -e "\033[1mUpgrading Python pip2 programs.\033[0m"
# Lists outdated, trim unneeded info, save as string
pip2Outdated=$(pip2 list --outdated --format=freeze | cut -d'=' -f1)
if [[ $pip2Outdated ]] ; then # If there are pips to update
echo "Upgrading pip2 apps."
pip2 install --upgrade $pip2Outdated # Updates everything in string
else
echo "All pip2 apps are up to date."
fi
echo ""
fi
}
# pip3
pip3Upgrade () {
if [[ $(command -v pip3) ]] ; then
echo -e "\033[1mUpgrading Python pip3 programs.\033[0m"
# Lists outdated, trim unneeded info, save as string
pip3Outdated=$(pip3 list --outdated --format=freeze | cut -d'=' -f1)
if [[ $pip3Outdated ]] ; then # If there are pips to update
echo "Upgrading pip3 apps."
pip3 install --upgrade $pip3Outdated # Updates everything in string
else
echo "All pip3 are up to date."
echo ""
fi
fi
}
# macOS
macosUpgrade () {
if [[ $(command -v softwareupdate) ]] ; then
echo -e "\033[1mUpgrading macOS\033[0m"
sudo softwareupdate -ia | grep -v 'No updates are available.' \
| grep -v 'Software Update Tool' | grep -v 'Finding available software'
echo "macOS is up to date"
echo ""
fi
}
# App Store
masUpgrade () {
if [[ $(command -v mas) ]] ; then
echo -e "\033[1mUpgrading App Store programs\033[0m"
# Lists outdated apps ecluding those requiring manual authentication
masOutdated=$(mas list | grep -v '856514119' | grep -v '424389933' |
cut -f1 -d' ' | paste -s -d' ' -)
mas upgrade "$masOutdated" | grep -v 'Warning: Nothing found to upgrade'
echo "All App Store apps are up to date."
echo ""
fi
}
# LaTeX Packages
latexPackageUpgrade () {
if [[ $(command -v tlmgr) ]] ; then
echo -e "\033[1mUpgrading LaTeX Packages\033[0m"
sudo tlmgr update --self --all
echo ""
fi
}
# Microsoft Office
microsoftOfficeUpgrade () {
if [[ $(command -v /Library/Application\ Support/Microsoft/MAU2.0/Microsoft\ AutoUpdate.app/Contents/MacOS/msupdate) ]] ; then
echo -e "\033[1mUpgrading Microsoft Office Programs\033[0m"
/Library/Application\ Support/Microsoft/MAU2.0/Microsoft\ AutoUpdate.app/Contents/MacOS/msupdate --install
echo ""
fi
}
# apt (Ubuntu, Debian, and derivatives)
aptUpgrade () {
if [[ $(command -v apt) ]] ; then
sudo apt update # Update package lists
sudo apt upgrade -y # Install all packages
fi
}
main () {
homebrewUpdate
homebrewCliUpgrade
homebrewCaskUpgrade
pip2Upgrade
pip3Upgrade
macosUpgrade
masUpgrade
latexPackageUpgrade
microsoftOfficeUpgrade
echo -e "\033[1mUpdates complete.\033[0m"
echo -e "\033[1mSome apps may require a reboot to be used.\033[0m"
}
main