Blame | Last modification | View Log | RSS feed
#!/bin/sh## ez-ipupdate Starts and stops the ez-ipupdate daemon### chkconfig: - 55 45# processname: ez-ipupdate# description: Check and update your IP to dynamic DNS Server.### BEGIN INIT INFO# Short-Description: Check and update your IP to dynamic DNS Server# Provides: ez-ipupdate# Required-Start: $local_fs $network# Required-Stop: $local_fs# Should-Start: $time### END INIT INFOez_configdir=/etc/ez-ipupdateez_piddir=/var/run/ez-ipupdateez_bin=/usr/sbin/ez-ipupdate# Make sure relevant files exist[ -x "$ez_bin" -a -d "$ez_configdir" ] || 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 0RETVAL=0prog=ez-ipupdatestart() {# Start daemons.for ez_configfile in ${ez_configdir}/*.conf; doif [ -r ${ez_configfile} ]; then# Don't run configurations that are not daemonsif ! grep -q '^ *daemon' ${ez_configfile}; then continue; fi# Don't run configurations that run in foregroundif grep -q '^ *foreground' ${ez_configfile}; then continue; fiez_name=`basename $ez_configfile .conf`if [ -f $ez_piddir/$ez_name.pid ]; thenif status -p $ez_piddir/$ez_name.pid; thencontinuefifiecho -n $"Starting $prog for $ez_name: "daemon $ez_bin --daemon --config-file $ez_configfile --pid-file $ez_piddir/$ez_name.pid[ $? -ne 0 ] && RETVAL=1echofidone}stop() {# Stop daemons.for pidfile in ${ez_piddir}/*.pid; doif [ -r ${pidfile} ]; thenez_name=`basename $pidfile .pid`echo -n $"Shutting down $prog for $ez_name: "killproc -p $pidfile $prog -QUIT[ $? -ne 0 ] && RETVAL=1echofidone}reload() {# Reload config by sending a SIGHUP.for pidfile in ${ez_piddir}/*.pid; doif [ -r ${pidfile} ]; thenez_name=`basename $pidfile .pid`echo -n $"Reloading $prog for $ez_name: "killproc -p $pidfile $prog -HUP[ $? -ne 0 ] && RETVAL=1echofidone}restart() {stop && startRETVAL=$?}# See how we were called.case "$1" instart)start;;stop)stop;;restart)restart;;reload|force-reload)reload;;condrestart|try-restart)ls ${ez_piddir}/*.pid >/dev/null && restart;;status)status $progRETVAL=$?for ez_config in $ez_configdir/*.conf; doif [ -r $ez_config ]; thenez_cache=`grep -E '^[[:space:]]*cache-file' $ez_config | cut -d "=" -f2`ez_host=`grep -E '^[[:space:]]*host' $ez_config | cut -d "=" -f2`ez_iface=`grep -E '^[[:space:]]*interface' $ez_config | cut -d "=" -f2`[ -n "$ez_cache" ] && \echo "Last IP update of $ez_host on $ez_iface: "`cat $ez_cache | cut -d "," -f2`fidone;;*)echo "Usage: $0 {start|stop|restart|condrestart|reload|status}"exit 1esacexit $RETVAL