Blob Blame History Raw
#!/bin/bash
#
# ddclient Client to update dynamic DNS host entries
#
# chkconfig: - 65 35
# description: ddclient is a Perl client used to update dynamic DNS \
#              entries for accounts on many dynamic DNS services.
# processname: /usr/sbin/ddclient
# config: /etc/ddclient.conf
# pidfile: /var/run/ddclient/ddclient.pid

### BEGIN INIT INFO
# Provides: ddclient
# Required-Start: $local_fs $network $syslog
# Required-Stop: $local_fs $network $syslog
# Should-Start: $named
# Should-Stop: $named
# Short-Description: Client to update dynamic DNS host entries
# Description: ddclient is a Perl client used to update dynamic DNS
#              entries for accounts on many dynamic DNS services.
### END INIT INFO

# Source function library.
. /etc/rc.d/init.d/functions

if [ -f /etc/sysconfig/ddclient ]; then
	. /etc/sysconfig/ddclient
fi

exec=/usr/sbin/ddclient
prog=`basename $exec`
lockfile=/var/lock/subsys/$prog
cache=/var/cache/ddclient/ddclient.cache
pid=/var/run/ddclient/ddclient.pid
RETVAL=0

start() {
	# Check that networking is up.
	[ ! -f /var/lock/subsys/network -a ! -f /var/lock/subsys/NetworkManager ] && exit 0

	echo -n $"Starting $prog: "
	[ -f $cache ] || touch $cache
	chown ddclient:ddclient $cache && chmod 600 $cache || exit $?
	daemon --user=ddclient --pidfile=$pid $exec $DDCLIENT_OPTIONS
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && touch $lockfile

	return $RETVAL
}

stop() {
	echo -n $"Stopping $prog: "
	killproc -p $pid $prog
	RETVAL=$?
	echo
	[ $RETVAL -eq 0 ] && rm -f $lockfile

	return $RETVAL
}

restart() {
	stop
	start
}

# See how we were called.
case "$1" in
    start)
	start
	;;
    stop)
	stop
	;;
    status)
	status -p $pid $prog
	;;
    restart|force-reload|reload)
	restart
	;;
    condrestart|try-restart)
	if [ -f $lockfile ]; then
	    restart
	fi
	;;
    *)
	echo $"Usage: $0 {start|stop|status|reload|restart|condrestart|force-reload|try-restart}"
	RETVAL=1
	;;
esac

exit $RETVAL