-
-
Save dullage/88a41298d5e0120e76c514f3366aa80d to your computer and use it in GitHub Desktop.
A script to ping healthchecks.io when no apt security updates are available. To be run as a cron job.
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
#!/usr/bin/env bash | |
set -e | |
hc_guid=<insert healthchecks.io guid> | |
sudo apt update | |
if [[ $1 == "upgrade" ]] | |
then | |
printf "Upgrading...\n" | |
sudo apt upgrade | |
fi | |
security_updates=$(sudo apt list --upgradable | grep "\-security" | wc -l) | |
if [[ $security_updates > 0 ]] | |
then | |
printf "$security_updates Security Updates Available!\n" | |
elif test -f /var/run/reboot-required | |
then | |
printf "Reboot Required!\n" | |
else | |
printf "All good, pinging healthchecks.io..." | |
curl -fsS --retry 3 https://hc-ping.com/$hc_guid | |
printf "\n" | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment