]> git.ipfire.org Git - thirdparty/lldpd.git/commitdiff
redhat: make the init script compatible with RHEL < 5
authorVincent Bernat <bernat@luffy.cx>
Sat, 25 Feb 2012 08:06:31 +0000 (09:06 +0100)
committerVincent Bernat <bernat@luffy.cx>
Sat, 25 Feb 2012 08:06:31 +0000 (09:06 +0100)
On RHEL < 5, killproc, daemon and status does not allow to take a
pidfile as argument. We detect this and omit it to provide such an
argument if needed.

redhat/lldpd.init

index 2202e2fe370ccaa49d901829a61ed41fa3b7bf0c..e62267671c122a19ba9e29cb92daab21199be851 100644 (file)
@@ -32,6 +32,13 @@ pidfile=/var/run/lldpd.pid
 chroot=/var/run/lldpd
 lockfile=/var/lock/subsys/$prog
 
+# Determine if we can use the -p option to daemon, killproc, and status.
+# RHEL < 5 can't.
+if status | grep -q -- '-p' 2>/dev/null; then
+    daemonopts="--pidfile $pidfile"
+    pidopts="-p $pidfile"
+fi
+
 build_chroot()
 {
         oldumask=$(umask)
@@ -51,7 +58,7 @@ start() {
                 failure
         else
                build_chroot
-                daemon --pidfile=$pidfile $binary $LLDPD_OPTIONS
+                daemon $daemonopts $binary $LLDPD_OPTIONS
                 RETVAL=$?
                 [ $RETVAL -eq 0 ] && touch $lockfile
         fi;
@@ -65,7 +72,7 @@ stop() {
                 RETVAL=1
                 failure
         else
-                killproc -p $pidfile $binary
+                killproc $pidopts $binary
                 RETVAL=$?
                 [ $RETVAL -eq 0 ] && rm -f $lockfile
         fi;
@@ -84,7 +91,7 @@ condrestart(){
 }
 
 rh_status_q(){
-    status $prog >/dev/null 2>&1
+    status $pidopts $prog >/dev/null 2>&1
 }
 
 case "$1" in
@@ -116,7 +123,7 @@ case "$1" in
        RETVAL=$?
        ;;
   status)
-        status $prog
+        status $pidopts $prog
        RETVAL=$?
         ;;
   *)