From: Vincent Bernat Date: Sat, 25 Feb 2012 08:06:31 +0000 (+0100) Subject: redhat: make the init script compatible with RHEL < 5 X-Git-Tag: 0.6.0~46 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=61723351277822b56b6671dd5ac610fb85eb831b;p=thirdparty%2Flldpd.git redhat: make the init script compatible with RHEL < 5 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. --- diff --git a/redhat/lldpd.init b/redhat/lldpd.init index 2202e2fe..e6226767 100644 --- a/redhat/lldpd.init +++ b/redhat/lldpd.init @@ -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=$? ;; *)