extra-scripts/check-system-update
2021-11-28 18:29:51 +01:00

49 lines
1.4 KiB
Bash
Executable File

#!/usr/bin/bash
yay -Syua
echo "==> Updating flatpaks..."
flatpak update
echo "==> Syncing database..."
sudo pacman -Sy --noconfirm || exit 1
function update_init_fail {
echo "==> Initialising system update failed." >&2
echo "==> Cleaning up..." >&2
sudo rm -rf /var/lib/system-update
exit 1
}
if pacman -Qu >&-; then
echo "==> System updates available."
echo "==> Downloading system updates..."
if [ ! -e /var/lib/system-update ]; then
sudo mkdir -p /var/lib/system-update || update_init_fail
fi
sudo pacman -Suw --noconfirm --cachedir /var/lib/system-update || update_init_fail
sudo ln -s /var/lib/system-update /system-update || update_init_fail
echo "==> System update scheduled for next reboot."
else
echo "==> Up to date."
if [ -e /system-update ]; then
echo "==> There is another system update pending."
while true; do
read -n1 -p"==> Unschedule system update? [Y/n]: " q
[ ! $q = "" ] && echo
case $q in
y|Y|"")
sudo rm /system-update || {
echo "==> Could not unschedule pending system update" >&2
exit 1
}
echo "==> Unscheduled pending system update"
break;;
n|N)
break;;
*)
continue;;
esac
done
fi
fi