#!/bin/sh
# Timezone Handler start-up script.

APP_NAME=timezone-handler

start_wd() {
	UCI_TIMEZONE=$(/sbin/uci get -q timezone.config.value)
	CURRENT_TIMEZONE=$(readlink /etc/localtime)
	if [ "/usr/share/zoneinfo/$UCI_TIMEZONE" != "$CURRENT_TIMEZONE" ]; then
		echo "${APP_NAME}: Changing timezone to $UCI_TIMEZONE ..."
		ln -sf /usr/share/zoneinfo/$UCI_TIMEZONE /etc/localtime
	fi
}

start() {
	# Just defer to start_wd().
	echo "${APP_NAME}: Starting the ${APP_NAME} application..."
	start_wd
	echo "${APP_NAME}: Starting the ${APP_NAME} application...DONE"
}

stop() {
	# Just defer to stop_wd().
	echo "${APP_NAME}: Stopping the ${APP_NAME} application..."
	#stop_wd
	echo "${APP_NAME}: Stopping the ${APP_NAME} application...DONE"
}

restart() {
	stop
	start
}


case "$1" in
	start)
		start
		;;
	stop)
		stop
		;;
	restart|reload)
		restart
		;;
	*)
		echo "Usage: $0 {start|stop|restart}"
		exit 1
esac

exit 0
