Initial commit (I feel unsafe)
This commit is contained in:
26
ubuntu_auto_apt_upgrade
Normal file
26
ubuntu_auto_apt_upgrade
Normal file
@@ -0,0 +1,26 @@
|
||||
#!/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"
|
||||
Reference in New Issue
Block a user