#!/bin/bash
#
# Startup script for the iplbwatch
#
# chkconfig: 2345 99 29
# description: lbmsgr
# processname: lbmsgr
pid_file=/var/run/iplbwatch.pid

case "$1" in
	start)
		echo "Starting iplbwatch:"
		/usr/lib/iplb4/iplbwatch &
		touch /var/lock/subsys/iplb4wd
		;;
	stop)
		echo "Shutting down iplbwatch:"
		`ps -efw | grep '/usr/lib/iplb4/iplbwatch' | grep -v grep |\
			 awk '{printf " %d",$2} END{printf"\n"}' > /var/run/iplbwatch.pid`
		if test -f "$pid_file"
		then
			iplbwatch_pid=`cat $pid_file`
			kill -1 $iplbwatch_pid > /dev/null 2>&1
			# iplbwatch should remove the pid_file when it exits.
		else
			echo "No iplbwatch"
		fi
		rm -f /var/run/iplbwatch.pid
		rm -f /var/lock/subsys/iplb4wd
		;;
	restart)
		$0 stop
		$0 start
		;;
	*)
		echo "Usage: $0 {start|stop|restart}"
		exit 1
esac

exit 0
