summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Maw <richard.maw@codethink.co.uk>2012-11-29 16:27:13 +0000
committerRichard Maw <richard.maw@codethink.co.uk>2012-11-29 16:27:13 +0000
commitcab5a9dc9b44ff9508ff6ae47bcd2c5e9e3130fd (patch)
tree356b86fe5b98fe9817fb7cf18436e09cbf023989
parent0f9476ad12d6cf2af49e58977dae1547bb2971c7 (diff)
parent1f68cf95779d1ab018053dfd8a62a7e943919bd3 (diff)
downloadbusybox-baserock/morph.tar.gz
Merge branch 'baserock/richardmaw/S5892/boot-sequencing' of git://git.baserock.org/delta/busybox into baserock/morphbaserock/morph
Reviewed on IRC by Lars Wirzenius.
-rwxr-xr-xscripts/ntpd-set.sh27
-rw-r--r--systemd-units/ifup@.service.in3
-rw-r--r--systemd-units/ntpd.service.in4
3 files changed, 16 insertions, 18 deletions
diff --git a/scripts/ntpd-set.sh b/scripts/ntpd-set.sh
index 3581d2421..d6fd8f25b 100755
--- a/scripts/ntpd-set.sh
+++ b/scripts/ntpd-set.sh
@@ -1,30 +1,25 @@
#!/bin/sh
max_attempts=4
-try_count=0
# This script takes a list of ntp servers and passes them to ntpd to set the
# system time. If a /etc/ntpd.conf file exists, the servers there are used,
# if not, some default values are passed
set_time() {
- ntpd -n -p $1;
- return $?
+ # -q flag makes ntpd exit after setting the time once
+ ntpd -q -n -p "$1"
}
check_time() {
- for arg ; do
- echo $arg
- if set_time $arg ; then
- return 0
- fi
- done
- # In case we are doing this before the network is up, try again
- let try_count=try_count+1
- if [ $try_count -lt $max_attempts ] ; then
+ for attempt in $(seq "$max_attempts"); do
+ for arg ; do
+ echo $arg
+ if set_time "$arg" ; then
+ return 0
+ fi
+ done
sleep 2
- check_time $@
- else
- return 1
- fi
+ done
+ return 1
}
if [ -f /etc/ntpd.conf ]; then
diff --git a/systemd-units/ifup@.service.in b/systemd-units/ifup@.service.in
index 72313bba9..25e8dc151 100644
--- a/systemd-units/ifup@.service.in
+++ b/systemd-units/ifup@.service.in
@@ -1,8 +1,9 @@
[Unit]
Description=ifup for %I
-After=local-fs.target
+Before=network.target
[Service]
+Type=oneshot
ExecStart=@rootprefix@/sbin/ifup %I
ExecStop=@rootprefix@/sbin/ifdown %I
RemainAfterExit=true
diff --git a/systemd-units/ntpd.service.in b/systemd-units/ntpd.service.in
index 1abc4f3a7..96ce5ac99 100644
--- a/systemd-units/ntpd.service.in
+++ b/systemd-units/ntpd.service.in
@@ -1,6 +1,8 @@
[Unit]
-Description=Service to use ntpd to set the date and time
+Description=Network Time Protocol client
+Before=network.target
[Service]
+Type=oneshot
ExecStart=/usr/bin/ntpd-set.sh
RemainAfterExit=true