#!/bin/sh if ! PREFIX=$(expr $0 : "\(/.*\)/etc/rc\.d/$(basename $0)\$"); then echo "$0: Cannot determine the PREFIX" >&2 exit 1 fi # If there is a global system configuration file, suck it in. if [ -r /etc/defaults/rc.conf ]; then . /etc/defaults/rc.conf source_rc_confs elif [ -r /etc/rc.conf ]; then . /etc/rc.conf fi gnump3d_enable=${gnump3d_enable:-YES} gnump3d_program=${gnump3d_program:-${PREFIX}/bin/gnump3d} gnump3d_flags=${gnump3d_flags:-"--quiet --background"} gnump3d_pidfile=${gnump3d_pidfile:-/var/run/gnump3d/gnump3d.pid} case $1 in start) case "${gnump3d_enable}" in [Yy][Ee][Ss]) if [ -f ${gnump3d_program} ]; then echo -n " gnump3d" ${gnump3d_program} ${gnump3d_flags} || return=" Failed." echo `ps auwx | grep -E 'perl.*gnump3d' | grep -v grep | awk '{print $2}'` > $gnump3d_pidfile fi ;; esac ;; forcestart) if [ -f ${gnump3d_program} ]; then echo -n " gnump3d" ${gnump3d_program} ${gnump3d_flags} || return=" Failed." echo `ps auwx | grep -E 'perl.*gnump3d' | grep -v grep | awk '{print $2}'` > $gnump3d_pidfile fi ;; stop) if [ -f ${gnump3d_pidfile} ]; then PID=`cat ${gnump3d_pidfile}` kill -KILL $PID || return=" Failed." rm -f ${gnump3d_pidfile} # some slaves won't die killall gnump3d > /dev/null 2>&1 echo " gnump3d killed" else return=" Failed." fi ;; forcestop) if [ -f ${gnump3d_pidfile} ]; then PID=`cat ${gnump3d_pidfile}` kill -KILL $PID || return=" Failed." rm -f ${gnump3d_pidfile} # some slaves won't die killall gnump3d > /dev/null 2>&1 echo " gnump3d killed" else return=" Failed." fi ;; restart) $0 stop $0 start; ;; *) echo "usage: $0 {start|stop|restart}" 1>&2 ;; esac exit 0;