summaryrefslogblamecommitdiffstats
path: root/core/rootfs/rootfs-stage31/data/inc/ntp_sync
blob: 940af36626061cab90a742f0a8f5bab1b12fbcf8 (plain) (tree)

























                                                                                                             
# 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