#!/bin/bash # # Linux-phased Richard Schneidt # # Startup script for ez-ipudate # # chkconfig: 345 55 45 # # processname: ez-ipupdate # description: Update your IP to a dynamic IP service # pidfile: /var/run/ez-ipudpate.pid # config: /etc/ez-ipupdate.conf # Make sure relevant files exist [ -f /usr/bin/ez-ipupdate ] || exit 0 [ -f /etc/ez-ipupdate.conf ] || exit 0 # Source function library. . /etc/rc.d/init.d/functions # Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ ${NETWORKING} = "no" ] && exit 0 # get external IP - set your router password below ROUTERPW=banana IPADDR=`lynx -auth "a:$ROUTERPW" -dump http://192.168.1.1/Status.htm | perl -ne 'm/IP Address: ([\d.]+)/ && print $1'` ez_config=/etc/ez-ipupdate.conf ez_bin=/usr/bin/ez-ipupdate ez_cache=`grep -E '^[[:space:]]*cache-file' $ez_config | cut -d "=" -f2 ` prog="ez-ipupdate" RETVAL=0 start() { # Start daemons. if [ -n "`/sbin/pidof ez-ipupdate`" ]; then echo -n $"$prog: already running" return 1 fi echo -n $"Starting $prog: " $ez_bin -a $IPADDR -c $ez_config >/dev/null 2>/dev/null success $"$prog startup" return 1 } stop() { # Stop daemons. echo -n $"Shutting down $prog: " success $"$prog shutdown" return 1 } # See how we were called. case "$1" in start) start ;; stop) stop ;; restart|reload) stop start RETVAL=$? ;; condrestart) if [ -f /var/lock/subsys/ez-ipupdate ]; then stop start RETVAL=$? fi ;; status) status ez-ipupdate RETVAL=$? LAST_IP=`cat $ez_cache | cut -d "," -f2` echo "last IP update : $LAST_IP" ;; *) echo $"Usage: ez-ipupdate {start|stop|restart|reload|condrestart|status}" RETVAL=1 esac exit $RETVAL