diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2022-07-01 11:51:35 +0200 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2022-07-01 10:15:32 +0000 |
commit | 8730da8aeb5abb42e7f29ed767680d9f5258fb06 (patch) | |
tree | df9a0942bff1d2639615318db1cb8b3451751fd4 | |
parent | 5e8175705911c1daf54d527b93c2c304afd3c507 (diff) | |
download | alpine-conf-8730da8aeb5abb42e7f29ed767680d9f5258fb06.zip |
setup-ntp: fix non-interactive -c option
We should not prompt user when -c is specified, in which case $1 is
empty.
fixes https://gitlab.alpinelinux.org/alpine/alpine-conf/-/issues/10522
-rw-r--r-- | setup-ntp.in | 2 | ||||
-rwxr-xr-x | tests/setup_ntp_test | 17 |
2 files changed, 17 insertions, 2 deletions
diff --git a/setup-ntp.in b/setup-ntp.in index af35e05..9f48d72 100644 --- a/setup-ntp.in +++ b/setup-ntp.in @@ -27,7 +27,7 @@ while getopts "hc:" opt; do done shift $(( $OPTIND - 1 )) -resp=$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 diff --git a/tests/setup_ntp_test b/tests/setup_ntp_test index 8294232..6746277 100755 --- a/tests/setup_ntp_test +++ b/tests/setup_ntp_test @@ -6,7 +6,9 @@ init_tests \ setup_ntp_invalid \ setup_ntp_busybox \ setup_ntp_chrony \ - setup_ntp_openntpd + setup_ntp_openntpd \ + setup_ntp_none \ + setup_ntp_none_backwards_compat setup_ntp_usage_body() { test_usage setup-ntp @@ -43,3 +45,16 @@ setup_ntp_openntpd_body() { -o match:"Starting openntpd" \ setup-ntp openntpd } + +setup_ntp_none_body() { + init_env + atf_check -s exit:0 \ + setup-ntp none +} + +setup_ntp_none_backwards_compat_body() { + init_env + atf_check -s exit:0 \ + setup-ntp -c none +} + |