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

case "$1" in
	start)
		if test -e /var/log/N????-????.log -o -e /var/log/NP????-????????.log -o -e /var/log/UL????-???.log ;
		then
		 echo -n "Starting iplbmsgr: "
		 /usr/lib/iplb4/iplbmsgr &
		 touch /var/lock/subsys/iplb4md
		 echo
		else
		 echo "Initial setup for LB is not completed!"
		fi
		;;
	stop)
		echo "Shutting down iplbmsgr: "
		`ps -ef | grep '/usr/lib/iplb4/iplbmsgr' | grep -v grep |\
			awk '{printf " %d",$2} END{printf"\n"}' > /var/run/iplbmsgr.pid`
		if test -f "$pid_file"
		then
			iplbmsgr_pid=`cat $pid_file`
			kill -1 $iplbmsgr_pid > /dev/null 2>&1
			# iplbmsgr should remove the pid_file when it exits.
		else
			echo "No iplbmsgr"
		fi
		rm -f /var/run/iplbmsgr.pid
		rm -f /var/lock/subsys/iplb4md
		;;
	restart)
		$0 stop
		$0 start
		;;
	*)
		echo "Usage: $0 {start|stop|restart}"
		exit 1
esac

exit 0
