Commit 7c72655b authored by Natanael Copa's avatar Natanael Copa
Browse files

setup-interfaces: configure bridge from interface question

parent 012623f7
......@@ -193,6 +193,47 @@ config_iface() {
unconfigured_del $iface
}
is_bridge() {
[ -e /sys/class/net/$1/bridge ] || [ -e $i.bridge_ports ]
}
unconfigured_non_bridges() {
local local i= iflist=
for i in $(unconfigured_list); do
if ! is_bridge $i; then
iflist="${iflist}${iflist:+ }$i"
fi
done
echo $iflist
}
unconfigured_all_are() {
local i=
for i; do
unconfigured_isin $i || return 1
done
return 0
}
config_bridge() {
local bridge=$1 iflist=
while ! unconfigured_all_done; do
set -- $(unconfigured_non_bridges)
[ $# -eq 0 ] && return 0;
echo "Available interfaces are: $@"
ask "Which interface(s) do you want add to bridge $bridge? (or 'done')" $1
case $resp in
'abort') return 1;;
'done') return 0;;
esac
if unconfigured_all_are $resp; then
bridge_add_iface $bridge $resp
continue
fi
echo "$resp is not a valid interface"
done
}
usage() {
cat <<__EOF__
usage: setup-interfaces [-bhi] [-p ROOT]
......@@ -221,8 +262,12 @@ prompt_for_interfaces() {
$(unconfigured_get_first)
iface=$resp
[ "$iface" = "done" ] && break
unconfigured_isin $iface || continue
case "$iface" in
"done") break;;
br[0-9]*|bridge[0-9]*|virbr[0-9]*)
config_bridge $iface || continue;;
*) unconfigured_isin $iface || continue;;
esac
config_iface $iface $(printf "%.3d~" $index)
index=$(( $index + 1 ))
done
......
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