1#!/bin/sh 2 3WAN_IF=brwan 4CONFIG=/bin/config 5 6DDNS_STATUS=/tmp/ez-ipupd.status 7DDNS_CONF=/tmp/ez-ipupd.conf 8DDNS_CACHE=/tmp/ez-ipupd.cache 9 10print_ddns_conf() { 11 local user_agent="NETGEAR - $(cat /module_name) - $(cat /firmware_version)" 12 13cat <<EOF 14#!/usr/sbin/ez-ipupdate -c 15service-type=dyndns 16user=$1:$2 17host=$3 18interface=$4 19max-interval=86400 20resolv-period=30 21period=10 22retrys=7 23pid-file=/tmp/ddnspid 24user-agent=$user_agent 25daemon 26execute=/etc/ez-ipupdate.script 27EOF 28} 29 30get_wan_ifname() { 31 local proto=$($CONFIG get wan_proto) 32 33 if [ "$proto" = "pppoe" -o "$proto" = "pptp" -o "$proto" = "mulpppoe1" ]; then 34 echo -n "ppp0" 35 else 36 echo -n $WAN_IF 37 fi 38} 39 40ddns_start() { 41 local start_flag wl_radio wds_repeater_basic wds_endis_fun 42 43 echo -n "0" > $DDNS_STATUS 44 45 wl_radio=$($CONFIG get endis_wl_radio) 46 wds_repeater_basic=$($CONFIG get wds_repeater_basic) 47 wds_endis_fun=$($CONFIG get wds_endis_fun) 48 49 if [ "$wl_radio" = "1" -a "$wds_repeater_basic" = "0" -a "$wds_endis_fun" = "1" ]; then 50 exit 51 fi 52 53 [ "$($CONFIG get endis_ddns)" != "1" ] && exit 54 55 local ipaddr=$($CONFIG get update_ddns_ipaddr) 56 local time=$($CONFIG get update_ddns_time) 57 local format_time=$($CONFIG get update_ddns_format_time) 58 echo $time,$ipaddr>$DDNS_CACHE 59 # Produce /tmp/ez-ipupd.time when reboot. then when we check status on GUI,it will display. 60 if [ $time -gt 0 -a ! -f /tmp/ez-ipupd.time ] ;then 61 echo $format_time>/tmp/ez-ipupd.time 62 fi 63 if [ -f /tmp/ez-ipupd.time ] ;then 64 echo "1">/tmp/ez-ipupd.status 65 fi 66 67 print_ddns_conf "$($CONFIG get sysDNSUser)" "$($CONFIG get sysDNSPassword)" "$($CONFIG get sysDNSHost)" "$(get_wan_ifname)" > $DDNS_CONF 68 69 if [ "$($CONFIG get endis_wildcards)" = "1" ]; then 70 /usr/sbin/ez-ipupdate -w wildcard -c $DDNS_CONF -b $DDNS_CACHE 71 else 72 /usr/sbin/ez-ipupdate -c $DDNS_CONF -b $DDNS_CACHE 73 fi 74} 75 76ddns_stop() { 77 if [ -f /tmp/ddnspid ]; then 78 kill -9 $(cat /tmp/ddnspid) 79 rm -f /tmp/ddnspid 80 sleep 2 81 fi 82} 83 84ddns_restart() { 85 ddns_stop 86 ddns_start 87} 88 89export TZ=$($CONFIG get time_zone) 90case "$1" in 91 stop) 92 ddns_stop 93 ;; 94 start) 95 ddns_start 96 ;; 97 restart) 98 ddns_restart 99 ;; 100esac 101