Created
August 3, 2018 12:40
-
-
Save halocaridina/ad5a3513b95dec3a05590f6d38db9ea8 to your computer and use it in GitHub Desktop.
This file contains hidden or 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 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