1
0
Fork 0

Sleep timer, unintrusive upgrade and reboot

- This script will reboot the system to commence an upgrade on the proceeding boot
- Incrementing sleep timer with a limit of one hour
- And some cleanup.
This commit is contained in:
Xavier Moffett 2023-04-14 00:22:58 +00:00
parent 0fa463d064
commit ae73a09e95

View file

@ -3,14 +3,19 @@
source /etc/os-release source /etc/os-release
MIRROR="https://mirror.xenyth.net/fedora/linux/releases" MIRROR="https://mirror.xenyth.net/fedora/linux/releases"
VERSION_NEXT=$(($VERSION_ID + 1)) VERSION_NEXT=$(($VERSION_ID + 1))
STATUS_FILE=/var/cache/dnf/upgrade.release
SLEEP=30
check () { check () {
if [[ -f $STATUS_FILE ]]; then
upgrade
return
fi
curl -s -o /dev/null $MIRROR curl -s -o /dev/null $MIRROR
if [[ $? != 0 ]]; then if [[ $? != 0 ]]; then
echo "Internet connection, or mirror, is offline. Trying again in 60 seconds.." timeout
sleep 60
check
return return
fi fi
@ -24,20 +29,31 @@ check () {
upgrade upgrade
;; ;;
*) *)
echo "Mirror returned unhandled HTTP Response Code: $mirror_response." echo "Mirror returned unhandled HTTP response: $mirror_response."
;; ;;
esac esac
} }
download () {
dnf upgrade --refresh -y
dnf system-upgrade download --releasever=$VERSION_NEXT -y
[[ $? == 0 ]] && touch $STATUS_FILE
}
upgrade () { upgrade () {
dnf upgrade --refresh -y rm $STATUS_FILE
dnf system-upgrade download --releasever=$VERSION_NEXT -y dnf system-upgrade reboot -y
}
wall "WARNING: An upgrade from Fedora $VERSION_ID to Fedora $VERSION_NEXT is commencing! Your computer will reboot in 60 seconds." timeout () {
if [[ $SLEEP -gt 3840 ]]; then
sleep 60 echo "Upgrade check has timed out. Aborting operation."
exit 1
dnf system-upgrade reboot -y fi
echo "Internet connection, or mirror, is offline. Sleeping for $SLEEP seconds.."
sleep $SLEEP
SLEEP=$(($SLEEP*2))
check
} }
check check