Init script taken from trusted_net_helper and adjusted to bpdyndnsd needs.
[bpdyndnsd] / scripts / bpdyndnsd
diff --git a/scripts/bpdyndnsd b/scripts/bpdyndnsd
new file mode 100755 (executable)
index 0000000..77bf508
--- /dev/null
@@ -0,0 +1,101 @@
+#! /bin/sh
+#
+# bpdyndnsd
+#
+# chkconfig: - 93 04
+# description: Bullet proof dynamic DNS update daemon.
+# processname: bpdyndnsd
+
+# Source function library.
+. /etc/rc.d/init.d/functions
+
+# define the paths to the binaries:
+path_prg=/usr/intranator/bin/bpdyndnsd
+
+# other paths:
+path_pidfile=/var/run/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
+
+
+##
+## the functions:
+##
+
+start() {
+   echo -n "Starting bpdyndnsd: "
+
+   ${path_prg} --daemon_mode 1
+   RETVAL=$?
+   echo
+
+   if [ $RETVAL -eq 0 ] ; then
+      touch /var/lock/subsys/bpdyndnsd
+   fi
+   return $RETVAL
+}
+
+stop() {
+    echo -n "Stopping bpdyndnsd: "
+
+    killproc bpdyndnsd
+    RETVAL=$?
+    echo
+
+    rm -f /var/lock/subsys/bpdyndnsd
+    return $RETVAL
+}
+
+reload() {
+    echo -n "Reloading bpdyndnsd: "
+
+    killproc bpdyndnsd -HUP
+    RETVAL=$?
+    echo
+
+    return $RETVAL
+}
+
+##
+## determine what we should do:
+##
+case "$1" in
+    start)
+        start
+        ;;
+    stop)
+        stop
+        ;;
+    status)
+        status bpdyndnsd
+        ;;
+    restart)
+        stop
+        start
+        ;;
+    reload)
+        reload
+        ;;
+    condrestart)
+        if [ -f /var/lock/subsys/bpdyndnsd ]; then
+            stop
+            start
+        fi
+        ;;
+    *)
+        echo "Usage: bpdyndnsd {start|stop|status|restart|reload|condrestart}"
+        exit 1
+esac
+
+exit $RETVAL