#!/bin/sh

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

cd /tmp/

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

stop_emu() {
kill `pidof mbox`
kill `pidof newcs-1.62`
sleep 2
killall -9 mbox
killall -9 newcs-1.62
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