summaryrefslogtreecommitdiff
path: root/custom
diff options
context:
space:
mode:
authoruvok cheetah2024-09-10 22:08:16 +0200
committeruvok cheetah2024-09-10 22:08:16 +0200
commit12383c3beddd20d0a3cb043ed79d64131404631c (patch)
treed863da66831e2338bab6b9f7dca099366e18c726 /custom
parentfb718cf7701eb15a3235a9393013e00357018dd9 (diff)
Make SNTP background
I have no idea how to only add files to the overlay if a package is configured... This will lead to problems probably.
Diffstat (limited to 'custom')
-rwxr-xr-xcustom/overlay/etc/init.d/S48sntp62
1 files changed, 62 insertions, 0 deletions
diff --git a/custom/overlay/etc/init.d/S48sntp b/custom/overlay/etc/init.d/S48sntp
new file mode 100755
index 0000000..2d6f0d7
--- /dev/null
+++ b/custom/overlay/etc/init.d/S48sntp
@@ -0,0 +1,62 @@
+#!/bin/sh
+
+#####
+# modification by uvok.
+# just throw the process into the background.
+# ethernet/DHCP takes too long.
+# and I don't want to wait eternities for boot to finish.
+#####
+
+DAEMON="sntp"
+# sntp uses all the IPs resolved for the hostname (i.e. pool.ntp.org has 4).
+# It will try each until they either all timeout or time has been set. Thus
+# default to only providing one NTP pool host.
+SNTP_SERVERS="pool.ntp.org"
+# Step if time delta is greater then 128ms, otherwise slew
+SNTP_ARGS="-Ss -M 128"
+SNTP_KEY_CACHE="/tmp/kod"
+
+# shellcheck source=/dev/null
+[ -r "/etc/default/$DAEMON" ] && . "/etc/default/$DAEMON"
+
+start() {
+ printf 'Starting %s: ' "$DAEMON"
+ # Create key cache file to prevents warning that file is missing
+ touch $SNTP_KEY_CACHE
+ # shellcheck disable=SC2086 # we need the word splitting
+ (sleep 10; /usr/bin/$DAEMON $SNTP_ARGS -K $SNTP_KEY_CACHE $SNTP_SERVERS) &
+ # sntp behavior
+ # - Does not background
+ # - Does not infinitely block
+ # - Time-out w/o network = ~2 sec
+ # - Time-out w/ network = ~5sec * # of servers
+ status=$?
+ if [ "$status" -eq 0 ]; then
+ echo "OK"
+ else
+ echo "FAIL"
+ fi
+ return "$status"
+}
+
+stop() {
+ echo "Nothing to do, $DAEMON is not a daemon."
+}
+
+restart() {
+ stop
+ sleep 1
+ start
+}
+
+reload() {
+ echo "Nothing to do, $DAEMON does not support reload."
+}
+
+case "$1" in
+ start|stop|restart|reload)
+ "$1";;
+ *)
+ echo "Usage: $0 {start|stop|restart|reload}"
+ exit 1
+esac