summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rwxr-xr-xsetup-interfaces.in49
1 files changed, 47 insertions, 2 deletions
diff --git a/setup-interfaces.in b/setup-interfaces.in
index c3bff78..78b9113 100755
--- a/setup-interfaces.in
+++ b/setup-interfaces.in
@@ -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