Changed init script not to use initlog.
authorBjoern Sikora <bjoern.sikora@intra2net.com>
Wed, 19 May 2010 12:26:11 +0000 (14:26 +0200)
committerBjoern Sikora <bjoern.sikora@intra2net.com>
Wed, 19 May 2010 12:26:11 +0000 (14:26 +0200)
scripts/bpdyndnsd

index 941fada..db91ee8 100755 (executable)
@@ -5,17 +5,27 @@
 # chkconfig: 35 80 20
 # description: Bullet proof dynamic DNS update daemon.
 # processname: bpdyndnsd
+# config: /etc/bpdyndnsd/bpdyndnsd.conf
 # pidfile: /var/run/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.pid
 
+test -x ${prog} || exit 0
+test -e /etc/bpdyndnsd/bpdyndnsd.conf || exit 0
 
 ##
 ## tool functions:
@@ -35,39 +45,53 @@ is_running() {
 ##
 
 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: "
+        $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
+}
 
-    return $RETVAL
+restart() {
+    stop
+    start
 }
 
+
 ##
 ## determine what we should do:
 ##
@@ -79,24 +103,21 @@ case "$1" in
         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 || : 
         ;;
     *)
         echo "Usage: bpdyndnsd {start|stop|status|restart|reload|condrestart}"
-        exit 1
+        RETVAL=1
 esac
 
 exit $RETVAL