Skip to content

Instantly share code, notes, and snippets.

@DRBragg
Created August 20, 2020 21:14
Show Gist options
  • Save DRBragg/ad126ae6d8eab23d05c04ec1f26cdcca to your computer and use it in GitHub Desktop.
Save DRBragg/ad126ae6d8eab23d05c04ec1f26cdcca to your computer and use it in GitHub Desktop.
Little shell script run via cron job to update my google domain to point to my local server.
#!/bin/bash
IP_ADDR_FILE="ip_addr.txt"
old_ip=$(cat $IP_ADDR_FILE)
current_ip=$(curl ifconfig.me/ip)
if [ "$old_ip" != "$current_ip" ]; then
curl "https://username:[email protected]/nic/update?hostname=test.drbragg.ninja&myip=$current_ip"
rm $IP_ADDR_FILE
touch $IP_ADDR_FILE
echo "$current_ip" > $IP_ADDR_FILE
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment