blob: af35e057a00aafc86bdeeabcce304dfa5a52bb20 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
#!/bin/sh
PREFIX=@PREFIX@
: ${LIBDIR=$PREFIX/lib}
. "$LIBDIR/libalpine.sh"
usage() {
cat >&$(( $1 + 1 ))<<-__EOF__
usage: setup-ntp [-h] [busybox|openntpd|chrony|none]
Setup NTP time synchronization
options:
-h Show this help
User is prompted if no NTP daemon is specified
__EOF__
exit $1
}
while getopts "hc:" opt; do
case $opt in
c) resp="$OPTARG";;
h) usage 0;;
'?') usage 1;;
esac
done
shift $(( $OPTIND - 1 ))
resp=$1
while [ $# -eq 0 ] && ! isin "$resp" busybox openntpd chrony none abort; do
ask "Which NTP client to run? ('busybox', 'openntpd', 'chrony' or 'none')" chrony
done
pkgs="$resp"
case "$resp" in
none|abort)
exit 0
;;
busybox)
pkgs=''
svc=ntpd
;;
chrony)
if apk info --installed --quiet acf-core; then
pkgs="$pkgs acf-chrony"
fi
svc=chronyd
;;
openntpd)
svc=openntpd
;;
*)
echo "setup-ntp: '$resp' is not a supported NTP client" >&2
usage 1
;;
esac
[ -z "$pkgs" ] || $MOCK apk add --quiet $pkgs
rc-update add $svc default
rc-service $svc start
|