#!/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 opendns config_get enable opendns enable config_get user opendns user config_get pass opendns pass config_get label opendns label if enabled $enable && [ ! -f /tmp/opendns.lock ] then if [ ! -f /tmp/ip_opendns.cache ] then echo '0.0.0.0'>/tmp/ip_opendns.cache fi # checking for online connection ip_now=`wget -O - http://myip.dnsomatic.com 2> /dev/null` if [ "$ip_now" = "" ] then exit 1 fi date=`date +"%s"` date_last=`date -r /tmp/ip_opendns.cache +"%s"` if [ `expr $date - $date_last` -lt 2505600 ] then ip_old=$(cat /tmp/ip_opendns.cache) if [ "$ip_old" = "$ip_now" ] then exit 0 # IP not changed and 29 days havn't passed fi fi return="$(wget -q --no-check-certificate -O - https://$user:$pass@updates.opendns.com/nic/update\?hostname=$label 2>/dev/null | awk '{print $1}')" if [ "$return" = "good" ] || [ "$return" = "nochg" ] then echo "$ip_now">/tmp/ip_opendns.cache exit 0 else rm -f /tmp/ip_opendns.cache if [ "$return" != "" ] then touch /tmp/opendns.lock fi exit 1 fi else exit 0 fi