#!/bin/ash

set -e

case "$1" in
'start')
	if [ -n "${SYNOPKG_PKG_STATUS}" ] || env | grep -q "^SYNOPKG_PKG_STATUS=" ; then
		# Only compute title when not booting
		${SYNOPKG_PKGDEST}/bin/FixConfig.pl ${SYNOPKG_PKGDEST}/ui/config >> $SYNOPKG_TEMP_LOGFILE 2>&1
	fi
	exec ${SYNOPKG_PKGDEST}/sbin/Daemon.pl start >> $SYNOPKG_TEMP_LOGFILE 2>&1
	;;
'stop')
	exec ${SYNOPKG_PKGDEST}/sbin/Daemon.pl stop >> $SYNOPKG_TEMP_LOGFILE 2>&1
	;;
'status')
	exec ${SYNOPKG_PKGDEST}/sbin/Daemon.pl status
	;;
'log')
	echo "${SYNOPKG_PKGDEST}/store/log"
	;;
*)
	echo "Unexpected argument '$1'" >> $SYNOPKG_TEMP_LOGFILE
	exit 1
esac

exit 0
