Handy scripts you'd like to share

This is an updated version of gun.sh (Garuda Update Now) incorperating your suggestion @elite .

#!/bin/bash
#cat /usr/local/bin/gun.sh
#sudo chmod +x  /usr/local/bin/gun.sh

black='\033[0;30m'
dk_gray='\033[1;30m'
red='\033[0;31m'
lt_red='\033[1;31m'
green='\033[0;32m'
lt_green='\033[1;32m'
yellow='\033[1;33m'
blue='\033[0;34m'
lt_blue='\033[1;34m'
purple='\033[0;35m'
lt_purple='\033[1;35m'
orange='\033[0;33m'
cyan='\033[0;36m'
lt_gray='\033[0;37m'
white='\033[1;37m'
default='\033[0m' # Default Color

HEIGHT=20
WIDTH=80
CHOICE_HEIGHT=4
BACKTITLE="Garuda Update Now"
TITLE="Garuda Update Advanced Options"
MENU="Choose one of the following options:"

OPTIONS=(1 "garuda-update + refresh mirrorlist"
         2 "garuda-update + Chaotic AUR + AUR updates + refresh mirrorlist"
         3 "garuda-update - skip refresh mirrorlist"
         4 "garuda-update + Chaotic AUR + AUR updates - skip refresh mirrorlist"
         5 "garuda-update --noconfirm"
         6 "garuda-update remote fix"
         7 "garuda-update remote keyring"
         8 "garuda-update remote fullfix"
         9 "garuda-update remote reinstall"
        10 "garuda-update remote reset-snapper"
        11 "garuda-update remote reset-audio"
        12 "garuda-update -- -u")

CHOICE=$(dialog --clear \
                --backtitle "$BACKTITLE" \
                --title "$TITLE" \
                --menu "$MENU" \
                $HEIGHT $WIDTH $CHOICE_HEIGHT \
                "${OPTIONS[@]}" \
                2>&1 >/dev/tty)

clear
case $CHOICE in
        1)
            echo -e "\nAlways ensure you have adequate free space before initiating a system update..."
            echo "BTRFS space calculations are inexact, you appear to have the following range of values:"
            echo -e "\n$(btrfs filesystem usage /  2> /dev/null | grep -i 'estimated')"
            echo -e "\n${lt_blue}You have selected the ${red}garuda-update${default} ${lt_blue}command, which executes:${default}"
            echo -e "${yellow}garuda-update + ${lt_purple}refresh mirrorlist${default}\n"
            echo -e "${red}Enter your sudo password to proceed... or press CTRL+C to cancel${default}\n"
            garuda-update
            ;;
        2)
            echo -e "\nAlways ensure you have adequate free space before initiating a system update..."
            echo "BTRFS space calculations are inexact, you appear to have the following range of values:"
            echo -e "\n$(btrfs filesystem usage /  2> /dev/null | grep -i 'estimated')"
            echo -e "\n${lt_blue}You have selected the ${red}garuda-update -a${default} ${lt_blue}command, which executes:${default}"
            echo -e "${yellow}garuda-update + ${lt_green}Chaotic AUR + AUR updates + ${lt_purple}refresh mirrorlist${default}\n"
            echo -e "${red}Enter your sudo password to proceed... or press CTRL+C to cancel${default}\n"
            garuda-update -a
            ;;
        3)
            echo -e "\nAlways ensure you have adequate free space before initiating a system update..."
            echo "BTRFS space calculations are inexact, you appear to have the following range of values:"
            echo -e "\n$(btrfs filesystem usage /  2> /dev/null | grep -i 'estimated')"
            echo -e "\n${lt_blue}You have selected the ${red}garuda-update --skip-mirrorlist${default} ${lt_blue}command, which executes:${default}"
            echo -e "${yellow}garuda-update - ${orange}skip refresh mirrorlist${default}\n"
            echo -e "${red}Enter your sudo password to proceed... or press CTRL+C to cancel${default}\n"
            garuda-update --skip-mirrorlist
            ;;
        4)
            echo -e "\nAlways ensure you have adequate free space before initiating a system update..."
            echo "BTRFS space calculations are inexact, you appear to have the following range of values:"
            echo -e "\n$(btrfs filesystem usage /  2> /dev/null | grep -i 'estimated')"
            echo -e "\n${lt_blue}You have selected the ${red}garuda-update -a --skip-mirrorlist${default} ${lt_blue}command, which executes:${default}"
            echo -e "${yellow}garuda-update + ${lt_green}Chaotic AUR + AUR+updates - ${orange}skip refresh mirrorlist${default}\n"
            echo -e "${red}Enter your sudo password to proceed... or press CTRL+C to cancel${default}\n"
            garuda-update -a --skip-mirrorlist
            ;;
        5)
            echo -e "\n${lt_blue}You have selected ${red}garuda-update –noconfirm${default}"
            echo  "This command will perform a system update without multiple confirmation prompts"
            echo -e "This emulates a custom (safer) version of --noconfirm for pacman (PACMAN_NOCONFIRM=1)\n"
            echo -e "${red}Enter your sudo password to proceed... or press CTRL+C to cancel${default}\n"
            garuda-update --noconfirm
             ;;
        6)
            echo -e "\n${lt_blue}You have selected ${red}garuda-update remote fix${default}"
            echo -e "This command will perform the following operation(s):\n"
            echo "Reset pacman.conf"
            echo -e "Refresh keyrings\n"
            echo -e "${red}Enter your sudo password to proceed... or press CTRL+C to cancel${default}\n"
            garuda-update remote fix
            ;;
        7)
            echo -e "\n${lt_blue}You have selected ${red}garuda-update remote keyring${default}"
            echo -e "This command will perform the following operation(s):\n"
            echo -e "Refresh the keyring without resetting pacman.conf\n"
            echo -e "${red}Enter your sudo password to proceed... or press CTRL+C to cancel${default}\n"
            garuda-update remote keyring
            ;;
        8)
            echo -e "\n${lt_blue}You have selected ${red}garuda-update remote fullfix${default}"
            echo -e "This command will perform the following operation(s):\n"
            echo "Reset pacman.conf"
            echo "Refresh keyrings"
            echo -e "Reinstall all Garuda OS packages\n"
            echo -e "${red}Enter your sudo password to proceed... or press CTRL+C to cancel${default}\n"
            garuda-update remote fullfix
            ;;
         9)
            echo -e "\n${lt_blue}You have selected ${red}garuda-update remote reinstall${default}"
            echo -e "This command will perform the following operation(s):\n"
            echo -e "Reinstall all Garuda OS packages\n"
            echo -e "${red}Enter your sudo password to proceed... or press CTRL+C to cancel${default}\n"
            garuda-update remote reinstall
            ;;
        10)
            echo -e "\n${lt_blue}You have selected ${red}garuda-update remote reset-snapper${default}"
            echo -e "This command will perform the following operation(s):\n"
            echo "Remove all backup subvolumes and snapshots created by Snapper"
            echo -e "Force recreate the Snapper configs\n"
            echo -e "${red}Enter your sudo password to proceed... or press CTRL+C to cancel${default}\n"
            garuda-update remote reset-snapper
            ;;
        11)
            echo -e "\n${lt_blue}You have selected ${red}garuda-update remote reset-audio${default}"
            echo -e "This command will perform the following operation(s):\n"
            echo "Reinstall WirePlumber and Pipewire-support"
            echo "Disable/enable the WirePlumber and Pipewire-support services"
            echo -e "Reset the audio configuration to default\n"
            echo -e "${red}Enter your sudo password to proceed... or press CTRL+C to cancel${default}\n"
            garuda-update remote reset-audio
            ;;
         12)
            echo -e "\n${lt_blue}You have selected ${red}garuda-update -- -u${default}"
            echo -e "This command will perform the following operation(s):\n"
            echo -e "Undocumented parameter to fix some update issues when receiving a warning about downgrading\n"
            echo -e "${red}Enter your sudo password to proceed... or press CTRL+C to cancel${default}\n"
            garuda-update -- -u
            ;;
esac


I modified the “free space check” language and command, as well as removing the free space pop-up warning.

3 Likes