#!/bin/sh # # Start the rwhod at system startup time on MacOSX # # Eric Myers - 23 July 2003 # @(#) $Id:$ ###################################################################### . /etc/rc.common # Add 'status' option RunService () { case $1 in start ) StartService ;; stop ) StopService ;; restart) RestartService ;; status ) StatusReport ;; * ) echo "$0: unknown argument: $1";; esac } StatusReport () { PID=`ps ax | grep -v grep | awk '$5 ~ /\/rwhod$/ {print $1}'` if [ "$PID" != "" ]; then echo "rwhod (pid $PID) is running... " exit 0 else if [ -f /var/run/rwhod.pid ]; then echo "rwhod is stopped but pid file exists." exit 1 else echo "rwhod is stopped " exit 2 fi fi } StartService () { CheckForNetwork if [ "${NETWORKUP}" = "-NO-" ]; then exit; fi if [ ! -x /usr/sbin/rwhod ]; then exit; fi ConsoleMessage "Starting rwho daemon" /usr/sbin/rwhod # Create pid file PID=`ps ax | grep -v grep | awk '$5 ~ /rwhod/ {print $1} '` echo $PID > /var/run/rwhod.pid } StopService () { PID=`ps ax | grep -v grep | awk '$5 ~ /\/rwhod$/ {print $1}'` if [ "$PID" != "" ]; then ConsoleMessage "Stopping rwho daemon" kill -TERM "${PID}" rm -f /var/run/rwhod.pid else echo "rwhod is not running." fi } RestartService () { StopService StartService } RunService "$1" ##