fff-network: Remove FORCEPARSE variable

This commit is contained in:
Fabian Bläse 2021-08-08 23:03:21 +02:00
parent 7cdd32f6ca
commit 4f3b35fbf9
2 changed files with 112 additions and 130 deletions

View File

@ -24,148 +24,134 @@ else
echo "LAN0MODE='$LAN0MODE' # use BATMAN, CLIENT or WAN" >> /etc/network.config
echo "LAN1MODE='$LAN1MODE' # use BATMAN, CLIENT or WAN" >> /etc/network.config
fi
echo "FORCEPARSE='0' # Parse at: 0=first boot only, 1=every reboot, 2=next reboot (once)" >> /etc/network.config
fi
if [ "$FORCEPARSE" = '2' ] ; then
sed -i '/^FORCEPARSE/d' /etc/network.config
echo "FORCEPARSE='0' # Parse at: 0=first boot only, 1=every reboot, 2=next reboot (once)" >> /etc/network.config
FORCEPARSE='1'
fi
if [ "$ONE_PORT" = "YES" ]; then
if ! uci -q get network.$SWITCHDEV.ifname || [ "$FORCEPARSE" = '1' ] ; then
uci set network.$SWITCHDEV=interface
uci set network.$SWITCHDEV.ifname=$SWITCHDEV
if [ "$ETHMODE" = "WAN" ]; then
uci set network.client.ifname="bat0"
uci set network.wan.ifname="$WANDEV"
uci del network.ethmesh.ifname
uci del network.${SWITCHDEV}.macaddr
elif [ "$ETHMODE" = "CLIENT" ] ; then
uci set network.client.ifname="bat0 $SWITCHDEV"
uci set network.wan.ifname="eth2" #eth2 because it is default in config file
uci del network.ethmesh.ifname
uci del network.${SWITCHDEV}.macaddr
elif [ "$ETHMODE" = "BATMAN" ] ; then
uci set network.client.ifname="bat0"
uci set network.wan.ifname="eth2" #eth2 because it is default in config file
uci set network.ethmesh.ifname="$SWITCHDEV"
ETH0DEV="$SWITCHDEV"
fi
uci commit network
uci set network.$SWITCHDEV=interface
uci set network.$SWITCHDEV.ifname=$SWITCHDEV
if [ "$ETHMODE" = "WAN" ]; then
uci set network.client.ifname="bat0"
uci set network.wan.ifname="$WANDEV"
uci del network.ethmesh.ifname
uci del network.${SWITCHDEV}.macaddr
elif [ "$ETHMODE" = "CLIENT" ] ; then
uci set network.client.ifname="bat0 $SWITCHDEV"
uci set network.wan.ifname="eth2" #eth2 because it is default in config file
uci del network.ethmesh.ifname
uci del network.${SWITCHDEV}.macaddr
elif [ "$ETHMODE" = "BATMAN" ] ; then
uci set network.client.ifname="bat0"
uci set network.wan.ifname="eth2" #eth2 because it is default in config file
uci set network.ethmesh.ifname="$SWITCHDEV"
ETH0DEV="$SWITCHDEV"
fi
uci commit network
elif [ "$TWO_PORT" = "YES" ]; then
if ! uci -q get network.$WANDEV.ifname || [ "$FORCEPARSE" = '1' ] ; then
uci set network.$WANDEV=interface
uci set network.$WANDEV.ifname="$WANDEV"
uci set network.$SWITCHDEV=interface
uci set network.$SWITCHDEV.ifname="$SWITCHDEV"
# Only one WAN possible, second port will be unset if both are WAN
if [ "$LAN0MODE" = "WAN" ]; then
if [ "$LAN1MODE" = "CLIENT" ]; then
uci set network.client.ifname="bat0 $SWITCHDEV"; else
uci set network.client.ifname=bat0; fi
# WAN
uci set network.wan.ifname="$WANDEV"
if [ "$LAN1MODE" = "BATMAN" ]; then
uci set network.ethmesh.ifname="$SWITCHDEV"; else
uci del network.ethmesh.ifname; fi
# Two client ports are possible
elif [ "$LAN0MODE" = "CLIENT" ]; then
if [ "$LAN1MODE" = "CLIENT" ]; then
uci set network.client.ifname="bat0 $WANDEV $SWITCHDEV"; else
uci set network.client.ifname="bat0 $WANDEV"; fi
if [ "$LAN1MODE" = "WAN" ]; then
uci set network.wan.ifname="$SWITCHDEV"; else
uci set network.wan.ifname=eth2; fi #eth2 because it is default in config file
if [ "$LAN1MODE" = "BATMAN" ]; then
uci set network.ethmesh.ifname="$SWITCHDEV"; else
uci del network.ethmesh.ifname; fi
# Only one BATMAN port possible, second port will be unset if both are BATMAN
elif [ "$LAN0MODE" = "BATMAN" ] ; then
if [ "$LAN1MODE" = "CLIENT" ]; then
uci set network.client.ifname="bat0 $SWITCHDEV"; else
uci set network.client.ifname=bat0; fi
if [ "$LAN1MODE" = "WAN" ]; then
uci set network.wan.ifname="$SWITCHDEV"; else
uci set network.wan.ifname=eth2; fi #eth2 because it is default in config file
# BATMAN
uci set network.ethmesh.ifname="$WANDEV"
fi
if [ "$LAN0MODE" = "BATMAN" ]; then
ETH0DEV="$WANDEV" # only needed for setting macaddr
uci del network.$SWITCHDEV.macaddr
elif [ "$LAN1MODE" = "BATMAN" ]; then
# $WANDEV will win if both are set to BATMAN, as above
ETH0DEV="$SWITCHDEV" # only needed for setting macaddr
uci del network.$WANDEV.macaddr
else
uci del network.$WANDEV.macaddr
uci del network.$SWITCHDEV.macaddr
fi
uci commit network
uci set network.$WANDEV=interface
uci set network.$WANDEV.ifname="$WANDEV"
uci set network.$SWITCHDEV=interface
uci set network.$SWITCHDEV.ifname="$SWITCHDEV"
# Only one WAN possible, second port will be unset if both are WAN
if [ "$LAN0MODE" = "WAN" ]; then
if [ "$LAN1MODE" = "CLIENT" ]; then
uci set network.client.ifname="bat0 $SWITCHDEV"; else
uci set network.client.ifname=bat0; fi
# WAN
uci set network.wan.ifname="$WANDEV"
if [ "$LAN1MODE" = "BATMAN" ]; then
uci set network.ethmesh.ifname="$SWITCHDEV"; else
uci del network.ethmesh.ifname; fi
# Two client ports are possible
elif [ "$LAN0MODE" = "CLIENT" ]; then
if [ "$LAN1MODE" = "CLIENT" ]; then
uci set network.client.ifname="bat0 $WANDEV $SWITCHDEV"; else
uci set network.client.ifname="bat0 $WANDEV"; fi
if [ "$LAN1MODE" = "WAN" ]; then
uci set network.wan.ifname="$SWITCHDEV"; else
uci set network.wan.ifname=eth2; fi #eth2 because it is default in config file
if [ "$LAN1MODE" = "BATMAN" ]; then
uci set network.ethmesh.ifname="$SWITCHDEV"; else
uci del network.ethmesh.ifname; fi
# Only one BATMAN port possible, second port will be unset if both are BATMAN
elif [ "$LAN0MODE" = "BATMAN" ] ; then
if [ "$LAN1MODE" = "CLIENT" ]; then
uci set network.client.ifname="bat0 $SWITCHDEV"; else
uci set network.client.ifname=bat0; fi
if [ "$LAN1MODE" = "WAN" ]; then
uci set network.wan.ifname="$SWITCHDEV"; else
uci set network.wan.ifname=eth2; fi #eth2 because it is default in config file
# BATMAN
uci set network.ethmesh.ifname="$WANDEV"
fi
if [ "$LAN0MODE" = "BATMAN" ]; then
ETH0DEV="$WANDEV" # only needed for setting macaddr
uci del network.$SWITCHDEV.macaddr
elif [ "$LAN1MODE" = "BATMAN" ]; then
# $WANDEV will win if both are set to BATMAN, as above
ETH0DEV="$SWITCHDEV" # only needed for setting macaddr
uci del network.$WANDEV.macaddr
else
uci del network.$WANDEV.macaddr
uci del network.$SWITCHDEV.macaddr
fi
uci commit network
else
if ! uci -q get network.$SWITCHDEV > /dev/null ; then
if [ "$DSA" = "1" ]; then
uci set network.$SWITCHDEV=device
uci set network.$SWITCHDEV.name=$SWITCHDEV
uci set network.$SWITCHDEV.type=bridge
# temporary workaround for netifd bug present in OpenWrt 21.02.0 (FS#4104)
uci set network.$SWITCHDEV.bridge_empty='1'
if [ "$DSA" = "1" ]; then
uci set network.$SWITCHDEV=device
uci set network.$SWITCHDEV.name=$SWITCHDEV
uci set network.$SWITCHDEV.type=bridge
# temporary workaround for netifd bug present in OpenWrt 21.02.0 (FS#4104)
uci set network.$SWITCHDEV.bridge_empty='1'
uci set network.${SWITCHDEV}_1=bridge-vlan
uci set network.${SWITCHDEV}_1.device=$SWITCHDEV
uci set network.${SWITCHDEV}_1.vlan=1
uci set network.${SWITCHDEV}_1.ports="$CLIENT_PORTS"
uci set network.${SWITCHDEV}_1=bridge-vlan
uci set network.${SWITCHDEV}_1.device=$SWITCHDEV
uci set network.${SWITCHDEV}_1.vlan=1
uci set network.${SWITCHDEV}_1.ports="$CLIENT_PORTS"
if [ "$WANDEV" = "$SWITCHDEV" ] || ! [ -z "$WAN_PORTS" ]; then
uci set network.${SWITCHDEV}_2=bridge-vlan
uci set network.${SWITCHDEV}_2.device=$SWITCHDEV
uci set network.${SWITCHDEV}_2.vlan=2
uci set network.${SWITCHDEV}_2.ports="$WAN_PORTS"
fi
uci set network.${SWITCHDEV}_3=bridge-vlan
uci set network.${SWITCHDEV}_3.device=$SWITCHDEV
uci set network.${SWITCHDEV}_3.vlan=3
uci set network.${SWITCHDEV}_3.ports="$BATMAN_PORTS"
else
SWITCHHW=$(swconfig list | awk '{ print $4 }')
uci set network.${SWITCHDEV}_1=switch_vlan
uci set network.${SWITCHDEV}_1.device=$SWITCHHW
uci set network.${SWITCHDEV}_1.vlan=1
uci set network.${SWITCHDEV}_1.ports="$CLIENT_PORTS"
if [ "$WANDEV" = "$SWITCHDEV" ] || [ -n "$WAN_PORTS" ]; then
uci set network.${SWITCHDEV}_2=switch_vlan
uci set network.${SWITCHDEV}_2.device=$SWITCHHW
uci set network.${SWITCHDEV}_2.vlan=2
uci set network.${SWITCHDEV}_2.ports="$WAN_PORTS"
fi
uci set network.${SWITCHDEV}_3=switch_vlan
uci set network.${SWITCHDEV}_3.device=$SWITCHHW
uci set network.${SWITCHDEV}_3.vlan=3
uci set network.${SWITCHDEV}_3.ports="$BATMAN_PORTS"
if [ "$WANDEV" = "$SWITCHDEV" ] || ! [ -z "$WAN_PORTS" ]; then
uci set network.${SWITCHDEV}_2=bridge-vlan
uci set network.${SWITCHDEV}_2.device=$SWITCHDEV
uci set network.${SWITCHDEV}_2.vlan=2
uci set network.${SWITCHDEV}_2.ports="$WAN_PORTS"
fi
uci set network.client.ifname="$SWITCHDEV.1 bat0"
uci set network.${SWITCHDEV}_3=bridge-vlan
uci set network.${SWITCHDEV}_3.device=$SWITCHDEV
uci set network.${SWITCHDEV}_3.vlan=3
uci set network.${SWITCHDEV}_3.ports="$BATMAN_PORTS"
else
SWITCHHW=$(swconfig list | awk '{ print $4 }')
uci set network.ethmesh.ifname="$SWITCHDEV.3"
uci set network.${SWITCHDEV}_1=switch_vlan
uci set network.${SWITCHDEV}_1.device=$SWITCHHW
uci set network.${SWITCHDEV}_1.vlan=1
uci set network.${SWITCHDEV}_1.ports="$CLIENT_PORTS"
if [ "$WANDEV" = "$SWITCHDEV" ]; then
uci set network.wan.ifname=$WANDEV.2
else
uci set network.wan.ifname=$WANDEV
if [ "$WANDEV" = "$SWITCHDEV" ] || [ -n "$WAN_PORTS" ]; then
uci set network.${SWITCHDEV}_2=switch_vlan
uci set network.${SWITCHDEV}_2.device=$SWITCHHW
uci set network.${SWITCHDEV}_2.vlan=2
uci set network.${SWITCHDEV}_2.ports="$WAN_PORTS"
fi
uci commit network
uci set network.${SWITCHDEV}_3=switch_vlan
uci set network.${SWITCHDEV}_3.device=$SWITCHHW
uci set network.${SWITCHDEV}_3.vlan=3
uci set network.${SWITCHDEV}_3.ports="$BATMAN_PORTS"
fi
uci set network.client.ifname="$SWITCHDEV.1 bat0"
uci set network.ethmesh.ifname="$SWITCHDEV.3"
if [ "$WANDEV" = "$SWITCHDEV" ]; then
uci set network.wan.ifname=$WANDEV.2
else
uci set network.wan.ifname=$WANDEV
fi
uci commit network
fi
/etc/init.d/network restart

View File

@ -7,8 +7,6 @@ if [ "$REQUEST_METHOD" = "POST" ] ; then
if [ "$POST_change_mode" != "" ] ; then
sed -i '/^.*# set via WebUI/d' /etc/network.config
echo "ETHMODE=\"${POST_mode}\" # set via WebUI" >> /etc/network.config
sed -i '/^FORCEPARSE/d' /etc/network.config
echo "FORCEPARSE='2'" >> /etc/network.config
do_reboot=1
MSG='<span class="green">Port Modus ge&auml;ndert! Router startet neu...</span>'
fi
@ -16,8 +14,6 @@ if [ "$REQUEST_METHOD" = "POST" ] ; then
sed -i '/^.*# set via WebUI/d' /etc/network.config
echo "LAN0MODE=\"${POST_mode0}\" # set via WebUI" >> /etc/network.config
echo "LAN1MODE=\"${POST_mode1}\" # set via WebUI" >> /etc/network.config
sed -i '/^FORCEPARSE/d' /etc/network.config
echo "FORCEPARSE='2'" >> /etc/network.config
do_reboot=1
MSG='<span class="green">Port Modus ge&auml;ndert! Router startet neu...</span>'
fi