Created
April 1, 2019 19:58
-
-
Save pilasguru/a60dd818c74c952763be710cb618930e 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
#!/bin/sh | |
############################################################################## | |
# application name: dnsactual | |
# other files: dnsactual.conf (keeps the last updated ip) | |
# dnsactual.log (register date & time of the actualization) | |
# Modified by: Rodolfo Pilas <[email protected]> | |
# Original Author: Ernest Danton - Date: 01/29/2007 | |
############################################################################## | |
################# | |
# mydomain.com | |
################# | |
DNSSTORE='/usr/local/etc/freedns/dnsactual.conf' | |
DNSLOG='/var/log/freedns.log' | |
FDCHE='http://freedns.afraid.org/dynamic/check.php' | |
FDUPD='https://freedns.afraid.org/dynamic/update.php?Z2RA-KEY-GET-FROM-YOUR-ACCOUNTDQ=' | |
WGETOPT='--no-check-certificate --output-file=/dev/null --output-document=/dev/stdout --quiet' | |
REMOTESTRE=user@remote-server-to-storage-log-OPTIONAL | |
REMOTEPORT=22 | |
# Create DNSSTORE folder if not exists | |
if [ ! -d /usr/local/etc/freedns ]; then mkdir -p /usr/local/etc/freedns; fi | |
if test -f $DNSSTORE; then | |
CacheIP=$(cat $DNSSTORE) | |
fi | |
if [ "$1" = "-d" ]; then echo "CacheIP: .$CacheIP."; fi | |
CurreIP=$(/usr/bin/wget $WGETOPT $FDCHE | grep Detected | cut -d : -f 2 | tr -d " ") | |
if [ "$1" = "-d" ]; then echo "CurreIP: .$CurreIP."; fi | |
if test "$CurreIP" != "$CacheIP"; then | |
# The IP has change | |
if [ "$1" = "-d" ]; then echo "Updating http://free.afraid.org with $CurreIP"; fi | |
/usr/bin/wget $WGETOPT $FDUPD | |
echo `date` "Updating log with IP " $CurreIP >> $DNSLOG | |
echo $CurreIP > $DNSSTORE | |
# Optional remote record to have external record of actual IP | |
scp -q -P$REMOTEPORT $DNSSTORE $REMOTESTORE: | |
else | |
if [ "$1" = "-d" ]; then echo "No update"; fi | |
fi | |
exit 0 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment