#!/bin/sh

##
# Thinking Home
##

. /etc/rc.common

StartService ()
{
    PIDS=`ps ax | grep ThinkingAgent | grep -v grep | awk '{print $1}'`

	if [ "${#PIDS}" = 0 ]; then
		ConsoleMessage "Starting Thinking Home"
		sudo -u __thinkingUser __pathToThinkingAgent __thinkingUser &
#		cd '__ path To Thinking Agent'
#		./ThinkingAgent &
	fi
}


StopService ()
{
	ConsoleMessage "Stopping Thinking Home"

	set PIDS = `ps ax | grep ThinkingAgent | grep -v grep | awk '{print $1}'`

	for pid in $PIDS; do
		kill -KILL $pid
	done
}


RestartService ()
{
    StopService
    sleep 3
    StartService
}

RunService "$1"
