forked from freifunk-franken/firmware
fff-network: Make custom port configuration update-safe
This writes CLIENT/BATMAN/WAN port configurations for devices with switches to a separate file. This file can be changed based on the desired setup and is then preserved during firmware upgrade. In case of a future bugfix concerning the entries of a specific network.* file, this will still be effective as only the port configurations reside in the new file, while the other settings could be overwritten by the upgrade. For one- and two-port devices, adjustments have been made so that their relevant settings also reside in the new file now. This also adds a WebUI interface for setting the two-port devices (CPE210 and CPE510). Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de> Tested-by: Adrian Schmutzler <freifunk@adrianschmutzler.de> Reviewed-by: Tim Niemeyer <tim@tn-x.org> Signed-off-by: Tim Niemeyer <tim@tn-x.org> - Changed doc in network.mode
This commit is contained in:
parent
b0974e0afc
commit
4dbf136a31
|
@ -1,7 +1,7 @@
|
||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=fff-network
|
PKG_NAME:=fff-network
|
||||||
PKG_VERSION:=0.0.7
|
PKG_VERSION:=8
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=1
|
||||||
|
|
||||||
PKG_BUILD_DIR:=$(BUILD_DIR)/fff-network
|
PKG_BUILD_DIR:=$(BUILD_DIR)/fff-network
|
||||||
|
|
|
@ -8,20 +8,5 @@ ETHMESHMAC="w2ap"
|
||||||
|
|
||||||
. /etc/network.mode
|
. /etc/network.mode
|
||||||
|
|
||||||
#LAN0: default: BATMAN
|
LAN0PORT=5
|
||||||
if [ "${LAN0MODE}" = "BATMAN" ] ; then
|
LAN1PORT=4
|
||||||
BATMAN_PORTS="${BATMAN_PORTS} 5"
|
|
||||||
elif [ "${LAN0MODE}" = "CLIENT" ] ; then
|
|
||||||
CLIENT_PORTS="${CLIENT_PORTS} 5"
|
|
||||||
else
|
|
||||||
WAN_PORTS="${WAN_PORTS} 5"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#LAN1: default: BATMAN
|
|
||||||
if [ "${LAN1MODE}" = "WAN" ] ; then
|
|
||||||
WAN_PORTS="${WAN_PORTS} 4"
|
|
||||||
elif [ "${LAN1MODE}" = "CLIENT" ] ; then
|
|
||||||
CLIENT_PORTS="${CLIENT_PORTS} 4"
|
|
||||||
else
|
|
||||||
BATMAN_PORTS="${BATMAN_PORTS} 4"
|
|
||||||
fi
|
|
||||||
|
|
|
@ -8,20 +8,5 @@ ETHMESHMAC="w2ap"
|
||||||
|
|
||||||
. /etc/network.mode
|
. /etc/network.mode
|
||||||
|
|
||||||
#LAN0: default: BATMAN
|
LAN0PORT=5
|
||||||
if [ "${LAN0MODE}" = "BATMAN" ] ; then
|
LAN1PORT=4
|
||||||
BATMAN_PORTS="${BATMAN_PORTS} 5"
|
|
||||||
elif [ "${LAN0MODE}" = "CLIENT" ] ; then
|
|
||||||
CLIENT_PORTS="${CLIENT_PORTS} 5"
|
|
||||||
else
|
|
||||||
WAN_PORTS="${WAN_PORTS} 5"
|
|
||||||
fi
|
|
||||||
|
|
||||||
#LAN1: default: BATMAN
|
|
||||||
if [ "${LAN1MODE}" = "WAN" ] ; then
|
|
||||||
WAN_PORTS="${WAN_PORTS} 4"
|
|
||||||
elif [ "${LAN1MODE}" = "CLIENT" ] ; then
|
|
||||||
CLIENT_PORTS="${CLIENT_PORTS} 4"
|
|
||||||
else
|
|
||||||
BATMAN_PORTS="${BATMAN_PORTS} 4"
|
|
||||||
fi
|
|
||||||
|
|
|
@ -1,19 +1,12 @@
|
||||||
WANDEV=eth0
|
WANDEV=eth0
|
||||||
SWITCHDEV=eth1
|
SWITCHDEV=eth1
|
||||||
WAN_PORTS=
|
WAN_PORTS=
|
||||||
|
BATMAN_PORTS="0t"
|
||||||
|
CLIENT_PORTS="0t"
|
||||||
|
|
||||||
ETHMESHMAC=eth1
|
ETHMESHMAC=eth1
|
||||||
ROUTERMAC=eth0
|
ROUTERMAC=eth0
|
||||||
|
|
||||||
. /etc/network.mode
|
. /etc/network.mode
|
||||||
|
|
||||||
if [ "$ETHMODE" = "CLIENT" ] ; then
|
ETHPORT=1
|
||||||
## Activate Client:
|
|
||||||
CLIENT_PORTS="1 0t"
|
|
||||||
BATMAN_PORTS="0t"
|
|
||||||
else
|
|
||||||
## Activate BATMAN:
|
|
||||||
BATMAN_PORTS="1 0t"
|
|
||||||
CLIENT_PORTS="0t"
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@
|
||||||
## This file is used to configure the behavior of network interfaces
|
## This file is used to configure the behavior of network interfaces
|
||||||
## if the routers interfaces differ from the standard WAN+4LAN-Ports
|
## if the routers interfaces differ from the standard WAN+4LAN-Ports
|
||||||
## +2Wireless APs.
|
## +2Wireless APs.
|
||||||
## If you want to change their behavior, you can do so below.
|
## If you want to change their behavior, you should edit the file
|
||||||
|
## /etc/network.config
|
||||||
## After that you have to reboot the router with following command.
|
## After that you have to reboot the router with following command.
|
||||||
#reboot
|
#reboot
|
||||||
#
|
#
|
||||||
|
|
|
@ -12,6 +12,61 @@
|
||||||
BOARD="$(uci get board.model.name)"
|
BOARD="$(uci get board.model.name)"
|
||||||
. /etc/network.$BOARD
|
. /etc/network.$BOARD
|
||||||
|
|
||||||
|
if [ -s /etc/network.config ] ; then
|
||||||
|
. /etc/network.config
|
||||||
|
else
|
||||||
|
echo "CLIENT_PORTS='$CLIENT_PORTS'" > /etc/network.config
|
||||||
|
echo "BATMAN_PORTS='$BATMAN_PORTS'" >> /etc/network.config
|
||||||
|
if [ -n "$WAN_PORTS" ] ; then
|
||||||
|
echo "WAN_PORTS='$WAN_PORTS'" >> /etc/network.config
|
||||||
|
fi
|
||||||
|
if [ "$ONE_PORT" = "YES" ] || [ -n "$ETHPORT" ] ; then
|
||||||
|
echo "ETHMODE='$ETHMODE' # use BATMAN, CLIENT or WAN" >> /etc/network.config
|
||||||
|
fi
|
||||||
|
if [ -n "$LAN0PORT" ] ; then
|
||||||
|
echo "LAN0MODE='$LAN0MODE' # use BATMAN, CLIENT or WAN" >> /etc/network.config
|
||||||
|
fi
|
||||||
|
if [ -n "$LAN1PORT" ] ; then
|
||||||
|
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 [ -n "$ETHPORT" ] ; then
|
||||||
|
#LAN@AR150: default: BATMAN
|
||||||
|
if [ "${ETHMODE}" = "BATMAN" ] ; then
|
||||||
|
BATMAN_PORTS="${BATMAN_PORTS} ${ETHPORT}"
|
||||||
|
else
|
||||||
|
CLIENT_PORTS="${CLIENT_PORTS} ${ETHPORT}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ -n "$LAN0PORT" ] ; then
|
||||||
|
#LAN0@two-port: default: BATMAN
|
||||||
|
if [ "${LAN0MODE}" = "BATMAN" ] ; then
|
||||||
|
BATMAN_PORTS="${BATMAN_PORTS} ${LAN0PORT}"
|
||||||
|
elif [ "${LAN0MODE}" = "CLIENT" ] ; then
|
||||||
|
CLIENT_PORTS="${CLIENT_PORTS} ${LAN0PORT}"
|
||||||
|
else
|
||||||
|
WAN_PORTS="${WAN_PORTS} ${LAN0PORT}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
if [ -n "$LAN1PORT" ] ; then
|
||||||
|
#LAN1@two-port: default: BATMAN
|
||||||
|
if [ "${LAN1MODE}" = "WAN" ] ; then
|
||||||
|
WAN_PORTS="${WAN_PORTS} ${LAN1PORT}"
|
||||||
|
elif [ "${LAN1MODE}" = "CLIENT" ] ; then
|
||||||
|
CLIENT_PORTS="${CLIENT_PORTS} ${LAN1PORT}"
|
||||||
|
else
|
||||||
|
BATMAN_PORTS="${BATMAN_PORTS} ${LAN1PORT}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
if ! uci -q get network.$SWITCHDEV > /dev/null || [ "$FORCEPARSE" = '1' ] ; then
|
if ! uci -q get network.$SWITCHDEV > /dev/null || [ "$FORCEPARSE" = '1' ] ; then
|
||||||
|
|
||||||
SWITCHHW=$(swconfig list | awk '{ print $4 }')
|
SWITCHHW=$(swconfig list | awk '{ print $4 }')
|
||||||
|
|
|
@ -7,6 +7,6 @@ cat > /etc/sysupgrade.conf <<-__EOF__
|
||||||
/etc/dropbear/dropbear_dss_host_key
|
/etc/dropbear/dropbear_dss_host_key
|
||||||
/etc/dropbear/dropbear_rsa_host_key
|
/etc/dropbear/dropbear_rsa_host_key
|
||||||
/etc/dropbear/authorized_keys
|
/etc/dropbear/authorized_keys
|
||||||
/etc/network.mode
|
/etc/network.config
|
||||||
/etc/config/system
|
/etc/config/system
|
||||||
__EOF__
|
__EOF__
|
||||||
|
|
|
@ -1,18 +1,32 @@
|
||||||
#!/usr/bin/haserl
|
#!/usr/bin/haserl
|
||||||
|
|
||||||
<%
|
<%
|
||||||
|
board_name=$(uci -q get board.model.name)
|
||||||
# write
|
# write
|
||||||
if [ "$REQUEST_METHOD" == "POST" ] ; then
|
if [ "$REQUEST_METHOD" == "POST" ] ; then
|
||||||
sed -i '/^.*# set via WebUI/d' /etc/network.mode
|
if [ "$POST_change_mode" != "" ] ; then
|
||||||
echo "ETHMODE=\"${POST_mode}\" # set via WebUI" >> /etc/network.mode
|
sed -i '/^.*# set via WebUI/d' /etc/network.config
|
||||||
do_reboot=1
|
echo "ETHMODE=\"${POST_mode}\" # set via WebUI" >> /etc/network.config
|
||||||
MSG='<span class="green">Port Modus geändert! Router startet neu...</span>'
|
sed -i '/^FORCEPARSE/d' /etc/network.config
|
||||||
|
echo "FORCEPARSE='2'" >> /etc/network.config
|
||||||
|
do_reboot=1
|
||||||
|
MSG='<span class="green">Port Modus geändert! Router startet neu...</span>'
|
||||||
|
fi
|
||||||
|
if [ "$POST_change_twoport" != "" ] ; 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ändert! Router startet neu...</span>'
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
%>
|
%>
|
||||||
<%in /www/ssl/cgi-bin/header %>
|
<%in /www/ssl/cgi-bin/header %>
|
||||||
<%in /www/ssl/cgi-bin/helpers %>
|
<%in /www/ssl/cgi-bin/helpers %>
|
||||||
<% show_msg %>
|
<% show_msg %>
|
||||||
<form method="POST">
|
<form method="post">
|
||||||
<table style="width: 100%;">
|
<table style="width: 100%;">
|
||||||
<% if swconfig list | grep -q switch0 ; then %>
|
<% if swconfig list | grep -q switch0 ; then %>
|
||||||
<%# Device has a switch %>
|
<%# Device has a switch %>
|
||||||
|
@ -53,10 +67,11 @@ fi
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<% fi %>
|
<% fi %>
|
||||||
<% if grep -q network.mode /etc/network.$(uci -q get board.model.name) ; then %>
|
<% if grep -q "ONE_PORT" "/etc/network.$board_name" || grep -q "ETHPORT" "/etc/network.$board_name" ; then %>
|
||||||
<%
|
<%
|
||||||
# Device has only one or two ports and makes use of /etc/network.mode
|
# Device has a port set by $ETHMODE
|
||||||
. /etc/network.mode
|
. /etc/network.mode
|
||||||
|
. /etc/network.config
|
||||||
%>
|
%>
|
||||||
<tr><td>
|
<tr><td>
|
||||||
<fieldset>
|
<fieldset>
|
||||||
|
@ -66,9 +81,11 @@ fi
|
||||||
<th style="width: 1em;">Anschluss Modus:</th>
|
<th style="width: 1em;">Anschluss Modus:</th>
|
||||||
<td>
|
<td>
|
||||||
<select name="mode">
|
<select name="mode">
|
||||||
<option value="WAN" <% [ "$ETHMODE" == "WAN" ] && echo -n selected %>>WAN</option>
|
<option value="BATMAN" <% [ "$ETHMODE" == "BATMAN" ] && echo -n 'selected="selected" ' %>>BATMAN</option>
|
||||||
<option value="CLIENT" <% [ "$ETHMODE" == "CLIENT" ] && echo -n selected %>>Client</option>
|
<option value="CLIENT" <% [ "$ETHMODE" == "CLIENT" ] && echo -n 'selected="selected" ' %>>CLIENT</option>
|
||||||
<option value="BATMAN" <% [ "$ETHMODE" == "BATMAN" ] && echo -n selected %>>BATMAN</option>
|
<% if grep -q "ONE_PORT" "/etc/network.$board_name" ; then %>
|
||||||
|
<option value="WAN" <% [ "$ETHMODE" == "WAN" ] && echo -n 'selected="selected" ' %>>WAN</option>
|
||||||
|
<% fi %>
|
||||||
</select>
|
</select>
|
||||||
</td>
|
</td>
|
||||||
</tr>
|
</tr>
|
||||||
|
@ -87,6 +104,52 @@ fi
|
||||||
</fieldset>
|
</fieldset>
|
||||||
</td></tr>
|
</td></tr>
|
||||||
<% fi %>
|
<% fi %>
|
||||||
|
<% if grep -q "LAN0PORT" "/etc/network.$board_name" || grep -q "LAN1PORT" "/etc/network.$board_name" ; then %>
|
||||||
|
<%
|
||||||
|
# Device has two ports
|
||||||
|
. /etc/network.mode
|
||||||
|
. /etc/network.config
|
||||||
|
%>
|
||||||
|
<tr><td>
|
||||||
|
<fieldset>
|
||||||
|
<legend>Ethernet Anschlüsse</legend>
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<th style="width: 15em;text-align:left">Modus Anschluss 0:</th>
|
||||||
|
<th style="width: 15em;text-align:left">Modus Anschluss 1:</th>
|
||||||
|
<th></th>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>
|
||||||
|
<select name="mode0">
|
||||||
|
<option value="BATMAN" <% [ "$LAN0MODE" == "BATMAN" ] && echo -n 'selected="selected" ' %>>BATMAN</option>
|
||||||
|
<option value="CLIENT" <% [ "$LAN0MODE" == "CLIENT" ] && echo -n 'selected="selected" ' %>>CLIENT</option>
|
||||||
|
<option value="WAN" <% [ "$LAN0MODE" == "WAN" ] && echo -n 'selected="selected" ' %>>WAN</option>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
<td>
|
||||||
|
<select name="mode1">
|
||||||
|
<option value="BATMAN" <% [ "$LAN1MODE" == "BATMAN" ] && echo -n 'selected="selected" ' %>>BATMAN</option>
|
||||||
|
<option value="CLIENT" <% [ "$LAN1MODE" == "CLIENT" ] && echo -n 'selected="selected" ' %>>CLIENT</option>
|
||||||
|
<option value="WAN" <% [ "$LAN1MODE" == "WAN" ] && echo -n 'selected="selected" ' %>>WAN</option>
|
||||||
|
</select>
|
||||||
|
</td>
|
||||||
|
<td><input type="submit" name="change_twoport" /></td>
|
||||||
|
</tr>
|
||||||
|
<tr><td colspan="3"></td></tr>
|
||||||
|
<tr><td colspan="3">
|
||||||
|
WAN: Knoten stellt über Ethernet Anschluss Verbindung zum Internet her.<br />
|
||||||
|
Client: Normale Clients stellen über Ethernet Anschluss des Knotens Verbindung zum Freifunk Netz her.<br />
|
||||||
|
BATMAN: Knoten stellt über Ethernet Anschluss Verbindung zu anderen MESH Knoten her.<br /><br />
|
||||||
|
|
||||||
|
Wenn diese Einstellung verändert wird, wird eine evtl. vorhandene manuelle Netzwerkkonfiguration in der
|
||||||
|
<tt>/etc/config/network</tt> überschrieben.<br />
|
||||||
|
Anschließend wird der Router neugestartet.
|
||||||
|
</td></tr>
|
||||||
|
</table>
|
||||||
|
</fieldset>
|
||||||
|
</td></tr>
|
||||||
|
<% fi %>
|
||||||
</table>
|
</table>
|
||||||
</form>
|
</form>
|
||||||
<%in /www/ssl/cgi-bin/footer %>
|
<%in /www/ssl/cgi-bin/footer %>
|
||||||
|
|
Loading…
Reference in New Issue