summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rwxr-xr-xremote/rootfs/rootfs-stage31/data/inc/ntp_sync26
-rwxr-xr-xremote/rootfs/rootfs-stage31/data/init3
l---------remote/rootfs/rootfs-stage32/data/etc/systemd/system/network.target.wants/ntpdate.service1
-rw-r--r--remote/rootfs/rootfs-stage32/data/etc/systemd/system/ntpdate.service9
-rwxr-xr-xremote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_network_time24
5 files changed, 29 insertions, 34 deletions
diff --git a/remote/rootfs/rootfs-stage31/data/inc/ntp_sync b/remote/rootfs/rootfs-stage31/data/inc/ntp_sync
new file mode 100755
index 00000000..940af366
--- /dev/null
+++ b/remote/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
+
diff --git a/remote/rootfs/rootfs-stage31/data/init b/remote/rootfs/rootfs-stage31/data/init
index d881ad50..81b9c89b 100755
--- a/remote/rootfs/rootfs-stage31/data/init
+++ b/remote/rootfs/rootfs-stage31/data/init
@@ -80,6 +80,9 @@ bench_event "NETWORK" "Network up and running"
bench_event "CONFIG" "Downloaded config"
# From here on, we have all the vars from /opt/openslx/config
+# Sync time via NTP
+. "/inc/ntp_sync"
+
[ $DEBUG -ge 2 ] && drop_shell "Requested Debug Shell: after configuration/before stage32."
. "/inc/setup_stage32" || drop_shell "Problem setting up stage3.2"
diff --git a/remote/rootfs/rootfs-stage32/data/etc/systemd/system/network.target.wants/ntpdate.service b/remote/rootfs/rootfs-stage32/data/etc/systemd/system/network.target.wants/ntpdate.service
deleted file mode 120000
index f4b5e3f8..00000000
--- a/remote/rootfs/rootfs-stage32/data/etc/systemd/system/network.target.wants/ntpdate.service
+++ /dev/null
@@ -1 +0,0 @@
-../ntpdate.service \ No newline at end of file
diff --git a/remote/rootfs/rootfs-stage32/data/etc/systemd/system/ntpdate.service b/remote/rootfs/rootfs-stage32/data/etc/systemd/system/ntpdate.service
deleted file mode 100644
index ebaa9afb..00000000
--- a/remote/rootfs/rootfs-stage32/data/etc/systemd/system/ntpdate.service
+++ /dev/null
@@ -1,9 +0,0 @@
-[Unit]
-Description=Update date from local time server
-After=network.target
-Requires=network.target
-
-[Service]
-Type=oneshot
-RemainAfterExit=yes
-ExecStart=/opt/openslx/scripts/systemd-setup_network_time
diff --git a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_network_time b/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_network_time
deleted file mode 100755
index 3ae84af5..00000000
--- a/remote/rootfs/rootfs-stage32/data/opt/openslx/scripts/systemd-setup_network_time
+++ /dev/null
@@ -1,24 +0,0 @@
-#!/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
-