2021-06-26 14:00:10 -04:00
|
|
|
#!/bin/bash
|
2021-07-14 08:54:16 -04:00
|
|
|
set -e
|
|
|
|
|
2021-07-11 05:42:04 -04:00
|
|
|
# Run the "I'm too lazy to fix it myself all in one" script
|
2021-07-09 20:02:36 -04:00
|
|
|
if [ "$1" == "remote" ]; then
|
2021-07-20 04:27:49 -04:00
|
|
|
exec sudo bash -c "VERSION=2 . <(wget -qO- https://gitlab.com/garuda-linux/themes-and-settings/settings/garuda-common-settings/-/snippets/2147440/raw/main/remote-update) \"$2\""
|
2021-07-09 20:02:36 -04:00
|
|
|
fi
|
|
|
|
|
2021-06-28 10:47:01 -04:00
|
|
|
# Check for AUR helper
|
2021-07-14 08:54:16 -04:00
|
|
|
if [ -x /usr/bin/paru ] && [[ $EUID -ne 0 ]]; then
|
2021-06-28 10:47:01 -04:00
|
|
|
upd_cmd="paru -Su"
|
|
|
|
echo "Detected Paru, using it to update the system.."
|
2021-07-14 08:54:16 -04:00
|
|
|
elif [ -x /usr/bin/yay ] && [[ $EUID -ne 0 ]]; then
|
2021-06-28 10:47:01 -04:00
|
|
|
upd_cmd="yay -Su"
|
|
|
|
echo "Detected Yay, using it to update the system.."
|
2021-07-14 08:54:16 -04:00
|
|
|
else
|
|
|
|
upd_cmd="sudo pacman -Su"
|
|
|
|
if [[ $EUID -ne 0 ]]; then
|
|
|
|
echo "No AUR helper installed, using Pacman to update.."
|
|
|
|
else
|
|
|
|
echo "Executed as root, using Pacman to update.."
|
|
|
|
fi
|
2021-06-28 10:47:01 -04:00
|
|
|
fi
|
|
|
|
|
2021-07-14 08:54:16 -04:00
|
|
|
if [ -x /usr/bin/reflector ]; then
|
|
|
|
# Refresh mirrorlist
|
|
|
|
echo "Refreshing mirrorlists.."
|
2021-08-08 15:51:23 -04:00
|
|
|
sudo reflector --latest 5 --age 2 --fastest 5 --protocol https --sort rate --save /etc/pacman.d/mirrorlist && cat /etc/pacman.d/mirrorlist || { echo -e "\033[1;31m\nFailed to update mirrorlist\n\033[0m"; }
|
2021-07-14 08:54:16 -04:00
|
|
|
fi
|
2021-06-26 14:00:10 -04:00
|
|
|
|
2021-09-24 01:33:42 -04:00
|
|
|
echo ""
|
|
|
|
|
|
|
|
# Update pacman Files database
|
|
|
|
echo "Checking pacman files database update.."
|
|
|
|
sudo pacman -Fy
|
|
|
|
|
|
|
|
echo ""
|
|
|
|
echo "pacman files database updated!"
|
|
|
|
echo ""
|
|
|
|
|
2021-06-26 14:00:10 -04:00
|
|
|
# Check for keyring update & update as needed
|
2021-07-14 08:54:16 -04:00
|
|
|
echo "Checking for keyring update before starting full system update.."
|
|
|
|
if pacman -Qq blackarch-keyring &> /dev/null; then
|
|
|
|
sudo pacman -Sy archlinux-keyring blackarch-keyring chaotic-keyring --needed && $upd_cmd || false
|
|
|
|
else
|
|
|
|
sudo pacman -Sy archlinux-keyring chaotic-keyring --needed && $upd_cmd || false
|
2021-07-02 05:03:30 -04:00
|
|
|
fi
|
2021-06-27 04:36:44 -04:00
|
|
|
echo ""
|
2021-06-26 14:00:10 -04:00
|
|
|
|
|
|
|
# Update mlocate index
|
2021-07-08 02:27:55 -04:00
|
|
|
if [ -x /usr/bin/locate ]; then
|
2021-07-08 02:26:31 -04:00
|
|
|
echo "Updating mlocate index.."
|
|
|
|
sudo updatedb
|
|
|
|
fi
|
2021-09-15 13:17:44 -04:00
|
|
|
echo ""
|
2021-07-08 02:26:31 -04:00
|
|
|
|
|
|
|
# Update fish completions
|
2021-07-14 08:54:16 -04:00
|
|
|
if [ -x /usr/bin/fish ]; then
|
|
|
|
if [[ $EUID -ne 0 ]]; then
|
|
|
|
fish -c fish_update_completions
|
|
|
|
elif [ ! -z "$SUDO_UID" ]; then
|
|
|
|
sudo -u \#$SUDO_UID fish -c fish_update_completions
|
|
|
|
fi
|
2021-07-08 02:26:31 -04:00
|
|
|
fi
|
2021-09-15 13:17:44 -04:00
|
|
|
echo ""
|
|
|
|
|
|
|
|
# Update micro plugins
|
|
|
|
if [ -x /usr/bin/micro ]; then
|
|
|
|
if [[ $EUID -ne 0 ]]; then
|
|
|
|
micro -plugin update
|
|
|
|
elif [ ! -z "$SUDO_UID" ]; then
|
|
|
|
sudo -u \#$SUDO_UID micro -plugin update
|
|
|
|
fi
|
|
|
|
fi
|
2021-07-08 02:26:31 -04:00
|
|
|
|
|
|
|
echo ""
|
|
|
|
echo "System updated! 🐧"
|