summaryrefslogtreecommitdiffstats
path: root/core/rootfs/rootfs-stage31/data/inc/ntp_sync
blob: 940af36626061cab90a742f0a8f5bab1b12fbcf8 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
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