aboutsummaryrefslogtreecommitdiffstats
path: root/layout/rootfs/etc/s6-rc/source-base/ntpclient
diff options
context:
space:
mode:
authorLaurent Bercot <ska-skaware@skarnet.org>2017-05-22 21:56:04 +0000
committerLaurent Bercot <ska-skaware@skarnet.org>2017-05-22 21:56:04 +0000
commit82d0f92ab8b84466ae20ab919c1f9c3577b5cecb (patch)
tree776015ae6c6a386125b2d39e13b62f91b99548f8 /layout/rootfs/etc/s6-rc/source-base/ntpclient
downloadlh-bootstrap-82d0f92ab8b84466ae20ab919c1f9c3577b5cecb.tar.gz
Initial commit
Diffstat (limited to 'layout/rootfs/etc/s6-rc/source-base/ntpclient')
-rw-r--r--layout/rootfs/etc/s6-rc/source-base/ntpclient/dependencies3
-rw-r--r--layout/rootfs/etc/s6-rc/source-base/ntpclient/notification-fd1
-rw-r--r--layout/rootfs/etc/s6-rc/source-base/ntpclient/pipeline-name1
-rw-r--r--layout/rootfs/etc/s6-rc/source-base/ntpclient/producer-for1
-rwxr-xr-xlayout/rootfs/etc/s6-rc/source-base/ntpclient/run58
-rw-r--r--layout/rootfs/etc/s6-rc/source-base/ntpclient/type1
6 files changed, 65 insertions, 0 deletions
diff --git a/layout/rootfs/etc/s6-rc/source-base/ntpclient/dependencies b/layout/rootfs/etc/s6-rc/source-base/ntpclient/dependencies
new file mode 100644
index 0000000..a328ed2
--- /dev/null
+++ b/layout/rootfs/etc/s6-rc/source-base/ntpclient/dependencies
@@ -0,0 +1,3 @@
+activate-eth0
+dnscache
+init-clock
diff --git a/layout/rootfs/etc/s6-rc/source-base/ntpclient/notification-fd b/layout/rootfs/etc/s6-rc/source-base/ntpclient/notification-fd
new file mode 100644
index 0000000..00750ed
--- /dev/null
+++ b/layout/rootfs/etc/s6-rc/source-base/ntpclient/notification-fd
@@ -0,0 +1 @@
+3
diff --git a/layout/rootfs/etc/s6-rc/source-base/ntpclient/pipeline-name b/layout/rootfs/etc/s6-rc/source-base/ntpclient/pipeline-name
new file mode 100644
index 0000000..f9615f1
--- /dev/null
+++ b/layout/rootfs/etc/s6-rc/source-base/ntpclient/pipeline-name
@@ -0,0 +1 @@
+ntpclient-pipeline
diff --git a/layout/rootfs/etc/s6-rc/source-base/ntpclient/producer-for b/layout/rootfs/etc/s6-rc/source-base/ntpclient/producer-for
new file mode 100644
index 0000000..c51cd0b
--- /dev/null
+++ b/layout/rootfs/etc/s6-rc/source-base/ntpclient/producer-for
@@ -0,0 +1 @@
+ntpclient-log
diff --git a/layout/rootfs/etc/s6-rc/source-base/ntpclient/run b/layout/rootfs/etc/s6-rc/source-base/ntpclient/run
new file mode 100755
index 0000000..1c1a820
--- /dev/null
+++ b/layout/rootfs/etc/s6-rc/source-base/ntpclient/run
@@ -0,0 +1,58 @@
+#!/command/execlineb -P
+
+fdmove -c 2 1
+
+
+# Get the IP addresses for some NTP servers in our country.
+# Limit the DNS queries to 30 seconds: if the DNS is slower than
+# that, chances are the server isn't good for us anyway.
+# All the queries are parallelized, so it's fast.
+
+pipeline
+{
+ s6-setuidgid nobody
+ s6-envdir /etc/s6-linux-init/env-stage2
+ import -u COUNTRY_CODE
+ forx -p I { 0 1 }
+ import -u I
+ s6-dnsip4 -t 30000 -- ${I}.${COUNTRY_CODE}.pool.ntp.org
+}
+importas -u p1 !
+
+
+# Ask for a NTP exchange with the servers we get.
+# If the exchange can't be completed in 5 seconds, kill it.
+# All the queries are parallelized.
+
+pipeline
+{
+ s6-setuidgid ntp
+ forstdin -p -d"\n" NTPSERVERIP
+ import -u NTPSERVERIP
+ s6-sntpclock -T 5000 ${NTPSERVERIP}
+}
+importas -u p2 !
+
+
+# Take the first answer we get
+
+pipeline
+{
+ s6-setuidgid nobody
+ s6-head -Sc 12
+}
+importas -u p3 !
+
+
+# Update the system clock. Accept 10 minutes of discrepancy.
+
+if { s6-clockadd -e 600000 }
+
+
+# Success. Send a readiness notification, reap zombies,
+# and sleep for 4 hours.
+
+s6-setuidgid nobody
+if { fdmove 1 3 s6-echo }
+wait { ${p1} ${p2} ${p3} }
+s6-sleep 14400
diff --git a/layout/rootfs/etc/s6-rc/source-base/ntpclient/type b/layout/rootfs/etc/s6-rc/source-base/ntpclient/type
new file mode 100644
index 0000000..5883cff
--- /dev/null
+++ b/layout/rootfs/etc/s6-rc/source-base/ntpclient/type
@@ -0,0 +1 @@
+longrun