summaryrefslogtreecommitdiffstats
path: root/satellit_installer/static_files/timesync/usr/local/sbin/redneck-timesync.sh
diff options
context:
space:
mode:
authorSimon Rettberg2023-09-29 16:37:15 +0200
committerSimon Rettberg2023-09-29 16:37:15 +0200
commit134bf3e3bdad7927de9c3ef7b57f9faf358cdffa (patch)
tree4e57eb21018627e3aec030af3bb81432205d3a16 /satellit_installer/static_files/timesync/usr/local/sbin/redneck-timesync.sh
parent[SSPS] timesync: Use more privacy-friendly URLs (diff)
downloadsetup-scripts-134bf3e3bdad7927de9c3ef7b57f9faf358cdffa.tar.gz
setup-scripts-134bf3e3bdad7927de9c3ef7b57f9faf358cdffa.tar.xz
setup-scripts-134bf3e3bdad7927de9c3ef7b57f9faf358cdffa.zip
[SSPS] timesync: Add cronjob to sync once a day
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