#!/bin/sh

export PATH=$PATH:.:/var/bin
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:.:/var/lib

cd /tmp/

start_emu() {
	mbox &
	echo mbox > /var/etc/SifTeam/tmp/cam_active.sif
	echo mbox > /var/tmp/cam_active.sif
	sleep 3
}

stop_emu() {
	kill `pidof mbox`
	sleep 2
	killall -9 mbox
	rm -rf /tmp/mbox*
	rm -rf /tmp/*.info
	rm -f /var/tmp/cam_active.sif
	sleep 2
}

case "$1" in
	start)
		start_emu
		;;
	stop)
		stop_emu
		;;
	restart)
		$0 stop
		sleep 5
		$0 start
		;;
	*)
		echo "usage: {start|stop|restart}"
		;;
esac

exit 0
