#!/bin/sh PREFIX= . "$PREFIX/lib/libalpine.sh" usage() { cat <<__EOF__ usage: setup-ntp [-h] [-c choice of NTP daemon] Setup NTP time synchronization options: -h Show this help -c Choice of NTP daemon: chrony openntpd none __EOF__ exit 1 } while getopts "hc:" opt; do case $opt in c) ntpchoice="$OPTARG";; h) usage;; esac done if [ -z "$ntpchoice" ]; then echo -n "Which NTP client to run? ('openntpd', 'chrony' or 'none') [chrony] " default_read ntpchoice "chrony" fi pkgs="$ntpchoice" case "$ntpchoice" in none|abort) exit 0 ;; chrony) if apk info --installed --quiet acf-core; then pkgs="$pkgs acf-chrony" fi svc=chronyd ;; openntpd) svc=ntpd ;; esac apk add -q $pkgs rc-update add $svc default rc-service $svc start