diff options
Diffstat (limited to 'core/rootfs/rootfs-stage31/data/inc/ntp_sync')
-rwxr-xr-x | core/rootfs/rootfs-stage31/data/inc/ntp_sync | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/core/rootfs/rootfs-stage31/data/inc/ntp_sync b/core/rootfs/rootfs-stage31/data/inc/ntp_sync new file mode 100755 index 00000000..940af366 --- /dev/null +++ b/core/rootfs/rootfs-stage31/data/inc/ntp_sync @@ -0,0 +1,26 @@ +# Sync time via network + +func_sync_net_time() { + local SERVER + if [ -n "$SLX_NTP_SERVER" ]; then + for SERVER in $SLX_NTP_SERVER; do + if ntpdate -u -p 2 "$SERVER"; then + echo "Successfully queried $SERVER for time." + if [ "x$SLX_BIOS_CLOCK" = "xlocal" ]; then + usleep 100000 + hwclock -l -w || echo "... but could not set BIOS clock to localtime" + elif [ "x$SLX_BIOS_CLOCK" = "xutc" ]; then + usleep 100000 + hwclock -u -w || echo "... but could not set BIOS clock to UTC" + fi + break + fi + echo "Error querying $SERVER for current time." + done + fi +} + +func_sync_net_time & + +true + |