#!/bin/sh
##
# $Id: romctl,v 1.3 2003/11/12 12:26:50 magic Exp $
#
# 2001, unicorn

running=0

if [ -f /tmp/rom.pid ]; then
	pid=`cat /tmp/rom.pid`

	if [ "x$pid" != "x" ] && kill -0 $pid 2>/dev/null ; then
		running=1
	else
		echo "Removing stale pid file."
		rm -f /tmp/rom.pid
	fi
fi

cd ../areas

case $@ in
	start)
		if [ $running -eq 1 ]; then
			echo "Allready running on pid $pid"
		else
			./foot-wrapping > /dev/null 2>&1 &
		fi
	;;
	stop)
		if [ $running -eq 0 ]; then
			echo "Not running."
		else
			kill $pid
			rm -f /tmp/rom.pid
		fi
	;;
	restart)
		if [ $running -eq 1 ]; then
			kill $pid
			rm -f /tmp/rom.pid
		fi
		
		./foot-wrapping > /dev/null 2>&1 &
	;;
	*)
		echo "Usage $0 [start|stop|restart]"
	;;
esac

