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

View File

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