commit 8aa7b3953e8f529f53274cf08836d54728ba8a78
parent 4f1d68af43c6e83d97e53e8518efaf57d9d50c8f
Author: Alex Balgavy <a.balgavy@gmail.com>
Date: Wed, 17 Oct 2018 14:18:24 +0200
Modified updatemaster script
Diffstat:
M | bin/updatemaster | | | 62 | +++++++++++++++++++++++++++++++++++++------------------------- |
1 file changed, 37 insertions(+), 25 deletions(-)
diff --git a/bin/updatemaster b/bin/updatemaster
@@ -12,17 +12,20 @@ select_casks=0
sudo_auth=0
greedy=1
+TICK="\e[1;32m\u2714\e[0m"
+CROSS="\e[1;31m\u2718\e[0m"
+
echo_succ() {
- echo -e "\e[1;32m$1\e[0m"
+ echo -e "[ $TICK ] \e[1;32m$1\e[0m"
}
echo_err() {
- echo -e "\e[1;31m$1\e[0m"
+ echo -e "[ $CROSS ] \e[1;31m$1\e[0m"
}
echo_warn() {
- echo -e "\e[1;34m$1\e[0m"
+ echo -e "[\e[1;34m!!!\e[0m] \e[1;34m$1\e[0m"
}
echo_progress() {
- echo -e "\e[1;36m$1\e[0m"
+ echo -e "[\e[1;36m...\e[0m] \e[1;36m$1\e[0m"
}
echo_progress "### STARTING UPDATE SCRIPT ###\n"
@@ -95,7 +98,7 @@ fi
echo
### HOMEBREW ###
-echo_progress "-- Homebrew update/upgrade."
+echo_progress "Homebrew update/upgrade."
if command -v brew &> /dev/null; then
brew update;
brew update > /dev/null;
@@ -109,7 +112,7 @@ if command -v brew &> /dev/null; then
# Potentially upgrade programs
if [ $no_formulas = 1 ] || [ $none = 1 ]; then
- echo_succ "\nNo programs will be updated."
+ echo_succ "No programs will be updated."
elif [ ${#outdated} = 0 ]; then
echo -e "No programs to update."
else
@@ -137,7 +140,7 @@ if command -v brew &> /dev/null; then
if [ ${#outdated_c} = 0 ]; then
echo_succ "No casks to update."
elif [ $no_casks = 1 ] || [ $none = 1 ]; then
- echo_succ "\nNo casks will be updated."
+ echo_succ "No casks will be updated."
else
echo -e "Casks to update:"
if [ $greedy = 1 ]; then
@@ -184,7 +187,7 @@ if command -v brew &> /dev/null; then
brew prune;
brew doctor;
brew missing;
- echo "Backuping up Brew installation..."
+ echo "Backing up Brew installation..."
brew bundle dump --force --file=~/.dotfiles/Brewfile;
echo_succ "Backup complete."
notify "Brewed." "All packages have been upgraded.";
@@ -192,42 +195,44 @@ else
echo_err "brew not found."
echo_err "Cannot upgrade Homebrew packages. Please do so manually."
fi
+echo
### Mac App Store (MAS) ###
-echo_progress "\n-- MAS update/upgrade."
+echo_progress "MAS update/upgrade."
if command -v mas &> /dev/null; then
echo -e "MAS outdated:"
outdated=$(mas outdated)
if [ ${#outdated} = 0 ]; then
- echo_succ "\nEverything is up to date."
+ echo_succ "Everything is up to date."
else
mas outdated
read -sn 1 -p "Continue? [Y/n]" CONF
case $CONF in
[Yy] )
- echo_succ -e "\nContinuing with mas upgrade."
+ echo_succ -e "Continuing with mas upgrade."
mas upgrade;
;;
* )
- echo -e "\nCancelled mas upgrade."
+ echo -e "Cancelled mas upgrade."
;;
esac
notify "MAS Updated." "All apps at newest version."
fi
else
- echo_err -e "\nmas not found. Install mas to update App Store apps on the command line."
- echo_err -e "\nCannot update Mac App Store apps. Please do so manually."
+ echo_err -e "mas not found. Install mas to update App Store apps on the command line."
+ echo_err -e "Cannot update Mac App Store apps. Please do so manually."
fi
+echo
### GLOBAL NPM ###
-echo_progress "\n-- NPM global update/upgrade."
+echo_progress "NPM global update/upgrade."
if command -v npm &> /dev/null; then
outdated=$(npm outdated)
if [ ${#outdated} = 0 ]; then
- echo_succ "\nEverything is up to date."
+ echo_succ "Everything is up to date."
else
npm update -g
notify "NPM Update Finished" "See Terminal for info."
@@ -235,21 +240,23 @@ if command -v npm &> /dev/null; then
npm cache verify
echo_succ "NPM update complete."
else
- echo_err "\nnpm not found."
- echo_err "\nCannot update NPM packages. Please do so manually."
+ echo_err "npm not found."
+ echo_err "Cannot update NPM packages. Please do so manually."
fi
+echo
### PIP3 ###
-echo_progress "\n-- PIP3 update/upgrade."
+echo_progress "PIP3 update/upgrade."
if command -v pip3 list &> /dev/null; then
pip3 list --outdated | cut -d ' ' -f1 | xargs -n1 pip3 install -U
notify "Pip3 Update Finished" "See Terminal for info."
else
- echo_err "\nCannot upgrade pip3 packages. Please do so manually."
+ echo_err "Cannot upgrade pip3 packages. Please do so manually."
fi
+echo
### PIP ###
-echo_progress "-- PIP update/upgrade."
+echo_progress "PIP update/upgrade."
if command -v pip list &> /dev/null; then
if pip freeze; then
pip freeze — local | grep -v '^\-e' | cut -d = -f 1 | xargs pip install -U
@@ -260,9 +267,10 @@ if command -v pip list &> /dev/null; then
else
echo_err "Cannot upgrade pip packages. Please do so manually."
fi
+echo
### SUDO PIP ###
-echo_progress "\n-- Global pip."
+echo_progress "Global pip."
if [ $sudo_auth -eq 1 ]; then
if command -v sudo -H pip list &> /dev/null; then
sudo -H pip freeze | grep -v '^\-e' | cut -d = -f 1 | xargs sudo -H pip install -U
@@ -273,10 +281,11 @@ if [ $sudo_auth -eq 1 ]; then
else
echo -e "Sudo not authorised."
fi
+echo
### TLDR DATABASE ###
if command -v tldr &> /dev/null; then
- echo_progress "\n-- TLDR database update"
+ echo_progress "TLDR database update"
tldr --update
tldr_exit=$?
if [ $tldr_exit -eq 0 ]; then
@@ -285,10 +294,11 @@ if command -v tldr &> /dev/null; then
echo_err "Exit code: $tldr_exit"
fi
fi
+echo
### ATOM PACKAGES ###
if command -v apm &> /dev/null; then
- echo_progress "\n-- Atom package upgrades"
+ echo_progress "Atom package upgrades"
if apm outdated &> /dev/null; then
apm upgrade --no-confirm;
echo_succ "All packages upgraded."
@@ -298,6 +308,8 @@ if command -v apm &> /dev/null; then
else
echo_err "Atom not installed (or APM not functioning properly)."
fi
+echo
+
notify "APM Upgrade Complete" "See Terminal for info."
-echo_progress "\n-- All systems checked. \e[1;32m\u2714\e[0m"
+echo_succ "All systems checked."
notify "All systems checked." "Everything you indicated should be upgraded."