#!/bin/sh
### BEGIN INIT INFO
# Provides:
# Short-Description: Starts ntpd against a custom NTP server
# Description:       The clock will synchronize against a user defined NTP server. Useful if the camera is on an isolated network.
### END INIT INFO

. /opt/wz_mini/wz_mini.conf

case "$1" in
	start)

		echo "#####$(basename "$0")#####"
		
		if [ ! -z "$NTP_SERVER" ] ; then
			# Slight delay required so that we can kill timesync from interfering
			(sleep 30 && kill -9 $(pgrep -f timesync) ; /opt/wz_mini/tmp/.bin/ntpd -p "$NTP_SERVER") &
		fi
		
		;;
	*)
		echo "Usage: $0 {start}"
		exit 1
		;;
esac

