1
1
Fork 0

updated the update() function to support macOS/brew

This commit is contained in:
david 2022-05-06 11:14:09 +02:00
parent 5906fc2905
commit 3928f759bf
1 changed files with 50 additions and 29 deletions

View File

@ -54,13 +54,14 @@ alias {dc,compose}="docker-compose"
alias d="docker" alias d="docker"
alias p="podman" alias p="podman"
alias vanity="docker run --rm -it socialnerds/wg-vanity-address:latest --in 6" alias vanity="docker run --rm -it socialnerds/wg-vanity-address:latest --in 6"
alias mp="multipass"
#alias {p,pass}="gopass" #alias {p,pass}="gopass"
alias {a,apt}="sudo apt" alias {a,apt}="sudo apt"
alias {u,ufw}="sudo ufw" alias {u,ufw}="sudo ufw"
alias LG_ultrafine_brightness="sudo LG_ultrafine_brightness" alias LG_ultrafine_brightness="sudo LG_ultrafine_brightness"
# **** function definitions **** # **** function definitions ****
## output handling ## output handling
@ -99,39 +100,59 @@ log() {
sleep 0.5; echo -e "[$level] ${@:2}" sleep 0.5; echo -e "[$level] ${@:2}"
} }
## OS upgrade for various systems ## Update systems packages
update-os() { update() {
systems="ubuntu arch solus raspbian antergos elementary" bold=$(tput bold)
issue="$(cat /etc/issue)" normal=$(tput sgr0)
for item in $systems; do if [ "$(uname)" = "Darwin" ]; then
echo $issue | grep -i $item >> /dev/null log info "macOS detected. Using ${bold}brew${normal} to update packages."
brew update && brew upgrade
if [ $? -eq 0 ]; then if [ $? -eq 0 ]; then
system=$item log success "All packages up-to-date."
else
log error "Something went wrong while running brew."
fi fi
done else
#if not Darwin then its probably Linux
systems="ubuntu arch raspbian antergos elementary"
issue="$(cat /etc/issue)"
for item in $systems; do
echo $issue | grep -i $item >> /dev/null
if [ $? -eq 0 ]; then
system=$item
fi
done
case $system in
ubuntu|debian|raspbian|elementary)
log info "Debian based system detected. Using ${bold}apt${normal} to update packages."
sudo apt update && sudo apt dist-upgrade -y && sudo apt autoremove -y && sudo apt autoclean -y
if [ $? -eq 0 ]; then
log success "All packages up-to-date."
else
log error "Something went wrong while running ${bold}apt${normal}."
fi
;;
arch|antergos)
log info "Arch Linux detected. Using ${bold}pacman${normal} to update packages."
sudo pacman -Syu --noconfirm
if [ $? -eq 0 ]; then
log success "All packages up-to-date."
else
log error "Something went wrong while running ${bold}pacman${normal}."
fi
case $system in ;;
ubuntu|debian|raspbian|elementary) ?)
log info "Updating Debian based system.." log error "Unknown system. Aborting."
sudo apt update && sudo apt dist-upgrade -y && sudo apt autoremove -y && sudo apt autoclean -y return 1
;; ;;
arch|antergos) esac
log info "Updating Arch Linux.."
sudo pacman -Syu if [ $? -ne 0 ]; then
;; echo "error: something went wrong."
solus)
log info "Updating Solus OS.."
sudo eopkg update-repo && sudo eopkg upgrade
;;
?)
log error "error: unknown system."
return 1 return 1
;; fi
esac
if [ $? -ne 0 ]; then
echo "error: something went wrong."
return 1
fi fi
} }