#!/bin/sh
export QWS_KEYBOARD="tty:keymap=/home/apollo.qmap"

if [ ! -x /home/mainApp ]
then
    echo "Your application isn't executable, muppet!"
    exit 0
fi

if [ "$1" = "stop" -o "$1" = "restart" ]
then                                                                            
    echo "Stopping the Qt application: "
    killall mainApp
    echo "Stopping the Qt application watchdog: "
    killall AppWatch
fi

if [ "$1" = "start" -o "$1" = "restart" ]
then
    echo $1
    echo $2 
    if [ ${2} = 1 ]
    then
    	echo "Starting the Measurement Cal: "	
    	/home/mainApp -qws -display transformed:Rot180 -nomouse --measurement-cal &
    else
    	echo "Starting SplashLoad"
    	/home/SplashLoad &
    	echo "Starting the Qt application: "
    	/home/mainApp -qws -display transformed:Rot180 -nomouse &
    fi
    echo "Starting the Qt application watchdog: "
    ./home/AppWatch mainApp &
fi
