#! /bin/bash
### BEGIN INIT INFO
# Provides: MapoIOB: script Steamware per avvio driver IOB
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: Steamware's MapoIOB driver
# Description: Steamware's MapoIOB driver, versione lettura porta parallela
### END INIT INFO

# /etc/init.d/MapoIOB

export HOME
case "$1" in
    start)
        echo "Starting readParallela"
        cd /home/pi/steamware
        /usr/bin/python ./readParallela.py 2>&1 &
    ;;
    stop)
        echo "Stopping readParallela"
        RS_PID=`ps auxwww | grep readParallela.py | head -1 | awk '{print $2}'`
        kill -9 $RS_PID
        cd /home/pi/steamware
	rm .lockfile
    ;;
    restart)
        ## Stop the service and regardless of whether it was
        ## running or not, start it again.
        $0 stop
	killall python
        $0 start
    ;;
    *)
        echo "Usage: /etc/init.d/MapoIOB {start|stop|restart}"
        exit 1
    ;;
esac
exit 0

