#! /bin/sh

case "$1" in
        start|"")
                #clear LCD onsole
		echo -e "\033\0143" > /dev/tty1
		#disable LCD console
		echo 0 > /sys/class/vtconsole/vtcon1/bind
						
		insmod /kirac/drv/ios.ko
		insmod /kirac/drv/expantion.ko
		mknod /dev/ios c 240 0
		mknod /dev/expantion c 241 0
								
		export TSLIB_CONSOLEDEVICE=none
		export TSLIB_FBDEVICE=/dev/fb0
		export TSLIB_TSDEVICE=/dev/input/event1
		export TSLIB_CONFFILE=/etc/ts.conf
		export TSLIB_PLUGINDIR=/usr/lib/ts
		export TSLIB_CALIBFILE=/etc/pointercal
		export LD_LIBRARY_PATH=/lib:/usr/lib
		export PATH=/bin:/sbin:/usr/bin/:/usr/sbin
		export QT_QPA_PLATFORM_PLUGIN_PATH=/usr/lib/qt/plugins
		export QT_QPA_PLATFORM=linuxfb:tty=/dev/fb0
		export QT_QPA_FONTDIR=/usr/lib/fonts
		export QT_QPA_GENERIC_PLUGINS=tslib:$TSLIB_TSDEVICE
		export QWS_MOUSE_PROTO=Tslib:/dev/input/event1
		export QT_DEBUG_PLUGINS=0
				
		lighttpd -f /etc/lighttpd/lighttpd.conf
		sqlite3 /kirac/db/sungateway.db  "VACUUM;"
		cd /kirac/app
		./appmond [c]heck-update /usr/bin/run-update [m]odbus-read /usr/bin/run-read [w]ebservice-send /usr/bin/run-send &
                ;;
        stop)
		pkill appmond
		pkill webservice-send
		pkill modbus-read
		pkill check-update
                ;;
esac

