#!/bin/sh

cd /usr/local/controller/scripts

case "$1" in
	start)
		if [ "$(ps x | grep -v grep | grep -c mysqlconn.pl)" != "0" ]; then
		./pmanager.sh stop
		fi
#		./alarm > /dev/null 2>&1 &
		./mysqlconn.pl > /dev/null 2>&1 &
#		echo -n " pmanager"
		;;
	stop)
#		kill `cat pidfile 2>/dev/null` > /dev/null 2>&1
		kill `ps x -o pid,command | grep mysqlconn | grep -v grep | awk '{print $1}'` \
		    > /dev/null 2>&1 
#		rm -f pidfile
		./polstop.sh > /dev/null 2>&1
		killall alarm > /dev/null 2>&1
		killall cleaner > /dev/null 2>&1
		killall vmstat > /dev/null 2>&1
		killall traffic-server > /dev/null 2>&1
		killall navigator-sync > /dev/null 2>&1
#		echo -n " pmanager"
		;;
	*)
		echo ""
		echo "Usage: `basename $0` { start | stop }"
		echo ""
		;;
esac

exit 0
