From 643189cb4a366ede798ddc3297b9bfc3f60dc770 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Sat, 3 Oct 2026 11:25:25 +0200 Subject: [PATCH 1/5] ntpd: Import existing tools into repository --- install.sh | 4 ++++ ntp/ntp.conf | 8 ++++++++ ntp/ntp.service | 10 ++++++++++ ntp/ntp.time.conf | 10 ++++++++++ ntp/ntpd-switch | 12 ++++++++++++ 5 files changed, 44 insertions(+) create mode 100644 ntp/ntp.conf create mode 100644 ntp/ntp.service create mode 100644 ntp/ntp.time.conf create mode 100755 ntp/ntpd-switch diff --git a/install.sh b/install.sh index 1ff39652..a52d187b 100755 --- a/install.sh +++ b/install.sh @@ -272,6 +272,10 @@ install_symlink ../dbus.socket "$DESTDIR$usr_libdir/s for f in post-pdist/*; do install_exec "$f" "$DESTDIR$usr_exec_prefix/libexec/post-pdist/$(basename "$f")" done +install_exec ntp/ntpd-switch "$DESTDIR$usr_libdir/ntpd-switch" +install_data ntp/ntp.time.conf "$DESTDIR$sysconfdir/ntp.time.conf" +install_data ntp/ntp.conf "$DESTDIR$sysconfdir/ntp.conf" +install_data ntp/ntp.service "$DESTDIR$systemdunitdir/ntp.service" postinstall exit diff --git a/ntp/ntp.conf b/ntp/ntp.conf new file mode 100644 index 00000000..c1b54ae2 --- /dev/null +++ b/ntp/ntp.conf @@ -0,0 +1,8 @@ +server time.molgen.mpg.de + +driftfile /var/cache/ntp.drift +pidfile /var/run/ntpd.pid + +restrict default noquery +restrict 127.0.0.1 + diff --git a/ntp/ntp.service b/ntp/ntp.service new file mode 100644 index 00000000..f3dedffb --- /dev/null +++ b/ntp/ntp.service @@ -0,0 +1,10 @@ +[Unit] +Description=Network Time Service +After=nss-lookup.target + +[Service] +ExecStart=/usr/lib/ntpd-switch --nofork --ipv4 --panicgate + +[Install] +WantedBy=basic.target + diff --git a/ntp/ntp.time.conf b/ntp/ntp.time.conf new file mode 100644 index 00000000..c9ba9df2 --- /dev/null +++ b/ntp/ntp.time.conf @@ -0,0 +1,10 @@ +# from http://support.ntp.org/bin/view/Servers/StratumOneTimeServers +server zeit.fu-berlin.de +server ntps1-0.cs.tu-berlin.de +server time.fu-berlin.de + +driftfile /var/cache/ntp.drift +pidfile /var/run/ntpd.pid + +restrict default noquery +restrict 127.0.0.1 diff --git a/ntp/ntpd-switch b/ntp/ntpd-switch new file mode 100755 index 00000000..f613f26e --- /dev/null +++ b/ntp/ntpd-switch @@ -0,0 +1,12 @@ +#! /bin/sh + +PATH=/usr/sbin:/usr/bin:$PATH + +hostname=`hostname -s` +if [ $hostname = "wtf" ] +then + ip addr add 141.14.16.215/20 dev net03 + exec /usr/bin/ntpd $@ --configfile=/etc/ntp.time.conf --interface=141.14.16.215 +else + exec /usr/bin/ntpd $@ +fi From 1e6c48a771faa3ce51972afd756304c1e641488f Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Sat, 3 Oct 2026 13:56:55 +0200 Subject: [PATCH 2/5] ntpd: Remove --- install.sh | 4 ---- ntp/ntp.conf | 8 -------- ntp/ntp.service | 10 ---------- ntp/ntp.time.conf | 10 ---------- ntp/ntpd-switch | 12 ------------ 5 files changed, 44 deletions(-) delete mode 100644 ntp/ntp.conf delete mode 100644 ntp/ntp.service delete mode 100644 ntp/ntp.time.conf delete mode 100755 ntp/ntpd-switch diff --git a/install.sh b/install.sh index a52d187b..1ff39652 100755 --- a/install.sh +++ b/install.sh @@ -272,10 +272,6 @@ install_symlink ../dbus.socket "$DESTDIR$usr_libdir/s for f in post-pdist/*; do install_exec "$f" "$DESTDIR$usr_exec_prefix/libexec/post-pdist/$(basename "$f")" done -install_exec ntp/ntpd-switch "$DESTDIR$usr_libdir/ntpd-switch" -install_data ntp/ntp.time.conf "$DESTDIR$sysconfdir/ntp.time.conf" -install_data ntp/ntp.conf "$DESTDIR$sysconfdir/ntp.conf" -install_data ntp/ntp.service "$DESTDIR$systemdunitdir/ntp.service" postinstall exit diff --git a/ntp/ntp.conf b/ntp/ntp.conf deleted file mode 100644 index c1b54ae2..00000000 --- a/ntp/ntp.conf +++ /dev/null @@ -1,8 +0,0 @@ -server time.molgen.mpg.de - -driftfile /var/cache/ntp.drift -pidfile /var/run/ntpd.pid - -restrict default noquery -restrict 127.0.0.1 - diff --git a/ntp/ntp.service b/ntp/ntp.service deleted file mode 100644 index f3dedffb..00000000 --- a/ntp/ntp.service +++ /dev/null @@ -1,10 +0,0 @@ -[Unit] -Description=Network Time Service -After=nss-lookup.target - -[Service] -ExecStart=/usr/lib/ntpd-switch --nofork --ipv4 --panicgate - -[Install] -WantedBy=basic.target - diff --git a/ntp/ntp.time.conf b/ntp/ntp.time.conf deleted file mode 100644 index c9ba9df2..00000000 --- a/ntp/ntp.time.conf +++ /dev/null @@ -1,10 +0,0 @@ -# from http://support.ntp.org/bin/view/Servers/StratumOneTimeServers -server zeit.fu-berlin.de -server ntps1-0.cs.tu-berlin.de -server time.fu-berlin.de - -driftfile /var/cache/ntp.drift -pidfile /var/run/ntpd.pid - -restrict default noquery -restrict 127.0.0.1 diff --git a/ntp/ntpd-switch b/ntp/ntpd-switch deleted file mode 100755 index f613f26e..00000000 --- a/ntp/ntpd-switch +++ /dev/null @@ -1,12 +0,0 @@ -#! /bin/sh - -PATH=/usr/sbin:/usr/bin:$PATH - -hostname=`hostname -s` -if [ $hostname = "wtf" ] -then - ip addr add 141.14.16.215/20 dev net03 - exec /usr/bin/ntpd $@ --configfile=/etc/ntp.time.conf --interface=141.14.16.215 -else - exec /usr/bin/ntpd $@ -fi From da4c39d0b49bd07a663baed1a3cb1f843c707324 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Sat, 3 Oct 2026 13:57:31 +0200 Subject: [PATCH 3/5] systemd-timesyncd: Add configuration --- .../system/systemd-timesyncd.service.d/not-on-wtf.conf | 6 ++++++ etc/systemd/timesyncd.conf.d/local.conf | 7 +++++++ 2 files changed, 13 insertions(+) create mode 100644 etc/systemd/system/systemd-timesyncd.service.d/not-on-wtf.conf create mode 100644 etc/systemd/timesyncd.conf.d/local.conf diff --git a/etc/systemd/system/systemd-timesyncd.service.d/not-on-wtf.conf b/etc/systemd/system/systemd-timesyncd.service.d/not-on-wtf.conf new file mode 100644 index 00000000..09685a59 --- /dev/null +++ b/etc/systemd/system/systemd-timesyncd.service.d/not-on-wtf.conf @@ -0,0 +1,6 @@ +# Don't start systemd-timesyncd on wtf, because on this host we start +# ntpd-time.service which regulates the kernel real time clock. + +[Unit] + +ConditionHost=!wtf.molgen.mpg.de diff --git a/etc/systemd/timesyncd.conf.d/local.conf b/etc/systemd/timesyncd.conf.d/local.conf new file mode 100644 index 00000000..66f3a214 --- /dev/null +++ b/etc/systemd/timesyncd.conf.d/local.conf @@ -0,0 +1,7 @@ +[Time] + +# several fallbacks. systemd-timesyncd will use the first responding server and stick +# to it as long as it is reachable or until restarted. +# test remote with `ntpdate -q SERVER` (no change of local time) + +NTP=time.molgen.mpg.de ntps1.gwdg.de ntps2.gwdg.de ntps3.gwdg.de ntps4.gwdg.de zeit.fu-berlin.de ntps1-0.cs.tu-berlin.de ptbtime1.ptb.de ptbtime2.ptb.de ptbtime3.ptb.de 0.de.pool.ntp.org 1.de.pool.ntp.org From 25a875e90dd85bb0714f987623ec42ab9385f5a6 Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Sat, 3 Oct 2026 14:22:07 +0200 Subject: [PATCH 4/5] ntpd-time: Add service for time.molgen.mpg.de@wtf --- etc/ntpd-time.conf | 22 ++++++++++++++++++++++ etc/systemd/system/ntpd-time.service | 18 ++++++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 etc/ntpd-time.conf create mode 100644 etc/systemd/system/ntpd-time.service diff --git a/etc/ntpd-time.conf b/etc/ntpd-time.conf new file mode 100644 index 00000000..8001ef73 --- /dev/null +++ b/etc/ntpd-time.conf @@ -0,0 +1,22 @@ +# Note: This is only for time.molgen.mpg.de@wtf + +interface ignore wildcard +interface listen 141.14.16.215 # time.molgen.mpg.de +interface listen 127.0.0.1 # for ntpq + +server ntps1.gwdg.de iburst +server ntps2.gwdg.de iburst +server ntps3.gwdg.de iburst +server ntps4.gwdg.de iburst +server zeit.fu-berlin.de iburst +server ntps1-0.cs.tu-berlin.de iburst +server ptbtime1.ptb.de iburst +server ptbtime2.ptb.de iburst +server ptbtime3.ptb.de iburst +server 0.de.pool.ntp.org iburst +server 1.de.pool.ntp.org iburst + +driftfile /var/cache/ntp.drift + +restrict default nomodify noquery notrap nopeer +restrict 127.0.0.1 diff --git a/etc/systemd/system/ntpd-time.service b/etc/systemd/system/ntpd-time.service new file mode 100644 index 00000000..2ccfdd76 --- /dev/null +++ b/etc/systemd/system/ntpd-time.service @@ -0,0 +1,18 @@ +[Unit] +ConditionHost=wtf.molgen.mpg.de +DefaultDependencies=no +After=systemd-sysusers.service +Before=time-set.target sysinit.target shutdown.target +Conflicts=shutdown.target +Wants=time-set.target + +[Service] +ExecStart=/usr/bin/ntpd -n -g -c /etc/ntpd-time.conf +Restart=always + +# ntpd logs to syslog, stdout/stderr is redundant +StandardOutput=null +StandardError=null + +[Install] +WantedBy=basic.target From 03cc5b5adb35206a8042c70f3eebce060c3dfc4f Mon Sep 17 00:00:00 2001 From: Donald Buczek Date: Sat, 3 Oct 2026 20:12:49 +0200 Subject: [PATCH 5/5] ntp-clock-stamp: Add systemd-timesyncd updates the timestamp of /var/lib/systemd/timesync/clock whenever it updates the system time. During boot, the system RTC is forwarded by systemd to this timestamp to prevent the system from running with a nonsensical time in case the RTC is bad or missing. On wtf we run ntpd instead of systemd-timesyncd. Add a service to maintain the timestamp of /var/lib/systemd/timesync/clock on wtf when ntpd is in sync. --- etc/systemd/system/ntp-clock-stamp.service | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 etc/systemd/system/ntp-clock-stamp.service diff --git a/etc/systemd/system/ntp-clock-stamp.service b/etc/systemd/system/ntp-clock-stamp.service new file mode 100644 index 00000000..cb8b0807 --- /dev/null +++ b/etc/systemd/system/ntp-clock-stamp.service @@ -0,0 +1,13 @@ +[Unit] +ConditionHost=wtf.molgen.mpg.de +After=ntpd-time.service +BindsTo=ntpd-time.service + +[Service] +Type=exec +ExecStartPre=/usr/bin/mkdir -p /var/lib/systemd/timesync +ExecStart=/bin/bash -c 'while true; do out=$(ntpq -c "rv 0 leap" 2>/dev/null); [[ $out =~ leap=(00|01|10) ]] && touch /var/lib/systemd/timesync/clock; sleep 60; done' +Restart=on-failure + +[Install] +WantedBy=multi-user.target