Artyom A Anikeev

slave protection was added

Showing 1 changed file with 42 additions and 29 deletions
... ... @@ -274,7 +274,8 @@ case "$CMD" in
#REMOVING UNNECESSARY BRIDGES AND VLANS
LINE_NUM=3;#skip lo, etc.
LINE_NUM=1;
#LINE_NUM=3;#skip lo, etc. Not necessary due to grep master
#LINE="`pwd | awk '{ printf $1 }'`"
LINE="`ip link show | grep master | awk '{ if (NR=="'"$LINE_NUM"'") printf $2 $9 "\n"}' | sed -e 's/@.*:/:/g'`"
##
... ... @@ -289,42 +290,54 @@ case "$CMD" in
echo "BRNAME $BRNAME"
echo "VLANNAME $VLANNAME"
##
let "LINE_NUM += 1";
LINE="`ip link show | grep master | awk '{ if (NR=="'"$LINE_NUM"'") printf $2 $9 "\n"}' | sed -e 's/@.*:/:/g'`"
IS_SLAVE=0
for D1Q_IFACE_TMP in ${D1Q_IFACES[@]}; do #we should keep slave ifaces
SLAVES_VARIABLE_TMP="${D1Q_IFACE_TMP}_SLAVES"
SLAVES_VARIABLE_TMP="${SLAVES_VARIABLE_TMP//[.]/_}[@]"
for SLAVE_TMP in "${!SLAVES_VARIABLE_TMP}"; do
if [[ "$SLAVE_TMP" == "$VLANNAME" ]]; then
IS_SLAVE=1
break;
fi
done
done
if [[ "$IS_SLAVE" = 0 ]]; then
BRIDGE_IN_USE=0
VLAN_IN_USE=0
VLAN_N_BRIDGE_IN_USE=0
BRIDGE_IN_USE=0
VLAN_IN_USE=0
VLAN_N_BRIDGE_IN_USE=0
for VLAN_N_BRIDGE in "${!VLAN_N_BRIDGE_VARIABLE}"; do
parse_vlan_subvlan_bridge "${VLAN_N_BRIDGE}"
if [[ "$LINE" = "$VLAN_N_BRIDGE" ]]; then
BRIDGE_IN_USE=1
VLAN_IN_USE=1
VLAN_N_BRIDGE_IN_USE=1
for VLAN_N_BRIDGE in "${!VLAN_N_BRIDGE_VARIABLE}"; do
parse_vlan_subvlan_bridge "${VLAN_N_BRIDGE}"
if [[ "$LINE" = "$VLAN_N_BRIDGE" ]]; then
BRIDGE_IN_USE=1
VLAN_IN_USE=1
VLAN_N_BRIDGE_IN_USE=1
elif [[ "$BRNAME" = "$OLD_BRNAME" ]]; then
BRIDGE_IN_USE=1
elif [[ "$BRNAME" = "$OLD_BRNAME" ]]; then
BRIDGE_IN_USE=1
elif [[ "$VLANNAME" = "$OLD_VLANNAME" ]]; then
VLAN_IN_USE=1
elif [[ "$VLANNAME" = "$OLD_VLANNAME" ]]; then
VLAN_IN_USE=1
fi
done
if [[ "$VLAN_N_BRIDGE_IN_USE" = 0 ]]; then
echo "ip link set $OLD_VLANNAME nomaster"
fi
if [[ "$VLAN_IN_USE" = 0 ]]; then
echo "ip link delete $OLD_VLANNAME"
fi
if [[ "$BRIDGE_IN_USE" = 0 ]]; then
echo "ip link delete $OLD_BRNAME"
fi
done
if [[ "$VLAN_N_BRIDGE_IN_USE" = 0 ]]; then
echo "ip link set $OLD_VLANNAME nomaster"
fi
if [[ "$VLAN_IN_USE" = 0 ]]; then
echo "ip link delete $OLD_VLANNAME"
fi
if [[ "$BRIDGE_IN_USE" = 0 ]]; then
echo "ip link delete $OLD_BRNAME"
fi
let "LINE_NUM += 1";
LINE="`ip link show | grep master | awk '{ if (NR=="'"$LINE_NUM"'") printf $2 $9 "\n"}' | sed -e 's/@.*:/:/g'`"
##
echo "LINE $LINE"
##
done
#CREATING OF NECESSARY BRIDGES AND VLANS
... ...