Monday, August 6, 2007

DNS-323 Time Sync with funplug-0.3 timezone.sh

I desired to configure the NTP functions of the DNS-323 so I dug right into the funplug-0.3 system again. I hade to rework the script a little bit to fix the errors, but this is what I came up with. Your time zone and server may vary. This is based on Pacific Daylight Savings Time. The next thing I will do is figure out how to add it to a cron job.



#!/bin/sh

# USA, Pacific Time. Daylight saving starts
# second Sunday of March and ends first
# Sunday of November.
timezone="PST8PDT,M3.2.0,M11.1.0"
timeserv=time-nw.nist.gov

timezone_start() {
echo "${timezone}" >/etc/TZ
/usr/sbin/sntp -r ${timeserv}
sleep 1
/usr/sbin/rtc -w
}

timezone_stop() {
echo "Stopping Timezone..."
}

timezone_status() {
cat /etc/TZ
}

case "$1" in
stop)
timezone_stop
;;
restart)
timezone_stop
sleep 1
timezone_start
;;
status)
timezone_status
;;
start)
timezone_start
;;
*)
echo "Usage: $0 start|stop|restart|status"
;;
esac


Make it executable.

chmod a+x timezone.sh



---------------------------------
www.CrazyOutdoorSports.com

No comments: