#!/bin/bash # goferd This shell script controls the gofer daemon. # Author: Jeff Ortel <jortel@redhat.com> # chkconfig: 345 97 2 # description: Gofer agent responds to commands from gofer server. # processname: python # export SYSTEMCTL_SKIP_REDIRECT=1 export SYSTEMCTL_IGNORE_DEPENDENCIES=1 . /etc/init.d/functions BINDIR=/usr/bin PROG=goferd LOCK=/var/lock/subsys/$PROG PID=/var/run/$PROG.pid start() { if [ -e $PID ]; then pid=$(cat $PID) fi kill -0 $pid >/dev/null 2>&1 RETVAL=$? if [ $RETVAL -eq "0" ]; then echo "$PROG ($pid) already running." return $RETVAL fi echo -n "Starting $PROG" $BINDIR/$PROG RETVAL=$? if [ $RETVAL -eq "0" ]; then touch $LOCK success else failure fi echo return $RETVAL } stop() { echo -n "Stopping $PROG" if [ -e $PID ]; then pid=$(cat $PID) fi kill -9 $pid >/dev/null 2>&1 RETVAL=$? if [ $RETVAL -eq "0" ]; then rm -f $LOCK success else failure fi echo return $RETVAL } status() { if [ -e $PID ]; then pid=$(cat $PID) fi kill -0 $pid >/dev/null 2>&1 RETVAL=$? if [ $RETVAL -eq "0" ]; then echo "$PROG ($pid) is running." else echo "$PROG is not running." fi } restart() { stop sleep 2 start } case "$1" in start) start ;; stop) stop ;; restart) restart ;; status) status ;; *) echo $"Usage: $0 {start|stop|status|restart|}" exit 1 esac exit $RETVAL