Permalink
Browse files

modified the 'rcbooth-arbitrator status' that it should only show

'Running' if a boothd is running in arbitrator mode.

Signed-off-by: Xia Li <xli@suse.com>
  • Loading branch information...
xiali committed Jan 10, 2013
1 parent bb8a987 commit 55ab027233407fd44850f0c4905b085205d55f64
Showing with 50 additions and 18 deletions.
  1. +50 −18 script/lsb/booth-arbitrator
@@ -21,39 +21,71 @@
prog="boothd"
exec="/usr/sbin/$prog"
-type="arbitrator"
+type="arbitrator"
lockfile="/var/run/booth.pid"
. /etc/rc.status
internal_status() {
- checkproc $exec > /dev/null 2>&1
- return $?
+ checkproc $exec > /dev/null 2>&1
+ return $?
+}
+
+check_status() {
+ internal_status
+ if [ "$?" -eq 0 ];then
+ pidnum=$(cat $lockfile)
+ if cat /proc/$pidnum/cmdline |grep $type > /dev/null 2>&1 ; then
+ return 0 #arbitrator daemon is Running
+ else
+ return 1 #site daemon is Running
+ fi
+ else
+ return 2 #BOOTH daemon is not running
+ fi
}
status() {
- if internal_status; then
+ echo -n "BOOTH arbitrator daemon is "
+ if check_status; then
echo "Running"
return 0
- else
+ else
echo "Stopped"
return 7
fi
}
start() {
[ -x $exec ] || exit 5
- echo -n $"Starting BOOTH arbitrator daemon: "
- if ! internal_status; then
+ check_status
+ rc=$?
+ case "$rc" in
+ 0)
+ echo "BOOTH arbitrator daemon is Running"
+ return 1
+ ;;
+ 1)
+ echo "BOOTH site daemon is Running"
+ return 1
+ ;;
+ 2)
+ echo -n $"Starting BOOTH arbitrator daemon: "
startproc $exec $type
- fi
- rc_status -v
+ rc_status -v
+ ;;
+ esac
}
stop() {
- echo -n $"Stopping BOOTH arbitrator daemon: "
- killproc -p $lockfile $prog -TERM
- rc_status -v
+ if check_status; then
+ echo -n $"Stopping BOOTH arbitrator daemon: "
+ killproc -p $lockfile $prog -TERM
+ rc_status -v
+ else
+ echo "BOOTH arbitrator daemon is not running."
+ return 1
+ fi
}
wait_for_stop() {
@@ -69,19 +101,19 @@ restart() {
}
case "$1" in
- start|stop|restart)
+ start|stop|restart)
$1
;;
- reload|force-reload)
+ reload|force-reload)
restart
;;
- condrestart|try-restart)
- [ ! -f "$lockfile" ] || restart
+ condrestart|try-restart)
+ [ ! -f "$lockfile" ] || restart
;;
- status)
+ status)
status $prog
;;
- *)
+ *)
echo $"Usage: $0 {start|stop|restart|try-restart|condrestart|reload|force-reload|status}"
exit 2
esac

0 comments on commit 55ab027

Please sign in to comment.