aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2011-10-06 13:08:23 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2011-10-06 13:08:23 +0000
commitc61c13c4453377be3e58cd15d062cc8be30060cc (patch)
treed90d6dd0b0f42549a1ea19f1042d7eb6fd39bfa6
parent76db5482a6585ab96923d1f6e9f6e5cda89ccc21 (diff)
downloadalpine-conf-c61c13c4453377be3e58cd15d062cc8be30060cc.tar.bz2
alpine-conf-c61c13c4453377be3e58cd15d062cc8be30060cc.tar.xz
setup-ntp: cleanup a bit
-rwxr-xr-xsetup-ntp.in54
1 files changed, 25 insertions, 29 deletions
diff --git a/setup-ntp.in b/setup-ntp.in
index 65ede2a..42c6bb5 100755
--- a/setup-ntp.in
+++ b/setup-ntp.in
@@ -17,27 +17,6 @@ __EOF__
exit 1
}
-install_ntpchoice() {
- if [ "$1" = "none" ]; then
- exit 0
- elif [ "$1" = "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 [ "$1" = "openntpd" ]; then
- apk add openntpd -q
- /etc/init.d/ntpd start
- rc-update add ntpd default
- fi
-}
-
while getopts "hc:" opt; do
case $opt in
c) ntpchoice="$OPTARG";;
@@ -45,12 +24,29 @@ while getopts "hc:" opt; do
esac
done
-acfinstalled="`apk version acf-core -q | awk '{print $1}'`"
-
-if [ -n "$ntpchoice" ]; then
- install_ntpchoice "$ntpchoice"
-else
- echo "Which NTP service would you like to use? (openntpd, chrony, none) [openntpd]"
- default_read ntpchoice "openntpd"
- install_ntpchoice "$ntpchoice"
+if [ -z "$ntpchoice" ]; then
+ echo -n "Which NTP service would you like to use? (openntpd, chrony, 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
+