#!/bin/sh
#
# Author [email protected]
#
# /usr/local/bin/ip-update
#
# Version 7.3.2
#
# Requires: yi.bs, ddclient
#
# Public: yes
# Copyright (C) 2002 "Dirk-Lueder Kreie"
#
# This program is free software; you can redistribute it and/or modify it
# under the terms of the GNU General Public License as published by the Free
# Software Foundation; either version 2 of the License, or (at your option)
# any later version.
#
# This program is distributed in the hope that it will be useful, but WITHOUT
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
# more details.
#
# You should have received a copy of the GNU General Public License along with
# this program; if not, write to the
#
# Free Software Foundation, Inc.
# 59 Temple Place, Suite 330
# Boston, MA 02111-1307
# USA.
lckfile="/var/sysflags/ip-update"
trap "rm $lckfile; exit" SIGHUP SIGINT SIGTERM
EXT_IF="ppp0"
export LC_ALL=C
if [ "`find $lckfile -cmin +15 2>&1`" = "$lckfile" ]; then
test -e $lckfile && rm $lckfile
echo `date`" - Warning: old lockfile \"$lckfile\" exists"
echo `date`" - Warning: old lockfile \"$lckfile\" exists" > /dev/stderr
fi
test -e $lckfile && echo `date`" - Fatal: lockfile \"$lckfile\" exists"
test -e $lckfile && exit 1
touch $lckfile
chmod 666 $lckfile
zonefiledir="/var/bind/pri"
oldip=`cat /var/log/oldip`
oldserial=`cat /var/log/oldserial`
curip=`/usr/local/bin/getip $EXT_IF`
curserial=`date +%Y%m%d%H`
if [ -z "$curip" ]; then
curip=0.0.0.0
fi
if [ "$oldip" != "$curip" ]; then
echo "old \"$oldip\" != \"$curip\" new"
wget -O - "http://ipv4.tunnelbroker.net/ipv4_end.php?ipv4b=${curip}&tunnel_id=50183&user_id=f727c9c7e21b5ed979e8bdeac979bdd0&pass=45c5cf7519c147827a705ce8623bffef" &
/usr/local/bin/yi.bs&
/usr/local/bin/ddclient -daemon=0 -syslog -use=if -if=$EXT_IF
cp ${zonefiledir}/deelkar.ath.cx.zone /tmp/deelkar.ath.cx.zone.backup-$curserial
sed -e "s/$oldip/$curip/" -e 's/.*\(; serial : YYYYMMDDhh\)/\t\t\t\t'"$curserial"' \1/' < /tmp/deelkar.ath.cx.zone.backup-$curserial > ${zonefiledir}/deelkar.ath.cx.zone || cp /tmp/deelkar.ath.cx.zone.backup-$curserial ${zonefiledir}/deelkar.ath.cx.zone
echo "; $oldserial > $curserial : $oldip > $curip" >> ${zonefiledir}/deelkar.ath.cx.zone
/etc/init.d/named reload
fi
echo "$curip" > /var/log/oldip
echo "$curserial" > /var/log/oldserial
rm -f $lckfile