#! /bin/sh
# init.d script to start x-core daemon
#

FTM_STATUS=`/usr/bin/infotools -i | grep -aw FTM | cut -d: -f2 | tr -d ' ' | tr -d '\n'`
SKU=`cat /build.prop | grep ro.build.sku | awk -F '=' '{print$2}'`

echo "FTM_STATUS:[${FTM_STATUS}]"
echo "SKU:[${SKU}]"
case "${FTM_STATUS}" in 
	1)
		if [ "$SKU" == "RTL6310VW_D346" ]; then
			case "$1" in
				start)
					echo -n "Starting xap-core: "
					start-stop-daemon -S -b -a /usr/bin/health_monitor
					echo "done"
					;;
				stop)
					echo -n "Stopping xap-core: "
					start-stop-daemon -K -n health_monitor
					echo "done"
					;;
				restart)
					$0 stop
					$0 start
					;;
				*)
				echo "Usage xap core { start | stop | restart}" >&2
				exit 1
				;;
			esac
		fi
		;;
	*)
		## launch xap-core
		case "$1" in
			start)
				echo -n "Starting xap-core: "
				start-stop-daemon -S -b -a /usr/bin/health_monitor
				echo "done"
				;;
			stop)
				echo -n "Stopping xap-core: "
				start-stop-daemon -K -n health_monitor
				echo "done"
				;;
			restart)
				$0 stop
				$0 start
				;;
			*)
				echo "Usage xap core { start | stop | restart}" >&2
				exit 1
				;;
		esac
		;;
esac

exit 0
