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