Automatic Time Synchronisation for D-Link ShareCenter DNS-320

If the current date/time for the D-Link ShareCenter DNS-320 gets reset everytime the the NAS shuts down, a script can be used to perform date/time synchronisation on boot-up. (This requires Fonz fun_plug to be installed.)

Create the file /ffp/start/timesync.sh with the following content.

#!/ffp/bin/sh

# PROVIDE: timesync
# REQUIRE: inetd

. /ffp/etc/ffp.subr

name="timesync"
start_cmd="timesync_start"

timesync_start()
{
    date +%s -s @`wget -O - -q http://www.icanhaztimestamp.com/`;
}

run_rc_command "$1"

Explanations

The key to the script lies in the following line.

date +%s -s @`wget -O - -q http://www.icanhaztimestamp.com/`;

It can be broken down as follows.

www.icanhaztimestamp.com

This is a web service that returns the current UNIX timestamp in plain text. (I.e. the HTTP response body contains nothing but the ten-digit current UNIX timestamp.)

wget -O - -q http://www.icanhaztimestamp.com/

This wget command makes a request to the specified URL and outputs the HTTP response body (in this case, the ten-digit current UNIX timestamp).

date +%s -s @`wget -O - -q http://www.icanhaztimestamp.com/`

This date command sets the current date/time to the specified UNIX timestamp which, in this case, is the response from www.icanhaztimestamp.com.

This script would run once when the NAS boots up, and hence, the date/time would be synchronised.

Note: wget had to be used to obtain the current date/time because ntpd did not appear to be present.

Note: Though the DNS-320 administrator console allowed an NTP server to be configured, the NAS did not appear to synchronise the time with the server. (Perhaps because ntpd was not present.)

References:

[1] https://nas-tweaks.net/tutorials/
[2] http://www.icanhaztimestamp.com/

Advertisements

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s