Skip to content

Instantly share code, notes, and snippets.

@dullage
Last active December 5, 2023 13:14
Show Gist options
  • Save dullage/88a41298d5e0120e76c514f3366aa80d to your computer and use it in GitHub Desktop.
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.
#!/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