From 1aa3bc74170f10a4285827efa2748d1d6c2e4613 Mon Sep 17 00:00:00 2001 From: Laurent Bercot Date: Fri, 23 Jan 2026 06:49:25 +0000 Subject: New example batch of service definitions --- .../ntpclient/dependencies.d/dns-cache | 0 .../ntpclient/dependencies.d/init-clock | 0 examples/source-router/ntpclient/notification-fd | 1 + examples/source-router/ntpclient/producer-for | 1 + examples/source-router/ntpclient/run | 56 ++++++++++++++++++++++ examples/source-router/ntpclient/type | 1 + 6 files changed, 59 insertions(+) create mode 100644 examples/source-router/ntpclient/dependencies.d/dns-cache create mode 100644 examples/source-router/ntpclient/dependencies.d/init-clock create mode 100644 examples/source-router/ntpclient/notification-fd create mode 100644 examples/source-router/ntpclient/producer-for create mode 100755 examples/source-router/ntpclient/run create mode 100644 examples/source-router/ntpclient/type (limited to 'examples/source-router/ntpclient') diff --git a/examples/source-router/ntpclient/dependencies.d/dns-cache b/examples/source-router/ntpclient/dependencies.d/dns-cache new file mode 100644 index 0000000..e69de29 diff --git a/examples/source-router/ntpclient/dependencies.d/init-clock b/examples/source-router/ntpclient/dependencies.d/init-clock new file mode 100644 index 0000000..e69de29 diff --git a/examples/source-router/ntpclient/notification-fd b/examples/source-router/ntpclient/notification-fd new file mode 100644 index 0000000..00750ed --- /dev/null +++ b/examples/source-router/ntpclient/notification-fd @@ -0,0 +1 @@ +3 diff --git a/examples/source-router/ntpclient/producer-for b/examples/source-router/ntpclient/producer-for new file mode 100644 index 0000000..c51cd0b --- /dev/null +++ b/examples/source-router/ntpclient/producer-for @@ -0,0 +1 @@ +ntpclient-log diff --git a/examples/source-router/ntpclient/run b/examples/source-router/ntpclient/run new file mode 100755 index 0000000..8ded1c1 --- /dev/null +++ b/examples/source-router/ntpclient/run @@ -0,0 +1,56 @@ +#!/command/execlineb -P + +fdmove -c 2 1 + + +# Get the IP addresses for some NTP servers. +# 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 + forx -p I { 0 1 2 } + importas -u I I + s6-dnsip4 -t 30000 -- ${I}.fr.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 + importas -u NTPSERVERIP 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/examples/source-router/ntpclient/type b/examples/source-router/ntpclient/type new file mode 100644 index 0000000..5883cff --- /dev/null +++ b/examples/source-router/ntpclient/type @@ -0,0 +1 @@ +longrun -- cgit v1.3.1