[Thread Prev][Thread Next][Thread Index]

Re: CAUTION!!!! Re: SOLARIS 7 start/stop script for PilotManager v1.107



The attached script will check for a running PilotManager owned by the
invoking user.  It will eather start, stop, or force a new run of the
daemon.  It doesn't use a lock file, so it is dangerous in that it
doesn't check if a hotsync is in progress, but hopefully the user can be
carefull to look at their pilot to see if a sync is going on before
killing.  I don't know, it's something anyway.  Use it at your own risk.


-- 
  - Jonathan Loran -  
  Space Sciences Lab 
     UC Berkeley      
    (510) 643-8485    
jloran@xxxxxxxxxxxxxxxx


Alan Harder wrote:
> 
> > Is there some technical reason why the daemon cannot check for itself (lock
> > file) when running and avoid such a (forgive me) kludge?
> 
> I made a minimal effort at trying to detect if the serial port already had
> a daemon listening on it, but pilot-link didn't provide any useful error
> messages..
> A lock file could work, but then of course you have stale lock problems......
> Trevor's solution seems pretty good..
> 
>         - Alan
> ------------------------------------------------------------------------
> ***********************************************************
> *             This is a public mailing list!              *
> * Please do not publish Sun proprietary information here! *
> *        -  -  -  -  -  -  -  -  -  -  -  -  -  -         *
> *             http://www.moshpit.org/pilotmgr             *
> ***********************************************************
#!/bin/sh

# Start/stop/new PilotManager in deamon mode.  Note, if a hotsync is
# in progress, <stop or new> might cause a corrupted sync!

USAGE="Usage: `basename $0` {start|stop|new}"
getpid ()
{
	pid=`ps -ef | grep $USER | grep PilotManager | egrep -v "grep|$$" | awk '{print $2}'`
}

killwait ()
{
	echo "Killing PilotManager daemon pid: $pid"
	echo ""
	kill $pid
	while ( [ ! -z "$pid" ] ) do
		sleep 2
		getpid
	done
	echo ""
	echo "Killed"
}

getpid

case $1 in
	start) 
		if [ ! -z "$pid" ] ; then 
			echo "PilotManager daemon already running"
		else
			echo "Starting PilotManager daemon"
			PilotManager -daemon
		 fi
		;;
	stop)
		if [ ! -z "$pid" ] ; then
			killwait
		else
			echo "No running PilotManager daemon to kill"
		fi
		;;		
	new)
		if [ ! -z "$pid" ] ; then
			killwait
		fi
		echo "Starting PilotManager daemon"
		PilotManager -daemon
		;;
	*)
		echo $USAGE
		;;
esac


SourceForge.net Logo