27 lines
690 B
Bash
27 lines
690 B
Bash
#!/bin/bash
|
|
|
|
mkdir -p "${HOME}"/upgrade_logs
|
|
logFile=${HOME}/upgrade_logs/$(date +%y_%m).log
|
|
rebootDelayInMinutes=10
|
|
|
|
{
|
|
echo "[+] $(date -I'seconds')"
|
|
echo "[+] Auto apt upgrade starting..."
|
|
sudo apt-get update
|
|
|
|
sudo apt-get upgrade -y
|
|
|
|
if [[ -s /var/run/reboot-required ]]; then
|
|
curl -Ss \
|
|
-H "Title: System Reboot scheduled" \
|
|
-H "Priority: 3" \
|
|
-H "Tags: loudspeaker,reboot" \
|
|
-d "Rebooting in $rebootDelayInMinutes minutes. Reason: package updates" \
|
|
"${NOTIF_URL}"
|
|
echo "[!] Rebooting in $rebootDelayInMinutes minutes..."
|
|
echo 'sudo reboot' | at now + $rebootDelayInMinutes minutes
|
|
else
|
|
echo "[+] Upgrade complete, no reboot required."
|
|
fi
|
|
} &>>"$logFile"
|