#!/bin/sh ### # # FreeWLAN Addons - http://www.freewlan.info # # 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., 51 Franklin Street, Fifth Floor, Boston, # MA 02110-1301, USA # # http://www.gnu.org/copyleft/gpl.html # ### . /etc/functions.sh config_load dyndns config_get enable dyndns enable config_get user dyndns user config_get pass dyndns pass config_get url dyndns url if enabled $enable && [ ! -f /tmp/dyndns.lock ] then if [ ! -f /etc/config/ip.cache ] then echo '0.0.0.0'>/etc/config/ip.cache fi ip_now=$(expr "$(wget -O - http://checkip.dyndns.org 2> /dev/null)" : '.*[^0-9]\([0-9]*\.[0-9]*\.[0-9]*\.[0-9]*\)') if [ "$ip_now" = "" ] then exit 1 fi date=`date +"%s"` date_last=`date -r /etc/config/ip.cache +"%s"` if [ `expr $date - $date_last` -lt 2505600 ] then ip_old=$(cat /etc/config/ip.cache) if [ "$ip_old" = "$ip_now" ] then exit 0 # IP not changed and 29 days havn't passed fi fi return="$(wget -q -O - http://$user:$pass@members.dyndns.org/nic/update\?system=dyndns\&hostname=$url 2> /dev/null | awk '{print $1}')" if [ "$return" = "good" ] || [ "$return" = "nochg" ] then echo "$ip_now">/etc/config/ip.cache exit 0 else rm -f /etc/config/ip.cache if [ "$return" != "" ] then touch /tmp/dyndns.lock fi exit 1 fi else exit 0 fi