Hello,
I created a service defintion for BB in RedHat, and used this startup script:
#!/bin/bash
#
# bb This shell script takes care of starting and stopping
# standalone BigBrother.
#
# chkconfig: - 89 16
# description: BigBrother is a network monitoring daemon
# processname: runbb.sh
start() {
# Start daemons.
su - bb -c "/usr/local/bb/bb/runbb.sh start"
return $RETVAL
}
stop() {
# Stop daemons.
su - bb -c "/usr/local/bb/bb/runbb.sh stop"
return $RETVAL
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
restart|reload)
stop
start
RETVAL=$?
;;
status)
status $prog
RETVAL=$?
;;
*)
echo $"Usage: $prog {start|stop|restart|reload|status}"
exit 1
esac
exit $RETVAL
It works great to start the service (running as bb not root).
However, when I try to use this script to stop the service, it doesn't
shut down cleanly:
service bb stop
Stopping Big Brother...
/usr/local/bb/bb/runbb.sh: line 145: kill: (12372) - Operation not permitted
/usr/local/bb/bb/runbb.sh: line 145: kill: (12235) - No such process
/usr/local/bb/bb/runbb.sh: line 145: kill: (12372) - Operation not permitted
/usr/local/bb/bb/runbb.sh: line 145: kill: (12373) - No such process
/usr/local/bb/bb/runbb.sh: line 145: kill: (12235) - No such process
/usr/local/bb/bb/runbb.sh: line 145: kill: (12372) - No such process
Specifically, it does kill all the BB processes, but it leaves BBPID,
so that BB thinks it is still running. It also creates runbb.sh.12373
with this info:
cat runbb.sh.12373
12235 pts/1 S 0:00 /bin/sh /usr/local/bb/bb/runbb.sh start
12372 pts/1 S 0:00 su - bb -c /usr/local/bb/bb/runbb.sh stop
12373 pts/1 S 0:00 /bin/sh /usr/local/bb/bb/runbb.sh stop
12235 pts/1 S 0:00 /bin/sh /usr/local/bb/bb/runbb.sh start
12372 pts/1 S 0:00 su - bb -c /usr/local/bb/bb/runbb.sh stop
12373 pts/1 S 0:00 /bin/sh /usr/local/bb/bb/runbb.sh stop
12235 pts/1 S 0:00 /bin/sh /usr/local/bb/bb/runbb.sh start
12372 pts/1 S 0:00 su - bb -c /usr/local/bb/bb/runbb.sh stop
12373 pts/1 S 0:00 /bin/sh /usr/local/bb/bb/runbb.sh stop
So BB is really stopped, but if I try a bb start, it says that it's
already running. I have to wipe out BBPID to get it started again.
Also, if I run runbb.sh stop manually, it works fine. Its only in my
script that it fails.
Any idea where my problem might be? Thanks,
Shane