summaryrefslogblamecommitdiffstats
path: root/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_network_time
blob: 3ae84af5ec64a07327ac7fb0cbb56a44292d5a42 (plain) (tree)
1
2
3
4
5
6
7
8
9
10
          

                                                                     


                                  
                                 
                                          

                                                             
                                     
                                                                                                               
                                                          
                                     
                                                                                                         


                      
                                                       

    
                                                                                                                                  

      
#!/bin/ash

. /opt/openslx/config || { echo "Could not source config!"; exit 1; }

[ -z "$SLX_NTP_SERVER" ] && exit 0

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
			/opt/openslx/sbin/hwclock -l -w || echo "... but could not set BIOS clock to localtime"
		elif [ "x$SLX_BIOS_CLOCK" = "xutc" ]; then
			usleep 100000
			/opt/openslx/sbin/hwclock -u -w || echo "... but could not set BIOS clock to UTC"
		fi
		exit 0
	fi
	echo "Error querying $SERVER for current time."
done

[ ! -z "$SLX_NTP_SERVER" ] && slxlog "ntpdate" "No NTP server was reachable. Please check SLX_NTP_SERVER in your config file." >&2
exit 1