#!/bin/sh # # Name: dyndnsup # Description: Auto-update dynamic dns service # Version: 1.0 # Author: Jose V Beneyto, # Depends on: netcat # checkdepends: check dependecies checkdepends() { for dep in netcat do which $dep >& /dev/null if [ $? == 1 ] then echo "$dep not found, please install it!" >&2 exit 1 fi done } # readconfig: readconfig() { if [ -f $CONFIG_FILE ] then . $CONFIG_FILE [ "$DYNDNS_SERVER" == "" ] && { echo "DYNDNS_SERVER variable not set!"; exit 1 } [ "$DYNDNS_PROTOCOL" == "" ] && { echo "DYNDNS_PROTOCOL variable not set!"; exit 1 } [ "$DYNDNS_HOSTNAME" == "" ] && { echo "DYNDNS_HOSTNAME variable not set!"; exit 1 } [ "$DYNDNS_IF" == "" ] && { echo "DYNDNS_IF variable not set!"; exit 1 } fi } # checkip: checkip() { current_ip=`ifconfig $DYNDNS_IF | grep 'inet addr' | awk '{print $2}' | sed -e 's/.*://'` last_ip=`cat /var/cache/dyndnsup.cache | grep 'ip' | sed 's/ip=//g'` # TODO # DYNDNS_IP= } # chech time: checktime(){ # TODO # EXPIRED_TIME= } # update: update() { DYNDNS_IP=$1 echo -ne "GET /nic/update?system=$DYNDNS_PROTOCOL&hostname=$DYNDNS_HOSTNAME&myip=$DYNDNS_IP" | netcat -vv $SERVER_DYNDNS 80 } # config file # (you can edit this file to overwrite script variables) CONFIG_FILE="/etc/dyndnsup.conf" # edit script variables # (CONFIG_FILE overwrite them) DYNDNS_SERVER="members.dyndns.org" DYNDNS_PROTOCOL="dyndns2" DYNDNS_HOSTNAME="mikeux.dyndns.org" DYNDNS_IP="" DYNDNS_IF="eth0" checkdepends readconfig checkip checktime update exit 0 # End of File