forked from FunctionalHacker/freedns-afraid-update-script
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate.sh
executable file
·23 lines (18 loc) · 965 Bytes
/
update.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
#!/bin/bash
# You can save this file wherever you want, but in the examples, I'm assuming
# that you have it in /scripts/update.sh
######## EDIT THESE VARIABLES TO MATCH YOUR CONFIGURATION #############################
domain="***YOUR DOMAIN***"
updateurl="***YOUR UPDATE URL***"
# You can get the update url by going to http://freedns.afraid.org/dynamic/v2/
# and copying the link under your domain that starts with http://sync.afraid.org/u/...
#######################################################################################
registered=$(nslookup $domain|tail -n2|grep A|sed s/[^0-9.]//g)
current=$(curl -s http://checkip.dyndns.org|sed s/[^0-9.]//g)
if [ "$current" != "$registered" ]; then
curl -s >> /dev/null $updateurl
echo "The DNS record of $domain was updated to $current from $registered"
else
echo "DNS record up to date"
fi
# Check the cron example on this repository to see how you can run this automatically