#! /bin/sh

if qcommand -t; then
	watchdog="no"
	device=$(grep "Hardware[[:space:]]*:" /proc/cpuinfo 2>/dev/null | \
		 head -n1 | sed "s/^[^:]*: //")
	case $device in
	    "QNAP TS-109/TS-209")
		mv /etc/qcontrol/ts209.lua /etc/qcontrol.conf ;;
	    "QNAP TS-119/TS-219")
		watchdog="yes"
		mv /etc/qcontrol/ts219.lua /etc/qcontrol.conf ;;
	    "QNAP TS-409")
		mv /etc/qcontrol/ts409.lua /etc/qcontrol.conf ;;
	    "QNAP TS-41x")
		watchdog="yes"
		mv /etc/qcontrol/ts41x.lua /etc/qcontrol.conf ;;
	esac
	rm -rf /etc/qcontrol/

	modprobe -q gpio_keys >/dev/null 2>&1
	sleep 1

	if [ X"$watchdog" = X"yes" ]; then
		qcommand watchdog off
	fi

	qcommand powerled on
	qcommand statusled green1hz
fi
