summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNatanael Copa <ncopa@alpinelinux.org>2012-03-21 14:50:01 +0000
committerNatanael Copa <ncopa@alpinelinux.org>2012-03-21 14:50:01 +0000
commit2e2c8e524b23267789030254155d4c1265827203 (patch)
tree71d1696acd5a4dc2918d068dfaea11d34568dcc3
parente18c8a75c22f320bfc3db31425f48fc90079369f (diff)
downloadalpine-conf-2e2c8e524b23267789030254155d4c1265827203.zip
libalpine: add available_ifaces
a sorted list of available network interfaces thats not a part of any bridge or bond
-rw-r--r--libalpine.sh.in21
1 files changed, 21 insertions, 0 deletions
diff --git a/libalpine.sh.in b/libalpine.sh.in
index 4ea5201..684f950 100644
--- a/libalpine.sh.in
+++ b/libalpine.sh.in
@@ -81,6 +81,27 @@ is_xen_dom0() {
is_xen && \
grep -q "control_d" /proc/xen/capabilities
}
+
+# list of acailable network interfaces thats not part of any bridge or bond
+available_ifaces() {
+ local iflist= ifpath= iface= i=
+ sorted_ifindexes=$(
+ for i in /sys/class/net/*/ifindex; do
+ [ -e "$i" ] || continue
+ echo -e "$(cat $i)\t$i";
+ done | sort -n | awk '{print $2}')
+ for i in $sorted_ifindexes; do
+ ifpath=${i%/*}
+ iface=${ifpath##*/}
+ # skip interfaces that are part of a bond or bridge
+ if [ -d "$ifpath"/master/bonding ] || [ -d "$ifpath"/brport ]; then
+ continue
+ fi
+ iflist="${iflist}${iflist:+ }$iface"
+ done
+ echo $iflist
+}
+
# from OpenBSD installer
# Ask for a password, saving the input in $resp.