1 |
commit: 1297ec97d29b680778c2c985a6a9e2d693af764b |
2 |
Author: Brian Evans <grknight <AT> gentoo <DOT> org> |
3 |
AuthorDate: Tue Mar 7 15:28:37 2017 +0000 |
4 |
Commit: Brian Evans <grknight <AT> gentoo <DOT> org> |
5 |
CommitDate: Tue Mar 7 15:34:04 2017 +0000 |
6 |
URL: https://gitweb.gentoo.org/proj/livecd-tools.git/commit/?id=1297ec97 |
7 |
|
8 |
net-setup: Fix zero argument mode |
9 |
|
10 |
The grepped output of 'ifconfig -a' included a colon after each interface. |
11 |
This broke subsequent calls for information on the interface. |
12 |
|
13 |
Also, instead of flashing an error when a path did not exist, |
14 |
check that it does exist before calling basename. |
15 |
|
16 |
Skip sit0 as it cannot be configured. |
17 |
|
18 |
Finally, check the return value of the dialog call. |
19 |
Only zero means an interface was selected to be processed. |
20 |
|
21 |
net-setup | 14 ++++++-------- |
22 |
1 file changed, 6 insertions(+), 8 deletions(-) |
23 |
|
24 |
diff --git a/net-setup b/net-setup |
25 |
index d47628b..f106f46 100755 |
26 |
--- a/net-setup |
27 |
+++ b/net-setup |
28 |
@@ -7,7 +7,7 @@ get_ifbus() { |
29 |
# Example: ../../../../bus/pci (wanted: pci) |
30 |
# Example: ../../../../../../bus/usb (wanted: usb) |
31 |
local if_bus=$(readlink /sys/class/net/${iface}/device/subsystem) |
32 |
- basename ${if_bus} |
33 |
+ [[ -e "${if_bus}" ]] && basename ${if_bus} |
34 |
} |
35 |
|
36 |
get_ifproduct() { |
37 |
@@ -57,7 +57,7 @@ get_ifdriver() { |
38 |
|
39 |
# Example: ../../../bus/pci/drivers/forcedeth (wanted: forcedeth) |
40 |
local if_driver=$(readlink /sys/class/net/${iface}/device/driver) |
41 |
- basename ${if_driver} |
42 |
+ [[ -e "${if_driver}" ]] && basename ${if_driver} |
43 |
} |
44 |
|
45 |
get_ifmac() { |
46 |
@@ -98,19 +98,17 @@ show_ifmenu() { |
47 |
local opts |
48 |
IFS=" |
49 |
" |
50 |
- for ifname in $(ifconfig -a | grep "^[^ ]"); do |
51 |
+ for ifname in $(ifconfig -a | grep "^[^ ]" | cut -d : -f 1); do |
52 |
ifname="${ifname%% *}" |
53 |
[[ ${ifname} == "lo" ]] && continue |
54 |
+ [[ ${ifname} == "sit0" ]] && continue |
55 |
opts="${opts} ${ifname} '$(get_ifdesc ${ifname})'" |
56 |
done |
57 |
IFS="${old_ifs}" |
58 |
|
59 |
- if ! eval dialog --visit-items \ |
60 |
+ dialog --visit-items --trim \ |
61 |
--menu "Please select the interface that you wish to configure from the list below:" 0 0 0 $opts 2>iface |
62 |
- then |
63 |
- exit |
64 |
- fi |
65 |
- |
66 |
+ [[ $? -gt 0 ]] && exit |
67 |
iface=$(< iface) |
68 |
} |