Fix 'occurred' typo
[bpdyndnsd] / scripts / bpdyndnsd
index c1d6712..274f6e9 100755 (executable)
@@ -2,11 +2,11 @@
 #
 # bpdyndnsd
 #
-# chkconfig: 35 80 20
+# chkconfig: 35 90 20
 # description: Bullet proof dynamic DNS update daemon.
 # processname: bpdyndnsd
 # config: /etc/bpdyndnsd/bpdyndnsd.conf
-# pidfile: /var/run/bpdyndnsd.pid
+# pidfile: /var/run/bpdyndnsd/bpdyndnsd.pid
 
 # Source function library.
 . /etc/rc.d/init.d/functions
@@ -22,7 +22,7 @@ group=bpdyndnsd
 # Binary file
 prog=/usr/bin/bpdyndnsd
 # PID file
-pidfile=/var/run/bpdyndnsd.pid
+pidfile=/var/run/bpdyndnsd/bpdyndnsd.pid
 
 test -x ${prog} || exit 0
 test -e /etc/bpdyndnsd/bpdyndnsd.conf || exit 0
@@ -45,7 +45,7 @@ start() {
         fi
 
         echo -n "Starting $progname: "
-        $prog --daemon_mode 1 --syslog 1;
+        daemon --user bpdyndnsd $prog --daemon_mode 1 --syslog 1;
         RETVAL=$?
         [ $RETVAL -eq 0 ] && success || failure
         echo
@@ -79,6 +79,29 @@ restart() {
     start
 }
 
+online() {
+    echo -n "Switching $progname to online mode: "
+    killproc bpdyndnsd -USR2
+    RETVAL=$?
+    [ $RETVAL -eq 0 ] && success || failure
+    echo
+}
+
+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
+}
 
 ##
 ## determine what we should do:
@@ -103,8 +126,17 @@ case "$1" in
     condrestart)
         [ -f /var/lock/subsys/bpdyndnsd ] && restart || : 
         ;;
+    online)
+        online
+        ;;
+    online_webcheck)
+        online_webcheck
+        ;;
+    offline)
+        offline
+        ;;
     *)
-        echo "Usage: bpdyndnsd {start|stop|status|restart|reload|condrestart}"
+        echo "Usage: bpdyndnsd {start|stop|status|restart|reload|condrestart|online|online_webcheck|offline}"
         RETVAL=1
 esac