bring epel6 init file in line with guidelines

This commit is contained in:
James Hogarth 2017-04-05 23:34:51 +01:00
parent a026e25dbb
commit 8d0e5e52d5
1 changed files with 61 additions and 77 deletions

View File

@ -22,100 +22,84 @@
# source function library # source function library
. /etc/rc.d/init.d/functions . /etc/rc.d/init.d/functions
LLDPD_OPTIONS="" exec="/usr/sbin/lldpd"
[ -e /etc/sysconfig/lldpd ] && . /etc/sysconfig/lldpd
RETVAL=0
prog="lldpd" prog="lldpd"
binary=/usr/sbin/lldpd config="/etc/lldpd.d"
pidfile=/var/run/lldpd.pid
[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog
lockfile=/var/lock/subsys/$prog 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
start() { start() {
[ -x $binary ] || exit 5 [ -x $exec ] || exit 4
echo -n $"Starting $prog: " [ -d $config ] || exit 6
if [ $UID -ne 0 ]; then echo -n $"Starting $prog: "
RETVAL=1 daemon $exec $LLDPD_OPTIONS
failure retval=$?
else echo
daemon $daemonopts $binary $LLDPD_OPTIONS [ $retval -eq 0 ] && touch $lockfile
RETVAL=$? return $retval
[ $RETVAL -eq 0 ] && touch $lockfile
fi;
echo
return $RETVAL
} }
stop() { stop() {
echo -n $"Stopping $prog: " echo -n $"Stopping $prog: "
if [ $UID -ne 0 ]; then killproc $exec
RETVAL=1 retval=$?
failure echo
else [ $retval -eq 0 ] && rm -f $lockfile
killproc $pidopts $binary return $RETVAL
RETVAL=$?
[ $RETVAL -eq 0 ] && rm -f $lockfile
fi;
echo
return $RETVAL
} }
restart(){ restart() {
stop stop
start start
} }
condrestart(){ reload() {
[ -e $lockfile ] && restart restart
return 0
} }
rh_status_q(){ force_reload() {
status $pidopts $prog >/dev/null 2>&1 restart
}
rh_status() {
# run checks to determine if the service is running or use generic status
status $prog
}
rh_status_q() {
rh_status >/dev/null 2>&1
} }
case "$1" in case "$1" in
start) start)
rh_status_q && exit 0 rh_status_q && exit 0
start $1
RETVAL=$?
;;
stop)
rh_status_q || exit 0
stop
RETVAL=$?
;;
restart)
restart
RETVAL=$?
;; ;;
reload) stop)
rh_status_q || exit 7
exit 3
;;
force-reload)
restart
RETVAL=$?
;;
condrestart|try-restart)
rh_status_q || exit 0 rh_status_q || exit 0
condrestart $1
RETVAL=$?
;;
status)
status $pidopts $prog
RETVAL=$?
;; ;;
*) restart)
echo $"Usage: $0 {start|stop|status|restart|condrestart|force-reload}" $1
RETVAL=2 ;;
reload)
rh_status_q || exit 7
$1
;;
force-reload)
force_reload
;;
status)
rh_status
;;
condrestart|try-restart)
rh_status_q || exit 0
restart
;;
*)
echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}"
exit 2
esac esac
exit $?
exit $RETVAL