#!/bin/sh
. "$(dirname "$0")/common"

case "$1" in
	start)
		if [ ! -s "$upstart_job" ] || [ ! -s "$SERVICE" ]; then
			DO_LINK
		fi
		if [ ! -L /usr/syno/etc/www/WebStation.json ]; then
			rm -f /usr/syno/etc/www/WebStation.json
			ln -sf /usr/syno/etc/packages/WebStation/WebStation.json /usr/syno/etc/www/WebStation.json
		fi
		/usr/syno/bin/synow3 gen
		synoservice --start webstation
		;;
	stop)
		synoservice --stop webstation
		rm -f /usr/syno/etc/www/WebStation.json
		;;
	status)
		synoservice --status webstation
		ret=$?
		if [ 0 -eq $ret ] && [ -L /usr/syno/etc/www/WebStation.json ] || [ 3 -eq $ret ]; then
			exit 0;
		fi
		exit 150;
		;;
esac
