On Fri, Aug 30, 2013 at 11:28:55AM +0100, Lars Wirzenius wrote:
With these changes:
* NTP is run at boot time, once, to set the system clock.
This allows the rest of the boot to continue as soon as time is set,
which should happen as soon as there is networking. This is
necessary because there's parts of the system that need to wait
for the system clock to be set.
* NTP is then also started as a daemon, which runs continuously,
until stopped by the user, to keep system clock synchronised.
The two systemd units need to be separate, otherwise we can't have
network.target depend on a unit that finishes quickly: the daemon
unit doesn't exit until there's an error.
[snip]
diff --git a/busybox.morph b/busybox.morph
index 188edf4..ad40f5b 100644
--- a/busybox.morph
+++ b/busybox.morph
@@ -57,8 +57,10 @@ configure-commands:
build-commands:
- make
- |
- for f in ifup@.service ntpd.service crond.service; do
- sed -e 's|@rootprefix@||g' "systemd-units/$f.in"
>"systemd-units/$f";
+ for fin in systemd-units/*.in
+ do
+ f=$(echo "$fin" | sed 's/\.in$//')
I would use `f=${fin%.in}`, but I'll take the echo and sed for readability.
+ sed -e 's|@rootprefix@||g' "$fin"
>"$f";
done
install-commands:
@@ -91,5 +93,12 @@ install-commands:
- cp examples/udhcp/simple.script
"$DESTDIR$PREFIX"/share/udhcpc/default.script
# Set up NTP
- - cp scripts/ntpd-set.sh "$DESTDIR$PREFIX"/bin/ntpd-set.sh
- - chmod 6755 "$DESTDIR$PREFIX"/bin/ntpd-set.sh
+ - install scripts/run-ntpd-with-config "$DESTDIR$PREFIX"/bin/.
+ - install -d "$DESTDIR/etc"
+ - |
+ cat << EOF > "$DESTDIR/etc/ntpd.conf"
+ server
0.pool.ntp.org
+ server
1.pool.ntp.org
+ server
2.pool.ntp.org
+ server
3.pool.ntp.org
+ EOF
I think in the long term we should aim to keep the contents of /etc
minimal, so the defaults would go elsewhere, but /etc/ntpd.conf is used
in preference if it exists.
However, that is a big job and I'm happy to have this for now.
[snip]
diff --git a/systemd-units/ntpd-boot.service.in
b/systemd-units/ntpd-boot.service.in
new file mode 100644
index 0000000..48b3cf1
--- /dev/null
+++ b/systemd-units/ntpd-boot.service.in
@@ -0,0 +1,10 @@
[snip]
+ExecStart=/usr/sbin/ntpd -n -q -p
0.pool.ntp.org
diff --git a/systemd-units/ntpd.service.in b/systemd-units/ntpd.service.in
index 96ce5ac..2ec35da 100644
--- a/systemd-units/ntpd.service.in
+++ b/systemd-units/ntpd.service.in
@@ -1,8 +1,10 @@
[snip]
[Service]
-Type=oneshot
-ExecStart=/usr/bin/ntpd-set.sh
-RemainAfterExit=true
+Type=simple
+ExecStart=/usr/sbin/ntpd -n -p
0.pool.ntp.org
You went to the effort of designing run-ntpd-with-config, but then aren't
using it anywhere, it's just using ntpd with a fixed address.