Mainos / Advertisement:

Translations:DDNS päivitysohjelmat/31/fi

Kohteesta Taisto
Siirry navigaatioon Siirry hakuun
  1. !/bin/bash
USERNAME="dyndnsusername"
PASSWORD="dyndnspassword"
HOSTNAME="yourdomain"
IP=`curl -s http://checkip.dy.fi/ | grep -o '\([0-9]\{1,3\}\.\)\{3\}[0-9]\{1,3\}'`

ABUSE_LOCK_FILE="/tmp/dyndns.abuse"
LAST_IP_FILE="/tmp/lastip"
LAST_IP=`cat $LAST_IP_FILE`

#lockfile check, lockfile is only used if a abuse result appears
if [ -e "$ABUSE_LOCK_FILE" ]; then
     echo "Dyndns abuse lockfile exisits: $ABUSE_LOCK_FILE"  
     exit 1
fi
#end of lockfile check

if [ "$IP" != "$LAST_IP" ]; then
   echo "Current IP: $IP"
   RESULT=`curl -D --user $USERNAME:$PASSWORD  "http://dy.fi/nic/update?hostname=$HOSTNAME&myip=$IP" | grep -o -E  "good|nochg|abuse|badauth|notfqdn|nohost|abuse|dnserr"`
   echo "Dyndns.org says: $RESULT!"
else
   echo "IP is still the same: $LAST_IP"
fi
Mainos / Advertisement: