summaryrefslogtreecommitdiffstats
path: root/satellit_installer/static_files/timesync/usr/local/sbin/redneck-timesync.sh
diff options
context:
space:
mode:
Diffstat (limited to 'satellit_installer/static_files/timesync/usr/local/sbin/redneck-timesync.sh')
-rwxr-xr-xsatellit_installer/static_files/timesync/usr/local/sbin/redneck-timesync.sh24
1 files changed, 21 insertions, 3 deletions
diff --git a/satellit_installer/static_files/timesync/usr/local/sbin/redneck-timesync.sh b/satellit_installer/static_files/timesync/usr/local/sbin/redneck-timesync.sh
index 2fbed8a..7dc538c 100755
--- a/satellit_installer/static_files/timesync/usr/local/sbin/redneck-timesync.sh
+++ b/satellit_installer/static_files/timesync/usr/local/sbin/redneck-timesync.sh
@@ -6,8 +6,26 @@ if [ "$USR" != 0 ]; then
exit 1
fi
-DRYRUN=false
-[ "x$1" = "x-s" ] || DRYRUN=true
+DRYRUN=true
+BOOTUP=false
+while [ "$#" -gt 0 ]; do
+ case "$1" in
+ -s)
+ DRYRUN=false
+ ;;
+ -b)
+ BOOTUP=true
+ esac
+done
+
+if ! $BOOTUP; then
+ # Not bootup mode, ntpd present, ntpq yields no error:
+ # Assume ntpd is up and running, so don't do anything
+ command -v ntpd > /dev/null && ntpq -p > /dev/null 2>&1 && exit 0
+ # Same for systemd timesync
+ systemctl -q is-active systemd-timesyncd && exit 0
+fi
+
# Check if clock is set properly by probing a bunch of web servers for
# their current time. Then -- after applying some sanity checks -- pick
@@ -35,7 +53,7 @@ F=$(mktemp)
NOW=$(date +%s)
ECODE=0
-/usr/local/sbin/slx-wait-online
+$BOOTUP && /usr/local/sbin/slx-wait-online
# Request all at once, HEAD only, 2 sec timeout
for url in $URLS; do