#
# bpdyndnsd
#
-# chkconfig: 35 80 20
+# chkconfig: 35 90 20
# description: Bullet proof dynamic DNS update daemon.
# processname: bpdyndnsd
-# pidfile: /var/run/bpdyndnsd.pid
+# config: /etc/bpdyndnsd/bpdyndnsd.conf
+# pidfile: /var/run/bpdyndnsd/bpdyndnsd.pid
# Source function library.
. /etc/rc.d/init.d/functions
-# define the paths to the binaries:
-path_prg=/usr/bin/bpdyndnsd
+# Configuration
+. /etc/sysconfig/bpdyndnsd
-# other paths:
-path_pidfile=/var/run/bpdyndnsd.pid
+# Prog name
+progname="bpdyndnsd (dynamic DNS update daemon)"
+# User and group
+user=bpdyndnsd
+group=bpdyndnsd
+# Binary file
+prog=/usr/bin/bpdyndnsd
+# PID file
+pidfile=/var/run/bpdyndnsd/bpdyndnsd.pid
-
-##
-## tool functions:
-##
-
-is_running() {
- [ -f ${path_pidfile} ] || return 1
- pid_from_file=`head -n1 ${path_pidfile}`
- [ -L /proc/${pid_from_file}/exe ] || return 1
- [ "`readlink /proc/${pid_from_file}/exe`" = "${path_prg}" ]
-}
-# eo is_running
+test -x ${prog} || exit 0
+test -e /etc/bpdyndnsd/bpdyndnsd.conf || exit 0
##
##
start() {
- echo -n "Starting bpdyndnsd: "
-
- initlog -c "${path_prg} --daemon_mode 1 --syslog 1" && success || failure
- RETVAL=$?
- echo
+ [ -f /var/lock/subsys/bpdyndnsd ] && stop
+
+ if [ $START_BPDYNDNSD -eq 1 ]; then
+ # Check if this is really bpdyndnsd's pid file
+ if [ -f $pidfile ]; then
+ if ! grep -s -q "bpdyndnsd" /proc/`cat $pidfile`/cmdline; then
+ echo "Unlinking non-bpdyndnsd pid file"
+ rm -f $pidfile
+ fi
+ fi
- if [ $RETVAL -eq 0 ] ; then
- touch /var/lock/subsys/bpdyndnsd
- fi
- return $RETVAL
+ echo -n "Starting $progname: "
+ daemon --user bpdyndnsd $prog --daemon_mode 1 --syslog 1;
+ RETVAL=$?
+ [ $RETVAL -eq 0 ] && success || failure
+ echo
+ [ $RETVAL -eq 0 ] && touch /var/lock/subsys/bpdyndnsd
+ fi
}
stop() {
- echo -n "Stopping bpdyndnsd: "
+ if [ ! -f /var/lock/subsys/bpdyndnsd ]; then
+ return 0
+ fi
+ echo -n "Stopping $progname: "
killproc bpdyndnsd
RETVAL=$?
+ [ $RETVAL -eq 0 ] && success || failure
echo
-
- rm -f /var/lock/subsys/bpdyndnsd
- return $RETVAL
+ [ $RETVAL -eq 0 ] && rm -f /var/lock/subsys/bpdyndnsd
}
reload() {
- echo -n "Reloading bpdyndnsd: "
-
+ echo -n "Reloading $progname: "
killproc bpdyndnsd -HUP
RETVAL=$?
+ [ $RETVAL -eq 0 ] && success || failure
+ echo
+}
+
+restart() {
+ stop
+ start
+}
+
+online() {
+ echo -n "Switching $progname to online mode: "
+ killproc bpdyndnsd -USR2
+ RETVAL=$?
+ [ $RETVAL -eq 0 ] && success || failure
echo
+}
- return $RETVAL
+online_webcheck() {
+ echo -n "Switching $progname to online mode with webcheck enabled: "
+ killproc bpdyndnsd -RTMIN
+ RETVAL=$?
+ [ $RETVAL -eq 0 ] && success || failure
+ echo
+}
+
+offline() {
+ echo -n "Switching $progname to offline mode: "
+ killproc bpdyndnsd -USR1
+ RETVAL=$?
+ [ $RETVAL -eq 0 ] && success || failure
+ echo
}
##
stop
;;
status)
- status bpdyndnsd
+ status $prog
+ RETVAL=$?
;;
restart)
- stop
- start
+ restart
;;
reload)
reload
;;
condrestart)
- if [ -f /var/lock/subsys/bpdyndnsd ]; then
- stop
- start
- fi
+ [ -f /var/lock/subsys/bpdyndnsd ] && restart || :
+ ;;
+ online)
+ online
+ ;;
+ online_webcheck)
+ online_webcheck
+ ;;
+ offline)
+ offline
;;
*)
- echo "Usage: bpdyndnsd {start|stop|status|restart|reload|condrestart}"
- exit 1
+ echo "Usage: bpdyndnsd {start|stop|status|restart|reload|condrestart|online|online_webcheck|offline}"
+ RETVAL=1
esac
exit $RETVAL