Created
July 13, 2019 14:30
-
-
Save pcrockett/c0cf4f509eed0fb48e7e02d25c7af846 to your computer and use it in GitHub Desktop.
Unattended security updates with healthcheck.io monitoring
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# sudo apt install unattended-upgrades | |
# | |
# crontab example: | |
# 0 4 * * * /home/user/unattended-upgrade.sh >/home/user/upgrade-log 2>&1 | |
# | |
# https://vaneyckt.io/posts/safer_bash_scripts_with_set_euxo_pipefail/ | |
set -Eeuo pipefail | |
if unattended-upgrade; then | |
curl -fsS --retry 3 https://hc-ping.com/MONITOR_ID_HERE > /dev/null | |
if [ -f "/var/run/reboot-required" ]; then | |
shutdown now -r | |
fi | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment