summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Evans <grknight@gentoo.org>2017-03-07 10:28:37 -0500
committerBrian Evans <grknight@gentoo.org>2017-03-07 10:34:04 -0500
commit1297ec97d29b680778c2c985a6a9e2d693af764b (patch)
treef44929aeb9aff4ac4db00957632028df7a9f5bf4
parentautoconfig: EVMS is long dead. (diff)
downloadlivecd-tools-1297ec97d29b680778c2c985a6a9e2d693af764b.tar.gz
livecd-tools-1297ec97d29b680778c2c985a6a9e2d693af764b.tar.bz2
livecd-tools-1297ec97d29b680778c2c985a6a9e2d693af764b.zip
net-setup: Fix zero argument mode
The grepped output of 'ifconfig -a' included a colon after each interface. This broke subsequent calls for information on the interface. Also, instead of flashing an error when a path did not exist, check that it does exist before calling basename. Skip sit0 as it cannot be configured. Finally, check the return value of the dialog call. Only zero means an interface was selected to be processed.
-rwxr-xr-xnet-setup14
1 files changed, 6 insertions, 8 deletions
diff --git a/net-setup b/net-setup
index d47628b..f106f46 100755
--- a/net-setup
+++ b/net-setup
@@ -7,7 +7,7 @@ get_ifbus() {
# Example: ../../../../bus/pci (wanted: pci)
# Example: ../../../../../../bus/usb (wanted: usb)
local if_bus=$(readlink /sys/class/net/${iface}/device/subsystem)
- basename ${if_bus}
+ [[ -e "${if_bus}" ]] && basename ${if_bus}
}
get_ifproduct() {
@@ -57,7 +57,7 @@ get_ifdriver() {
# Example: ../../../bus/pci/drivers/forcedeth (wanted: forcedeth)
local if_driver=$(readlink /sys/class/net/${iface}/device/driver)
- basename ${if_driver}
+ [[ -e "${if_driver}" ]] && basename ${if_driver}
}
get_ifmac() {
@@ -98,19 +98,17 @@ show_ifmenu() {
local opts
IFS="
"
- for ifname in $(ifconfig -a | grep "^[^ ]"); do
+ for ifname in $(ifconfig -a | grep "^[^ ]" | cut -d : -f 1); do
ifname="${ifname%% *}"
[[ ${ifname} == "lo" ]] && continue
+ [[ ${ifname} == "sit0" ]] && continue
opts="${opts} ${ifname} '$(get_ifdesc ${ifname})'"
done
IFS="${old_ifs}"
- if ! eval dialog --visit-items \
+ dialog --visit-items --trim \
--menu "Please select the interface that you wish to configure from the list below:" 0 0 0 $opts 2>iface
- then
- exit
- fi
-
+ [[ $? -gt 0 ]] && exit
iface=$(< iface)
}