diff --git a/src/commands/applications-setup/alacritty-setup.sh b/src/commands/applications-setup/alacritty-setup.sh index 6911fd3c..a26b78f8 100755 --- a/src/commands/applications-setup/alacritty-setup.sh +++ b/src/commands/applications-setup/alacritty-setup.sh @@ -7,10 +7,10 @@ setupAlacritty() { if ! command_exists alacritty; then case ${PACKAGER} in pacman) - sudo ${PACKAGER} -S --needed --noconfirm alacritty + $ESCALATION_TOOL ${PACKAGER} -S --needed --noconfirm alacritty ;; *) - sudo ${PACKAGER} install -y alacritty + $ESCALATION_TOOL ${PACKAGER} install -y alacritty ;; esac else @@ -26,4 +26,5 @@ setupAlacritty() { } checkEnv +checkEscalationTool setupAlacritty diff --git a/src/commands/applications-setup/dwmtitus-setup.sh b/src/commands/applications-setup/dwmtitus-setup.sh index d8543fc7..548d9073 100644 --- a/src/commands/applications-setup/dwmtitus-setup.sh +++ b/src/commands/applications-setup/dwmtitus-setup.sh @@ -1,27 +1,27 @@ #!/bin/sh -e . ../common-script.sh -makeDWM(){ - cd $HOME && git clone https://github.com/ChrisTitusTech/dwm-titus.git # CD to Home directory to install dwm-titus - # This path can be changed (e.g. to linux-toolbox directory) - cd dwm-titus/ # Hardcoded path, maybe not the best. - sudo ./setup.sh # Run setup - sudo make clean install # Run make clean install +makeDWM() { + cd "$HOME" && git clone https://github.com/ChrisTitusTech/dwm-titus.git # CD to Home directory to install dwm-titus + # This path can be changed (e.g. to linux-toolbox directory) + cd dwm-titus/ # Hardcoded path, maybe not the best. + $ESCALATION_TOOL ./setup.sh # Run setup + $ESCALATION_TOOL make clean install # Run make clean install } setupDWM() { echo "Installing DWM-Titus if not already installed" case "$PACKAGER" in # Install pre-Requisites pacman) - sudo "$PACKAGER" -S --needed --noconfirm base-devel libx11 libxinerama libxft imlib2 + $ESCALATION_TOOL "$PACKAGER" -S --needed --noconfirm base-devel libx11 libxinerama libxft imlib2 ;; *) - sudo "$PACKAGER" install -y build-essential libx11-dev libxinerama-dev libxft-dev libimlib2-dev + $ESCALATION_TOOL "$PACKAGER" install -y build-essential libx11-dev libxinerama-dev libxft-dev libimlib2-dev ;; esac - } checkEnv +checkEscalationTool setupDWM makeDWM diff --git a/src/commands/applications-setup/kitty-setup.sh b/src/commands/applications-setup/kitty-setup.sh index 8088f594..a9d26293 100755 --- a/src/commands/applications-setup/kitty-setup.sh +++ b/src/commands/applications-setup/kitty-setup.sh @@ -7,10 +7,10 @@ setupKitty() { if ! command_exists kitty; then case ${PACKAGER} in pacman) - sudo "${PACKAGER}" -S --needed --noconfirm kitty + $ESCALATION_TOOL "${PACKAGER}" -S --needed --noconfirm kitty ;; *) - sudo "${PACKAGER}" install -y kitty + $ESCALATION_TOOL "${PACKAGER}" install -y kitty ;; esac else @@ -18,12 +18,13 @@ setupKitty() { fi echo "Copy Kitty config files" if [ -d "${HOME}/.config/kitty" ]; then - cp -r "${HOME}"/.config/kitty "${HOME}"/.config/kitty-bak + cp -r "${HOME}/.config/kitty" "${HOME}/.config/kitty-bak" fi - mkdir -p "${HOME}"/.config/kitty/ - wget -O "${HOME}"/.config/kitty/kitty.conf https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/kitty/kitty.conf - wget -O "${HOME}"/.config/kitty/nord.conf https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/kitty/nord.conf + mkdir -p "${HOME}/.config/kitty/" + wget -O "${HOME}/.config/kitty/kitty.conf" https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/kitty/kitty.conf + wget -O "${HOME}/.config/kitty/nord.conf" https://github.com/ChrisTitusTech/dwm-titus/raw/main/config/kitty/nord.conf } checkEnv +checkEscalationTool setupKitty diff --git a/src/commands/applications-setup/rofi-setup.sh b/src/commands/applications-setup/rofi-setup.sh index 236e42e2..9c06f953 100755 --- a/src/commands/applications-setup/rofi-setup.sh +++ b/src/commands/applications-setup/rofi-setup.sh @@ -7,10 +7,10 @@ setupRofi() { if ! command_exists rofi; then case "$PACKAGER" in pacman) - sudo "$PACKAGER" -S --needed --noconfirm rofi + $ESCALATION_TOOL "$PACKAGER" -S --needed --noconfirm rofi ;; *) - sudo "$PACKAGER" install -y rofi + $ESCALATION_TOOL "$PACKAGER" install -y rofi ;; esac else @@ -31,4 +31,5 @@ setupRofi() { } checkEnv +checkEscalationTool setupRofi diff --git a/src/commands/applications-setup/zsh-setup.sh b/src/commands/applications-setup/zsh-setup.sh index f3e7d0c1..eaa608b5 100644 --- a/src/commands/applications-setup/zsh-setup.sh +++ b/src/commands/applications-setup/zsh-setup.sh @@ -8,10 +8,10 @@ install_zsh() { if ! command_exists zsh; then case "$PACKAGER" in pacman) - sudo "$PACKAGER" -S --needed --noconfirm zsh + $ESCALATION_TOOL "$PACKAGER" -S --needed --noconfirm zsh ;; *) - sudo "$PACKAGER" install -y zsh + $ESCALATION_TOOL "$PACKAGER" install -y zsh ;; esac else @@ -43,9 +43,10 @@ RPROMPT='%F{15}(%F{166}%D{%H:%M}%F{15})%f' EOL # Ensure /etc/zsh/zshenv sets ZDOTDIR to the user's config directory - echo 'export ZDOTDIR="$HOME/.config/zsh"' | sudo tee -a /etc/zsh/zshenv + echo 'export ZDOTDIR="$HOME/.config/zsh"' | $ESCALATION_TOOL tee -a /etc/zsh/zshenv } checkEnv -setup_zsh_config +checkEscalationTool install_zsh +setup_zsh_config diff --git a/src/commands/common-script.sh b/src/commands/common-script.sh index 064bf3c9..bfea62f4 100644 --- a/src/commands/common-script.sh +++ b/src/commands/common-script.sh @@ -11,6 +11,23 @@ command_exists() { which "$1" >/dev/null 2>&1 } +checkEscalationTool() { + ## Check for escalation tools. + if [ -z "$ESCALATION_TOOL_CHECKED" ]; then + ESCALATION_TOOLS='sudo doas' + for tool in ${ESCALATION_TOOLS}; do + if command_exists "${tool}"; then + ESCALATION_TOOL=${tool} + echo "Using ${tool} for privilege escalation" + ESCALATION_TOOL_CHECKED=true + return 0 + fi + done + + echo -e "${RED}Can't find a supported escalation tool${RC}" + exit 1 + fi +} checkCommandRequirements() { ## Check for requirements. @@ -82,4 +99,5 @@ checkEnv() { checkCurrentDirectoryWritable checkSuperUser checkDistro + checkEscalationTool } diff --git a/src/commands/security/firewall-baselines.sh b/src/commands/security/firewall-baselines.sh index 69963083..ee0441b6 100644 --- a/src/commands/security/firewall-baselines.sh +++ b/src/commands/security/firewall-baselines.sh @@ -7,10 +7,10 @@ installPkg() { if ! command_exists ufw; then case ${PACKAGER} in pacman) - sudo "${PACKAGER}" -S --needed --noconfirm ufw + $ESCALATION_TOOL "${PACKAGER}" -S --needed --noconfirm ufw ;; *) - sudo "${PACKAGER}" install -y ufw + $ESCALATION_TOOL "${PACKAGER}" install -y ufw ;; esac else @@ -22,27 +22,28 @@ configureUFW() { echo -e "${GREEN}Using Chris Titus Recommended Firewall Rules${RC}" echo "Disabling UFW" - sudo ufw disable + $ESCALATION_TOOL ufw disable echo "Limiting port 22/tcp (UFW)" - sudo ufw limit 22/tcp + $ESCALATION_TOOL ufw limit 22/tcp echo "Allowing port 80/tcp (UFW)" - sudo ufw allow 80/tcp + $ESCALATION_TOOL ufw allow 80/tcp echo "Allowing port 443/tcp (UFW)" - sudo ufw allow 443/tcp + $ESCALATION_TOOL ufw allow 443/tcp echo "Denying Incoming Packets by Default(UFW)" - sudo ufw default deny incoming + $ESCALATION_TOOL ufw default deny incoming echo "Allowing Outcoming Packets by Default(UFW)" - sudo ufw default allow outgoing + $ESCALATION_TOOL ufw default allow outgoing - sudo ufw enable + $ESCALATION_TOOL ufw enable echo -e "${GREEN}Enabled Firewall with Baselines!${RC}" } checkEnv +checkEscalationTool installPkg configureUFW diff --git a/src/commands/system-setup/1-compile-setup.sh b/src/commands/system-setup/1-compile-setup.sh index 1130cee1..47a48a26 100755 --- a/src/commands/system-setup/1-compile-setup.sh +++ b/src/commands/system-setup/1-compile-setup.sh @@ -31,16 +31,16 @@ installDepend() { case $PACKAGER in pacman) if ! grep -q "^\s*\[multilib\]" /etc/pacman.conf; then - echo "[multilib]" | sudo tee -a /etc/pacman.conf - echo "Include = /etc/pacman.d/mirrorlist" | sudo tee -a /etc/pacman.conf - sudo "$PACKAGER" -Syu + echo "[multilib]" | $ESCALATION_TOOL tee -a /etc/pacman.conf + echo "Include = /etc/pacman.d/mirrorlist" | $ESCALATION_TOOL tee -a /etc/pacman.conf + $ESCALATION_TOOL "$PACKAGER" -Syu else echo "Multilib is already enabled." fi if ! command_exists yay && ! command_exists paru; then echo "Installing yay as AUR helper..." - sudo "$PACKAGER" -S --needed --noconfirm base-devel - cd /opt && sudo git clone https://aur.archlinux.org/yay-git.git && sudo chown -R "$USER":"$USER" ./yay-git + $ESCALATION_TOOL "$PACKAGER" -S --needed --noconfirm base-devel + cd /opt && $ESCALATION_TOOL git clone https://aur.archlinux.org/yay-git.git && $ESCALATION_TOOL chown -R "$USER":"$USER" ./yay-git cd yay-git && makepkg --noconfirm -si else echo "Aur helper already installed" @@ -53,30 +53,30 @@ installDepend() { echo "No AUR helper found. Please install yay or paru." exit 1 fi - "$AUR_HELPER" -S --needed --noconfirm "$DEPENDENCIES" + $AUR_HELPER -S --needed --noconfirm "$DEPENDENCIES" ;; apt-get|nala) COMPILEDEPS='build-essential' - sudo "$PACKAGER" update - sudo dpkg --add-architecture i386 - sudo "$PACKAGER" update - sudo "$PACKAGER" install -y $DEPENDENCIES $COMPILEDEPS + $ESCALATION_TOOL "$PACKAGER" update + $ESCALATION_TOOL dpkg --add-architecture i386 + $ESCALATION_TOOL "$PACKAGER" update + $ESCALATION_TOOL "$PACKAGER" install -y $DEPENDENCIES $COMPILEDEPS ;; dnf) COMPILEDEPS='@development-tools' - sudo "$PACKAGER" update - sudo "$PACKAGER" config-manager --set-enabled powertools - sudo "$PACKAGER" install -y "$DEPENDENCIES" $COMPILEDEPS - sudo "$PACKAGER" install -y glibc-devel.i686 libgcc.i686 + $ESCALATION_TOOL "$PACKAGER" update + $ESCALATION_TOOL "$PACKAGER" config-manager --set-enabled powertools + $ESCALATION_TOOL "$PACKAGER" install -y "$DEPENDENCIES" $COMPILEDEPS + $ESCALATION_TOOL "$PACKAGER" install -y glibc-devel.i686 libgcc.i686 ;; zypper) COMPILEDEPS='patterns-devel-base-devel_basis' - sudo "$PACKAGER" refresh - sudo "$PACKAGER" --non-interactive install "$DEPENDENCIES" $COMPILEDEPS - sudo "$PACKAGER" --non-interactive install libgcc_s1-gcc7-32bit glibc-devel-32bit + $ESCALATION_TOOL "$PACKAGER" refresh + $ESCALATION_TOOL "$PACKAGER" --non-interactive install "$DEPENDENCIES" $COMPILEDEPS + $ESCALATION_TOOL "$PACKAGER" --non-interactive install libgcc_s1-gcc7-32bit glibc-devel-32bit ;; *) - sudo "$PACKAGER" install -y $DEPENDENCIES # Fixed bug where no packages found on debian-based + $ESCALATION_TOOL "$PACKAGER" install -y $DEPENDENCIES # Fixed bug where no packages found on debian-based ;; esac } @@ -102,5 +102,6 @@ install_additional_dependencies() { } checkEnv +checkEscalationTool installDepend install_additional_dependencies diff --git a/src/commands/system-setup/2-gaming-setup.sh b/src/commands/system-setup/2-gaming-setup.sh index 4393b0b0..890f25a4 100755 --- a/src/commands/system-setup/2-gaming-setup.sh +++ b/src/commands/system-setup/2-gaming-setup.sh @@ -7,16 +7,16 @@ installDepend() { echo -e "${YELLOW}Installing dependencies...${RC}" if [ "$PACKAGER" = "pacman" ]; then if ! grep -q "^\s*\[multilib\]" /etc/pacman.conf; then - echo "[multilib]" | sudo tee -a /etc/pacman.conf - echo "Include = /etc/pacman.d/mirrorlist" | sudo tee -a /etc/pacman.conf - sudo ${PACKAGER} -Syu + echo "[multilib]" | $ESCALATION_TOOL tee -a /etc/pacman.conf + echo "Include = /etc/pacman.d/mirrorlist" | $ESCALATION_TOOL tee -a /etc/pacman.conf + $ESCALATION_TOOL ${PACKAGER} -Syu else echo "Multilib is already enabled." fi if ! command_exists yay && ! command_exists paru; then echo "Installing yay as AUR helper..." - sudo ${PACKAGER} -S --needed --noconfirm base-devel - cd /opt && sudo git clone https://aur.archlinux.org/yay-git.git && sudo chown -R ${USER}:${USER} ./yay-git + $ESCALATION_TOOL ${PACKAGER} -S --needed --noconfirm base-devel + cd /opt && $ESCALATION_TOOL git clone https://aur.archlinux.org/yay-git.git && $ESCALATION_TOOL chown -R ${USER}:${USER} ./yay-git cd yay-git && makepkg --noconfirm -si else echo "Aur helper already installed" @@ -29,24 +29,24 @@ installDepend() { echo "No AUR helper found. Please install yay or paru." exit 1 fi - ${AUR_HELPER} -S --needed --noconfirm wine giflib lib32-giflib libpng lib32-libpng libldap lib32-libldap gnutls lib32-gnutls \ + $AUR_HELPER -S --needed --noconfirm wine giflib lib32-giflib libpng lib32-libpng libldap lib32-libldap gnutls lib32-gnutls \ mpg123 lib32-mpg123 openal lib32-openal v4l-utils lib32-v4l-utils libpulse lib32-libpulse libgpg-error \ lib32-libgpg-error alsa-plugins lib32-alsa-plugins alsa-lib lib32-alsa-lib libjpeg-turbo lib32-libjpeg-turbo \ sqlite lib32-sqlite libxcomposite lib32-libxcomposite libxinerama lib32-libgcrypt libgcrypt lib32-libxinerama \ ncurses lib32-ncurses ocl-icd lib32-ocl-icd libxslt lib32-libxslt libva lib32-libva gtk3 \ lib32-gtk3 gst-plugins-base-libs lib32-gst-plugins-base-libs vulkan-icd-loader lib32-vulkan-icd-loader elif [ "$PACKAGER" = "apt-get" ]; then - sudo ${PACKAGER} update - sudo ${PACKAGER} install -y wine64 wine32 libasound2-plugins:i386 libsdl2-2.0-0:i386 libdbus-1-3:i386 libsqlite3-0:i386 + $ESCALATION_TOOL ${PACKAGER} update + $ESCALATION_TOOL ${PACKAGER} install -y wine64 wine32 libasound2-plugins:i386 libsdl2-2.0-0:i386 libdbus-1-3:i386 libsqlite3-0:i386 elif [ "$PACKAGER" = "dnf" ] || [ "$PACKAGER" = "zypper" ]; then - sudo ${PACKAGER} install -y wine + $ESCALATION_TOOL ${PACKAGER} install -y wine else - sudo ${PACKAGER} install -y ${DEPENDENCIES} + $ESCALATION_TOOL ${PACKAGER} install -y ${DEPENDENCIES} fi } install_additional_dependencies() { - case $(which apt-get || which zypper || which dnf || which pacman) in + case $(command -v apt-get || command -v zypper || command -v dnf || command -v pacman) in *apt-get) version=$(git -c 'versionsort.suffix=-' ls-remote --tags --sort='v:refname' https://github.com/lutris/lutris | grep -v 'beta' | @@ -58,8 +58,8 @@ install_additional_dependencies() { # Install the downloaded .deb package using apt-get echo "Installing lutris_${version_no_v}_all.deb" - sudo apt-get update - sudo apt-get install ./lutris_${version_no_v}_all.deb + $ESCALATION_TOOL apt-get update + $ESCALATION_TOOL apt-get install ./lutris_${version_no_v}_all.deb # Clean up the downloaded .deb file rm lutris_${version_no_v}_all.deb @@ -70,34 +70,35 @@ install_additional_dependencies() { #Install steam on Debian if (lsb_release -i | grep -qi Debian); then #Enable i386 repos - sudo dpkg --add-architecture i386 + $ESCALATION_TOOL dpkg --add-architecture i386 # Install software-properties-common to be able to add repos - sudo apt-get install -y software-properties-common + $ESCALATION_TOOL apt-get install -y software-properties-common # Add repos necessary for installing steam - sudo apt-add-repository contrib -y - sudo apt-add-repository non-free -y + $ESCALATION_TOOL apt-add-repository contrib -y + $ESCALATION_TOOL apt-add-repository non-free -y #Install steam - sudo apt-get install steam-installer -y + $ESCALATION_TOOL apt-get install steam-installer -y else #Install steam on Ubuntu - sudo apt-get install -y steam + $ESCALATION_TOOL apt-get install -y steam fi ;; *zypper) - + ;; *dnf) - + ;; *pacman) - + ;; *) - - ;; + + ;; esac } checkEnv +checkEscalationTool installDepend install_additional_dependencies diff --git a/src/commands/system-setup/3-global-theme.sh b/src/commands/system-setup/3-global-theme.sh index e255ea76..3e66101d 100644 --- a/src/commands/system-setup/3-global-theme.sh +++ b/src/commands/system-setup/3-global-theme.sh @@ -17,19 +17,19 @@ install_theme_tools() { printf "${YELLOW}Installing theme tools (qt6ct and kvantum)...${RC}\n" case $PACKAGER in apt-get) - sudo apt-get update - sudo apt-get install -y qt6ct kvantum + $ESCALATION_TOOL apt-get update + $ESCALATION_TOOL apt-get install -y qt6ct kvantum ;; zypper) - sudo zypper refresh - sudo zypper --non-interactive install qt6ct kvantum + $ESCALATION_TOOL zypper refresh + $ESCALATION_TOOL zypper --non-interactive install qt6ct kvantum ;; dnf) - sudo dnf update - sudo dnf install -y qt6ct kvantum + $ESCALATION_TOOL dnf update + $ESCALATION_TOOL dnf install -y qt6ct kvantum ;; pacman) - sudo pacman -S --needed --noconfirm qt6ct kvantum + $ESCALATION_TOOL pacman -S --needed --noconfirm qt6ct kvantum ;; *) printf "${RED}Unsupported package manager. Please install qt6ct and kvantum manually.${RC}\n" @@ -52,7 +52,7 @@ EOF # Add QT_QPA_PLATFORMTHEME to /etc/environment if ! grep -q "QT_QPA_PLATFORMTHEME=qt6ct" /etc/environment; then printf "${YELLOW}Adding QT_QPA_PLATFORMTHEME to /etc/environment...${RC}\n" - echo "QT_QPA_PLATFORMTHEME=qt6ct" | sudo tee -a /etc/environment > /dev/null + echo "QT_QPA_PLATFORMTHEME=qt6ct" | $ESCALATION_TOOL tee -a /etc/environment > /dev/null printf "${GREEN}QT_QPA_PLATFORMTHEME added to /etc/environment.${RC}\n" else printf "${GREEN}QT_QPA_PLATFORMTHEME already set in /etc/environment.${RC}\n" @@ -70,6 +70,7 @@ EOF } checkEnv +checkEscalationTool install_theme_tools configure_qt6ct configure_kvantum diff --git a/src/commands/system-setup/4-remove-snaps.sh b/src/commands/system-setup/4-remove-snaps.sh index 26a115f3..f804aa5b 100644 --- a/src/commands/system-setup/4-remove-snaps.sh +++ b/src/commands/system-setup/4-remove-snaps.sh @@ -5,24 +5,26 @@ removeSnaps() { case $PACKAGER in pacman) - sudo ${PACKAGER} -Rns snapd + $ESCALATION_TOOL ${PACKAGER} -Rns snapd ;; apt-get|nala) - sudo ${PACKAGER} autoremove --purge snapd + $ESCALATION_TOOL ${PACKAGER} autoremove --purge snapd if [ "$ID" = ubuntu ]; then - sudo apt-mark hold snapd + $ESCALATION_TOOL apt-mark hold snapd fi ;; dnf) - sudo ${PACKAGER} remove snapd + $ESCALATION_TOOL ${PACKAGER} remove snapd ;; zypper) - sudo ${PACKAGER} remove snapd + $ESCALATION_TOOL ${PACKAGER} remove snapd ;; *) - echo "removing snapd not implemented for this package manager" + echo "Removing snapd not implemented for this package manager" + ;; esac } checkEnv +checkEscalationTool removeSnaps diff --git a/src/commands/system-setup/arch/paru-setup.sh b/src/commands/system-setup/arch/paru-setup.sh index f0b53ae1..8b9f388d 100755 --- a/src/commands/system-setup/arch/paru-setup.sh +++ b/src/commands/system-setup/arch/paru-setup.sh @@ -7,8 +7,8 @@ installDepend() { pacman) if ! command_exists paru; then echo "Installing paru as AUR helper..." - sudo "$PACKAGER" -S --needed --noconfirm base-devel - cd /opt && sudo git clone https://aur.archlinux.org/paru.git && sudo chown -R "$USER": ./paru + $ESCALATION_TOOL "$PACKAGER" -S --needed --noconfirm base-devel + cd /opt && $ESCALATION_TOOL git clone https://aur.archlinux.org/paru.git && $ESCALATION_TOOL chown -R "$USER": ./paru cd paru && makepkg --noconfirm -si echo "Paru installed" else @@ -22,4 +22,5 @@ installDepend() { } checkEnv -installDepend \ No newline at end of file +checkEscalationTool +installDepend diff --git a/src/commands/system-setup/arch/yay-setup.sh b/src/commands/system-setup/arch/yay-setup.sh index f29ecc3f..b248ef51 100755 --- a/src/commands/system-setup/arch/yay-setup.sh +++ b/src/commands/system-setup/arch/yay-setup.sh @@ -7,8 +7,8 @@ installDepend() { pacman) if ! command_exists yay; then echo "Installing yay as AUR helper..." - sudo "$PACKAGER" -S --needed --noconfirm base-devel - cd /opt && sudo git clone https://aur.archlinux.org/yay-git.git && sudo chown -R "$USER": ./yay-git + $ESCALATION_TOOL "$PACKAGER" -S --needed --noconfirm base-devel + cd /opt && $ESCALATION_TOOL git clone https://aur.archlinux.org/yay-git.git && $ESCALATION_TOOL chown -R "$USER": ./yay-git cd yay-git && makepkg --noconfirm -si echo "Yay installed" else @@ -22,4 +22,5 @@ installDepend() { } checkEnv -installDepend \ No newline at end of file +checkEscalationTool +installDepend diff --git a/src/commands/system-setup/system-update.sh b/src/commands/system-setup/system-update.sh index 1277143a..eef21bb1 100755 --- a/src/commands/system-setup/system-update.sh +++ b/src/commands/system-setup/system-update.sh @@ -7,8 +7,8 @@ fastUpdate() { pacman) if ! command_exists yay && ! command_exists paru; then echo "Installing yay as AUR helper..." - sudo ${PACKAGER} -S --needed --noconfirm base-devel || { echo -e "${RED}Failed to install base-devel${RC}"; exit 1; } - cd /opt && sudo git clone https://aur.archlinux.org/yay-git.git && sudo chown -R ${USER}:${USER} ./yay-git + $ESCALATION_TOOL ${PACKAGER} -S --needed --noconfirm base-devel || { echo -e "${RED}Failed to install base-devel${RC}"; exit 1; } + cd /opt && $ESCALATION_TOOL git clone https://aur.archlinux.org/yay-git.git && $ESCALATION_TOOL chown -R ${USER}:${USER} ./yay-git cd yay-git && makepkg --noconfirm -si || { echo -e "${RED}Failed to install yay${RC}"; exit 1; } else echo "Aur helper already installed" @@ -21,9 +21,9 @@ fastUpdate() { echo "No AUR helper found. Please install yay or paru." exit 1 fi - ${AUR_HELPER} -S --needed --noconfirm rate-mirrors-bin + $AUR_HELPER -S --needed --noconfirm rate-mirrors-bin if [ -s /etc/pacman.d/mirrorlist ]; then - sudo cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak + $ESCALATION_TOOL cp /etc/pacman.d/mirrorlist /etc/pacman.d/mirrorlist.bak fi # If for some reason DTYPE is still unknown use always arch so the rate-mirrors does not fail @@ -31,33 +31,33 @@ fastUpdate() { if [ "${DTYPE}" = "unknown" ]; then dtype_local="arch" fi - sudo rate-mirrors --top-mirrors-number-to-retest=5 --disable-comments --save /etc/pacman.d/mirrorlist --allow-root ${dtype_local} + $ESCALATION_TOOL rate-mirrors --top-mirrors-number-to-retest=5 --disable-comments --save /etc/pacman.d/mirrorlist --allow-root ${dtype_local} ;; apt-get|nala) - sudo apt-get update + $ESCALATION_TOOL apt-get update if ! command_exists nala; then - sudo apt-get install -y nala || { echo -e "${YELLOW}Falling back to apt-get${RC}"; PACKAGER="apt-get"; } + $ESCALATION_TOOL apt-get install -y nala || { echo -e "${YELLOW}Falling back to apt-get${RC}"; PACKAGER="apt-get"; } fi if [ "${PACKAGER}" = "nala" ]; then - sudo cp /etc/apt/sources.list /etc/apt/sources.list.bak - sudo nala update + $ESCALATION_TOOL cp /etc/apt/sources.list /etc/apt/sources.list.bak + $ESCALATION_TOOL nala update PACKAGER="nala" fi - sudo ${PACKAGER} upgrade -y + $ESCALATION_TOOL ${PACKAGER} upgrade -y ;; dnf) - sudo ${PACKAGER} update -y + $ESCALATION_TOOL ${PACKAGER} update -y ;; zypper) - sudo ${PACKAGER} ref - sudo ${PACKAGER} --non-interactive dup + $ESCALATION_TOOL ${PACKAGER} ref + $ESCALATION_TOOL ${PACKAGER} --non-interactive dup ;; yum) - sudo ${PACKAGER} update -y - sudo ${PACKAGER} upgrade -y + $ESCALATION_TOOL ${PACKAGER} update -y + $ESCALATION_TOOL ${PACKAGER} upgrade -y ;; xbps-install) - sudo ${PACKAGER} -Syu + $ESCALATION_TOOL ${PACKAGER} -Syu ;; *) echo -e "${RED}Unsupported package manager: $PACKAGER${RC}" @@ -70,23 +70,23 @@ updateSystem() { echo -e "${GREEN}Updating system${RC}" case ${PACKAGER} in nala|apt-get) - sudo "${PACKAGER}" update -y - sudo "${PACKAGER}" upgrade -y + $ESCALATION_TOOL "${PACKAGER}" update -y + $ESCALATION_TOOL "${PACKAGER}" upgrade -y ;; yum|dnf) - sudo "${PACKAGER}" update -y - sudo "${PACKAGER}" upgrade -y + $ESCALATION_TOOL "${PACKAGER}" update -y + $ESCALATION_TOOL "${PACKAGER}" upgrade -y ;; pacman) - sudo "${PACKAGER}" -Sy --noconfirm --needed archlinux-keyring - sudo "${PACKAGER}" -Su --noconfirm + $ESCALATION_TOOL "${PACKAGER}" -Sy --noconfirm --needed archlinux-keyring + $ESCALATION_TOOL "${PACKAGER}" -Su --noconfirm ;; zypper) - sudo ${PACKAGER} ref - sudo ${PACKAGER} --non-interactive dup + $ESCALATION_TOOL ${PACKAGER} ref + $ESCALATION_TOOL ${PACKAGER} --non-interactive dup ;; xbps-install) - sudo ${PACKAGER} -Syu + $ESCALATION_TOOL ${PACKAGER} -Syu ;; *) echo -e "${RED}Unsupported package manager: ${PACKAGER}${RC}" @@ -102,6 +102,7 @@ updateFlatpaks() { } checkEnv +checkEscalationTool fastUpdate updateSystem updateFlatpaks