blob: 24d9cc1653e89055d0897950b69eec3ba24278c7 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
|
#!/bin/sh
#
# Invoke the Busybox ntpd with servers listed in /etc/ntpd.conf, if it
# exists. The servers should be listed one per line, with the first
# word in the line being "server". Any lines that don't start with
# "server" as the first word are ignored. The server name should be
# the second word. Anything else on the line is ignored.
#
# If the config file does not exist, no default servers are used.
set -eu
parse_servers()
{
awk '$1 == "server" { for (i=2; i <= NF; ++i) print "-p", $i }' "$1"
}
if [ -e /etc/ntpd.conf ]
then
exec ntpd $(parse_servers /etc/ntpd.conf) "$@"
else
exec ntpd "$@"
fi
|