Commit 3638145a authored by Natanael Copa's avatar Natanael Copa
Browse files

setup-interfaces: be more verbose on what ports are already added to bridge

parent 80387939
...@@ -88,7 +88,7 @@ To add this interface to a bridge enter the bridge name (eg 'br0' or 'bridge0') ...@@ -88,7 +88,7 @@ To add this interface to a bridge enter the bridge name (eg 'br0' or 'bridge0')
__EOF__ __EOF__
} }
bridge_add_iface() { bridge_add_port() {
local bridge=$1 iface= local bridge=$1 iface=
shift shift
for iface; do for iface; do
...@@ -98,6 +98,12 @@ bridge_add_iface() { ...@@ -98,6 +98,12 @@ bridge_add_iface() {
done done
} }
bridge_list_ports() {
if [ -r $1.bridge_ports ]; then
echo $(cat $1.bridge_ports)
fi
}
config_iface() { config_iface() {
local iface=$1 local iface=$1
local prefix=$2 local prefix=$2
...@@ -117,7 +123,7 @@ config_iface() { ...@@ -117,7 +123,7 @@ config_iface() {
if [ "$resp" = "yes" ]; then if [ "$resp" = "yes" ]; then
bridge="br"`echo $iface | sed 's/[^0-9]//g'` bridge="br"`echo $iface | sed 's/[^0-9]//g'`
ask "Name of the bridge you want add $iface to:" $bridge ask "Name of the bridge you want add $iface to:" $bridge
bridge_add_iface $resp $iface bridge_add_port $resp $iface
return return
fi fi
...@@ -146,7 +152,7 @@ config_iface() { ...@@ -146,7 +152,7 @@ config_iface() {
# we dont allow bridge bridges # we dont allow bridge bridges
br[0-9]*|bridge[0-9]*) continue;; br[0-9]*|bridge[0-9]*) continue;;
esac esac
bridge_add_iface $resp $iface bridge_add_port $resp $iface
return ;; return ;;
esac esac
done done
...@@ -216,21 +222,27 @@ unconfigured_all_are() { ...@@ -216,21 +222,27 @@ unconfigured_all_are() {
} }
config_bridge() { config_bridge() {
local bridge=$1 iflist= local bridge=$1 iflist= i= ports=
while ! unconfigured_all_done; do while ! unconfigured_all_done; do
set -- $(unconfigured_non_bridges) set -- $(unconfigured_non_bridges)
[ $# -eq 0 ] && return 0; [ $# -eq 0 ] && return 0;
ports=$(bridge_list_ports $bridge)
if [ -n "$ports" ]; then
echo "Bridge ports in $bridge are: $ports"
fi
echo "Available bridge ports are: $@" echo "Available bridge ports are: $@"
ask "Which port(s) do you want add to bridge $bridge? (or 'done')" $1 ask "Which port(s) do you want add to bridge $bridge? (or 'done')" $1
case $resp in case $resp in
'abort') return 1;; 'abort') return 1;;
'done') return 0;; 'done') return 0;;
esac esac
if unconfigured_all_are $resp; then for i in $resp; do
bridge_add_iface $bridge $resp if unconfigured_isin $i; then
continue bridge_add_port $bridge $i
fi else
echo "$resp is not a valid interface" echo "$i is not valid"
fi
done
done 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