diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2022-11-22 11:42:58 +0100 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2022-11-22 11:42:58 +0100 |
commit | c7fa8d0c0bb4a7f047bc0bf5282d20cf754f5703 (patch) | |
tree | 7bf968fcb5065b1402ad6bf295590509fcf10c94 | |
parent | eef31dff2eae711c33cabc1a05b2c9df2fa25d01 (diff) | |
download | alpine-conf-c7fa8d0c0bb4a7f047bc0bf5282d20cf754f5703.zip |
setup-alpine: leave interfaces file unmodified with 'none'
fixes https://gitlab.alpinelinux.org/alpine/alpine-conf/-/issues/10542
-rw-r--r-- | setup-alpine.in | 7 | ||||
-rwxr-xr-x | tests/setup_alpine_test | 32 |
2 files changed, 36 insertions, 3 deletions
diff --git a/setup-alpine.in b/setup-alpine.in index 2308f88..aea9d3f 100644 --- a/setup-alpine.in +++ b/setup-alpine.in @@ -158,14 +158,17 @@ fi [ -z "$SSH_CONNECTION" ] && rst_if=1 if [ -n "$INTERFACESOPTS" ]; then - printf "$INTERFACESOPTS" | setup-interfaces -i ${rst_if:+-r} + if [ "$INTERFACESOPTS" != none ]; then + printf "$INTERFACESOPTS" | setup-interfaces -i ${rst_if:+-r} + fi else setup-interfaces ${quick:+-a} ${rst_if:+-r} fi # setup up dns if no dhcp was configured -grep '^iface.*dhcp' $ROOT/etc/network/interfaces > /dev/null ||\ +if [ -f "$ROOT"/etc/network/interfaces ] && ! grep -q '^iface.*dhcp' "$ROOT"/etc/network/interfaces; then setup-dns ${DNSOPTS} +fi # set root password if [ -z "$empty_root_password" ]; then diff --git a/tests/setup_alpine_test b/tests/setup_alpine_test index d7fbd87..014dd7d 100755 --- a/tests/setup_alpine_test +++ b/tests/setup_alpine_test @@ -6,7 +6,8 @@ init_tests \ setup_alpine_quick \ setup_alpine_create_answerfile \ setup_alpine_kvm_clock \ - setup_alpine_restart_network + setup_alpine_restart_network \ + setup_alpine_answerfile_none export WGETCONTENT="https://mirror.example.com" setup_alpine_usage_body() { @@ -109,3 +110,32 @@ setup_alpine_restart_network_body() { atf_check -s exit:3 \ rc-service --quiet networking status } + +setup_alpine_answerfile_none_body() { + init_env + + cat >opts<<-EOF + KEYMAPOPTS=none + HOSTNAMEOPTS=alpine + INTERFACESOPTS=none + DNSOPTS=none + TIMEZONEOPTS=none + PROXYOPTS=none + NTPOPTS=none + APKREPOSOPTS=none + USEROPTS=none + SSHDOPTS=none + DISKOPTS=none + LBUOPTS=none + APKCACHEOPTS=none + EOF + atf_check -s exit:0 \ + -o match:"apk add" \ + setup-alpine -e -f opts + for i in etc/network/interfaces etc/resolv.conf; do + if [ -e "$i" ]; then + atf_fail "$i should not been created" + fi + done +} + |