#!/bin/sh
# Written in sh because the user may not have Perl...to run Auto....

PID=bin/auto.pid
MODS="Mouse Class::Unload"
EMODS="MIME::Base64"

if [ "$1" = "start" ] ; then
	if [ -e $PID ]; then
		echo "Auto appears to be running already."
	else
		echo "Starting Auto. . ."
		bin/auto
		sleep 2
		if [ ! -r $PID ]; then
			echo "Possible failed startup... check Auto logs for more information"
		fi
	fi

elif [ "$1" = "stop" ]; then
	echo "Stopping Auto. . ."
	kill -TERM `cat $PID`

elif [ "$1" = "rehash" ]; then
	echo "Rehashing Auto. . ."
	kill -HUP `cat $PID`

elif [ "$1" = "status" ]; then
	if [ -e $PID ]; then
		echo "Status: Auto appears to be running."
	else
		echo "Status: Auto appears to not be running."
	fi
elif [ "$1" = "getmodules" ]; then
	cpan -i $MODS

elif [ "$1" = "getextras" ]; then
	cpan -i $EMODS

else
	echo "Usage: auto (start|stop|rehash|status|getmodules|getextras)"
fi
