diff options
author | Natanael Copa <ncopa@alpinelinux.org> | 2022-11-21 16:28:08 +0100 |
---|---|---|
committer | Natanael Copa <ncopa@alpinelinux.org> | 2022-11-21 16:28:08 +0100 |
commit | 8f72ede2ebdc98466b40994af52f3b374b8dbece (patch) | |
tree | 2cf360eb434c533fb556d4cc1120ab0d11084db3 | |
parent | 73847dbfedb96a83580f0083c4a1959f4c0a1c3d (diff) | |
download | alpine-conf-8f72ede2ebdc98466b40994af52f3b374b8dbece.zip |
setup-interfaces: use 'none' to leave network unmodified
fixes https://gitlab.alpinelinux.org/alpine/alpine-conf/-/issues/10542
-rw-r--r-- | setup-interfaces.in | 7 | ||||
-rwxr-xr-x | tests/setup_interfaces_test | 31 |
2 files changed, 36 insertions, 2 deletions
diff --git a/setup-interfaces.in b/setup-interfaces.in index 07427a0..3a8a71f 100644 --- a/setup-interfaces.in +++ b/setup-interfaces.in @@ -441,6 +441,8 @@ iface_help() { You will be asked which physical interface(s) to be used for advanced configurations. + Select 'none' to leave configuration unmodified. + __EOF__ } prompt_for_interfaces() { @@ -458,6 +460,7 @@ prompt_for_interfaces() { iface=$resp case "$iface" in + "none") exit;; "done") break;; '?') iface_help; continue;; br[0-9]*|bridge[0-9]*|virbr[0-9]*) @@ -576,6 +579,10 @@ while getopts "abhip:r" opt; do esac done +if [ "$1" = none ]; then + exit +fi + mkdir -p $ROOT/etc/network if [ "$STDINPUT" = "1" ]; then cat > $ROOT/etc/network/interfaces diff --git a/tests/setup_interfaces_test b/tests/setup_interfaces_test index e848da3..35dce72 100755 --- a/tests/setup_interfaces_test +++ b/tests/setup_interfaces_test @@ -3,14 +3,16 @@ . $(atf_get_srcdir)/test_env.sh init_tests \ setup_interfaces_usage \ + setup_interfaces_none \ setup_interfaces_interactive_dhcp \ + setup_interfaces_interactive_none \ setup_interfaces_interactive_vlan \ setup_interfaces_interactive_vlan_ng \ setup_interfaces_interactive_vlan0_ng \ setup_interfaces_interactive_br0 \ setup_interfaces_interactive_bond0 \ setup_interfaces_interactive_wlan0_psk \ - setup_interfaces_interactive_wlan0_none + setup_interfaces_interactive_wlan0_open setup_interfaces_usage_body() { test_usage setup-interfaces @@ -26,6 +28,16 @@ create_fake_ifaces() { done } +setup_interfaces_none_body() { + init_env + create_fake_ifaces lo eth0 + atf_check -s exit:0 \ + setup-interfaces none + if [ -f etc/network/interfaces ]; then + atf_fail "etc/network/interfaces should not be created" + fi +} + setup_interfaces_interactive_dhcp_body() { init_env create_fake_ifaces lo eth0 @@ -42,6 +54,21 @@ setup_interfaces_interactive_dhcp_body() { setup-interfaces <answers } +setup_interfaces_interactive_none_body() { + init_env + create_fake_ifaces lo eth0 + ( + # Which one do you want to initialize? (or '?' or 'done') [eth0] + echo none + )>answers + atf_check -s exit:0 \ + -o match:"Available interfaces are: eth0" \ + setup-interfaces <answers + if [ -f etc/network/interfaces ]; then + atf_fail "etc/network/interfaces should not be created" + fi +} + setup_interfaces_interactive_vlan_body() { init_env create_fake_ifaces lo eth0 @@ -182,7 +209,7 @@ setup_interfaces_interactive_wlan0_psk_body() { setup-interfaces <answers } -setup_interfaces_interactive_wlan0_none_body() { +setup_interfaces_interactive_wlan0_open_body() { init_env create_fake_ifaces lo eth0 wlan0 mkdir -p sys/class/net/wlan0/phy80211 |