Skip to content

Instantly share code, notes, and snippets.

@halocaridina
Created August 3, 2018 12:40
Show Gist options
  • Save halocaridina/ad5a3513b95dec3a05590f6d38db9ea8 to your computer and use it in GitHub Desktop.
Save halocaridina/ad5a3513b95dec3a05590f6d38db9ea8 to your computer and use it in GitHub Desktop.
#!/usr/bin/env sh
/usr/bin/nc -w 5 -z 8.8.8.8 53 >/dev/null 2>&1
online=$?
interface=$1 status=$2
case $status in
up)
if [ $online -eq 0 ]; then
/usr/bin/tzupdate --timeout 15
/usr/bin/systemd-cat -t "tzupdater" /usr/bin/echo "***** UPDATED TIMEZONE VIA NETWORK GEOLOCATION ON $(date) *****"
exit 0
else
/usr/bin/systemd-cat -t "tzupdater" /usr/bin/echo "***** CANNOT UPDATE TIMEZONE DUE TO NETWORK ROUTE BEING DOWN - $(date) *****"
exit 0
fi
;;
down)
/usr/bin/systemd-cat -t "tzupdater" /usr/bin/echo "***** WILL CHECK TIMEZONE WHEN NETWORK ROUTE RETURNS - $(date) *****"
exit 0
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment