diff --git a/numad.init b/numad.init index 526382b..08b3627 100755 --- a/numad.init +++ b/numad.init @@ -1,97 +1,104 @@ #!/bin/bash # chkconfig: - 99 1 -# description: Control operation of nunmad which will monitior and -# rebalance assignement of NUMA resources. +# description: Control operation of numad which will monitor and +# rebalance assignment of NUMA resources -## -## BEGIN INIT INFO +### BEGIN INIT INFO # Provides: numad -# Default-Start: -# Default-Stop: -# Required-Start: -# -# Short-Description: numad control -## END INIT INFO -# numad: Set up numad -# config: /etc/numad.conf -# -# - +# Required-Start: cgconfig +# Required-Stop: +# Should-Start: +# Should-Stop: +# Default-Start: +# Default-Stop: +# Short-Description: numad control +# Description: +### END INIT INFO # Source function library. -. /etc/init.d/functions +. /etc/rc.d/init.d/functions -#source the config file, if it's there -if [ -f /etc/numad.conf ]; then - . /etc/numad.conf -fi +exec="/usr/bin/numad" +prog="numad" +config="/etc/numad.conf" -LOCKFILE=/var/lock/subsys/numad +[ -e /etc/sysconfig/$prog ] && . /etc/sysconfig/$prog +lockfile=/var/lock/subsys/$prog base=${0##*/} start() { - echo -n "Starting numad" - - [ -f "$LOCKFILE" ] && return 0 - touch $LOCKFILE - /usr/bin/numad -i $INTERVAL|| return $? - return 0 + [ -x $exec ] || exit 5 + [ -f $config ] || exit 6 + echo -n $"Starting $prog: " + . $config + daemon "$exec -i $config" + retval=$? + echo + [ $retval -eq 0 ] && touch $lockfile + return $retval } stop() { - echo -n "Stopping numad" - /usr/bin/numad -i 0 - [ -f "$LOCKFILE" ] || return 1 - rm $LOCKFILE -} - -status() { - if [ -f "$LOCKFILE" ]; then - echo "$base is running" - else - echo "$base is stopped" - fi - exit 0 + echo -n $"Stopping $prog: " + killproc $prog + retval=$? + echo + [ $retval -eq 0 ] && rm -f $lockfile + return $retval } restart() { - stop && start + stop + start } -condrestart(){ - [ -e "$LOCKFILE" ] && restart +reload() { + restart } +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 - restart) - restart && success || failure - ;; - start) - start && success || failure - echo - ;; - - stop) - stop && success || failure - ;; - - status) - status - ;; - - reload) - stop - start - ;; - - condrestart|try-restart) - condrestart && success || : + rh_status_q && exit 0 + $1 + ;; + stop) + rh_status_q || exit 0 + $1 + ;; + 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|reload|condrestart|try-restart}" - exit 3 - ;; + echo $"Usage: $0 {start|stop|status|restart|condrestart|try-restart|reload|force-reload}" + exit 2 esac +exit $?