From 4e995e2dd71a53d6574103d0e5cbc6bfa2ccafd5 Mon Sep 17 00:00:00 2001 From: Chris Titus Date: Sat, 13 Jul 2024 23:02:52 -0500 Subject: [PATCH] system update checks --- src/commands/system-update.sh | 34 ++++++++++++++++++++-------------- 1 file changed, 20 insertions(+), 14 deletions(-) diff --git a/src/commands/system-update.sh b/src/commands/system-update.sh index 6b58d181..f2465a7c 100755 --- a/src/commands/system-update.sh +++ b/src/commands/system-update.sh @@ -17,9 +17,8 @@ checkEnv() { exit 1 fi done - ## Check Package Handler - PACKAGEMANAGER='apt-get dnf pacman zypper' + PACKAGEMANAGER='apt-get nala dnf pacman zypper yum' for pgm in ${PACKAGEMANAGER}; do if command_exists ${pgm}; then PACKAGER=${pgm} @@ -62,9 +61,9 @@ fastUpdate() { pacman) if ! command_exists yay && ! command_exists paru; then printf "Installing yay as AUR helper...\n" - sudo ${PACKAGER} --noconfirm -S base-devel + sudo ${PACKAGER} --noconfirm -S base-devel || { printf "${RED}Failed to install base-devel${RC}\n"; exit 1; } cd /opt && sudo git clone https://aur.archlinux.org/yay-git.git && sudo chown -R ${USER}:${USER} ./yay-git - cd yay-git && makepkg --noconfirm -si + cd yay-git && makepkg --noconfirm -si || { printf "${RED}Failed to install yay${RC}\n"; exit 1; } else printf "Aur helper already installed\n" fi @@ -88,15 +87,26 @@ fastUpdate() { ;; apt-get|nala) sudo apt-get update - sudo apt-get install -y nala - sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak - sudo nala update - PACKAGER="nala" + if ! command_exists nala; then + sudo apt-get install -y nala || { printf "${YELLOW}Falling back to apt-get${RC}\n"; PACKAGER="apt-get"; } + fi + if [ "${PACKAGER}" = "nala" ]; then + sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak + sudo nala update + PACKAGER="nala" + fi sudo ${PACKAGER} upgrade -y ;; dnf) + sudo ${PACKAGER} update -y ;; zypper) + sudo ${PACKAGER} refresh + sudo ${PACKAGER} update -y + ;; + yum) + sudo ${PACKAGER} update -y + sudo ${PACKAGER} upgrade -y ;; *) printf "${RED}Unsupported package manager: ${PACKAGER}${RC}\n" @@ -108,15 +118,11 @@ fastUpdate() { updateSystem() { printf "${GREEN}Updating system${RC}\n" case ${PACKAGER} in - nala) + nala|apt-get) sudo ${PACKAGER} update -y sudo ${PACKAGER} upgrade -y ;; - yum) - sudo ${PACKAGER} update -y - sudo ${PACKAGER} upgrade -y - ;; - dnf) + yum|dnf) sudo ${PACKAGER} update -y sudo ${PACKAGER} upgrade -y ;;