Commit 2e2c8e52 authored by Natanael Copa's avatar Natanael Copa

libalpine: add available_ifaces

a sorted list of available network interfaces thats not a part of
any bridge or bond
parent e18c8a75
......@@ -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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment