#! /bin/sh


case "$1" in

    start)
	getcfg ddns_enable
        if [ "$?" != 1 ];then
                echo "DDNS Client Service disabled"
        else
                echo "DDNS Client Service enables"
		getcfg ddns_option
		if [ "$?" != 8 ];then
	                getcfg gen_ddns_conf
			/bin/rm -f "/tmp/ez-ipupdate.cache"
        	        /sbin/ez-ipupdate -c /etc/ddns.conf
			/bin/killall -9 monddns
			/sbin/monddns&
		fi
        fi
	;;

    stop)
	killall -9 dhrpc
	;;

    restart)
    	$0 stop
	sleep 1
	$0 start
	;;

    *)
	echo "Usage: $0 (start|stop|restart)"
	exit 1
	;;

esac

exit 0

