diff options
Diffstat (limited to 'setup-ntp.in')
-rwxr-xr-x | setup-ntp.in | 51 |
1 files changed, 51 insertions, 0 deletions
diff --git a/setup-ntp.in b/setup-ntp.in new file mode 100755 index 0000000..8211024 --- /dev/null +++ b/setup-ntp.in @@ -0,0 +1,51 @@ +#!/bin/sh + +PREFIX= + +. "$PREFIX/lib/libalpine.sh" + +usage() { + cat <<__EOF__ +usage: setup-ntp [-hn] + +Setup NTP time synchronization + +options: + -h Show this help + -n Don't prompt, just use defaults +__EOF__ + exit 1 +} + +while getopts "hn" opt; do + case $opt in + n) PROMPT="0";; + h) usage;; + esac +done + +if [ "$PROMPT" != "0" ]; then + echo "Which NTP service would you like to use? (openntpd, chrony, none) [openntpd]" + default_read ntpchoice "openntpd" + if [ "$ntpchoice" = "none" ]; then + exit 0 + fi +fi + +acfinstalled="`apk version acf-core -q | awk '{print $1}'`" +if [ "$ntpchoice" = "chrony" ]; then + if [ "$acfinstalled" != "ERROR:" ]; then + apk add acf-chrony -q + else + apk add chrony -q + fi + + echo "10 chronypass" > /etc/chrony/chrony.keys + + /etc/init.d/chronyd start + rc-update add chronyd default +elif [ "$ntpchoice" = "openntpd" ]; then + apk add openntpd -q + /etc/init.d/ntpd start + rc-update add ntpd default +fi |