contrib/meshwizard: Add lan config, rework wan config
This commit is contained in:
parent
fa9c8e72e8
commit
f6d549b20c
6 changed files with 45 additions and 44 deletions
|
@ -20,6 +20,6 @@ for v in system wifi_device wifi_iface interface alias dhcp olsr_interface olsr_
|
|||
done
|
||||
|
||||
# read values from meshwizard
|
||||
for v in system luci_main contact community wan; do
|
||||
for v in system luci_main contact community wan lan; do
|
||||
get_var meshwizard.$v
|
||||
done
|
||||
|
|
|
@ -1,30 +1,20 @@
|
|||
#!/bin/sh
|
||||
# Add "freifunk" firewall zone
|
||||
# If wan is used for olsr then delete wan zone and all wan rules
|
||||
# If wan/lan is used for olsr then remove these networks from wan/lan zones
|
||||
# Also setup rules defined in /etc/config/freifunk and /etc/config/profile_<community>
|
||||
|
||||
. /etc/functions.sh
|
||||
. $dir/functions.sh
|
||||
|
||||
wan_is_olsr=$(uci -q get meshwizard.netconfig.wan_config)
|
||||
lan_is_olsr=$(uci -q get meshwizard.netconfig.lan_config)
|
||||
|
||||
config_load firewall
|
||||
|
||||
# Add local_restrict to wan firewall zone (if wan is not used for olsr)
|
||||
# If wan is used for olsr then remove the firewall zone wan
|
||||
handle_zonewan() {
|
||||
config_get name "$1" name
|
||||
if [ "$name" == "wan" ]; then
|
||||
if [ "$wan_is_olsr" == 1 ]; then
|
||||
uci del firewall.$1 && uci_commitverbose "WAN is used for olsr, delete firewall zone wan" firewall
|
||||
else
|
||||
uci set firewall.$1.local_restrict=1 && uci_commitverbose "Enable local_restrict for zone wan" firewall
|
||||
fi
|
||||
fi
|
||||
}
|
||||
config_foreach handle_zonewan zone
|
||||
# Rename firewall zone for freifunk if unnamed
|
||||
# If wan is used for olsr then set network for the firewall zone wan to ' ' to remove the wan interface from it, else add local restrict to it
|
||||
# If lan is used for olsr then set network for the firewall zone lan to ' ' to remove the lan interface from it
|
||||
|
||||
# Rename firewall zone for freifunk if unnamed and delete wan zone if it is used for olsr; else enable local restrict
|
||||
handle_fwzone() {
|
||||
config_get name "$1" name
|
||||
config_get network "$1" network
|
||||
|
@ -38,11 +28,15 @@ handle_fwzone() {
|
|||
|
||||
if [ "$name" == "wan" ]; then
|
||||
if [ "$wan_is_olsr" == 1 ]; then
|
||||
uci del firewall.$1 && uci_commitverbose "WAN is used for olsr, delete firewall zone wan" firewall
|
||||
uci set firewall.$1.network=' ' && uci_commitverbose "WAN is used for olsr, removed the wan interface from zone wan" firewall
|
||||
else
|
||||
uci set firewall.$1.local_restrict=1 && uci_commitverbose "Enable local_restrict for zone wan" firewall
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ "$name" == "lan" ] && [ "$lan_is_olsr" == 1 ]; then
|
||||
uci set firewall.$1.network=' ' && uci_commitverbose "LAN is used for olsr, removed the lan interface from zone lan" firewall
|
||||
fi
|
||||
}
|
||||
|
||||
config_foreach handle_fwzone zone
|
||||
|
@ -80,7 +74,7 @@ if [ -n "$LANIP" ]; then
|
|||
fi
|
||||
|
||||
currms=$(uci -q get firewall.zone_freifunk.masq_src)
|
||||
if [ ! "$no_masq_lan" == "1" ]; then
|
||||
if [ ! "$no_masq_lan" == "1" ] && [ ! "$(uci -q get meshwizard.netconfig.lan_config)" == 1 ]; then
|
||||
uci set firewall.zone_freifunk.masq="1"
|
||||
[ -z "$(echo $currms |grep lan)" ] && uci add_list firewall.zone_freifunk.masq_src="lan"
|
||||
fi
|
||||
|
@ -104,21 +98,3 @@ for config in freifunk profile_$community; do
|
|||
done
|
||||
done
|
||||
uci_commitverbose "Setup rules, forwardings, advanced config and includes." firewall
|
||||
|
||||
# If wan is used for olsr we need to cleanup old wan (forward) rules
|
||||
|
||||
if [ "$wan_is_olsr" == 1 ]; then
|
||||
handle_wanrules() {
|
||||
config_get src "$1" src
|
||||
config_get dest "$1" dest
|
||||
if [ "$src" == "wan" ] || [ "$dest" == "wan" ]; then
|
||||
uci del firewall.$1
|
||||
fi
|
||||
}
|
||||
for i in rule forwarding; do
|
||||
config_load firewall
|
||||
config_foreach handle_wanrules $i
|
||||
done
|
||||
uci_commitverbose "Wan is used for olsr, delete wan firewall rules and forwardings" firewall
|
||||
fi
|
||||
|
||||
|
|
|
@ -0,0 +1,17 @@
|
|||
#!/bin/sh
|
||||
# Setup static interface settings for lan if lan is not an olsr interface
|
||||
|
||||
[ ! "$(uci -q get network.lan)" == "interface" ] && exit
|
||||
|
||||
. /etc/functions.sh
|
||||
. $dir/functions.sh
|
||||
|
||||
uci batch << EOF
|
||||
set network.lan.proto='$lan_proto'
|
||||
set network.lan.ipaddr='$lan_ip4addr'
|
||||
set network.lan.netmask='$lan_netmask'
|
||||
EOF
|
||||
|
||||
uci_commitverbose "Setup static ip settings for lan" network
|
||||
|
||||
uci delete meshwizard.lan && uci commit meshwizard
|
|
@ -1,6 +1,6 @@
|
|||
# setup entry in /etc/config/network for a interface
|
||||
# Argument $1: network interface
|
||||
|
||||
|
||||
net="$1"
|
||||
. /etc/functions.sh
|
||||
. $dir/functions.sh
|
||||
|
@ -9,15 +9,20 @@ net="$1"
|
|||
|
||||
ipaddr=$(uci get meshwizard.netconfig.$net\_ip4addr)
|
||||
[ -z "$ipaddr" ] && msg_missing_value meshwizard $net\_ip4addr
|
||||
[ -z "$interface_netmask" ] && interface netmask="255.255.0.0"
|
||||
|
||||
netmask=$(uci -q get meshwizard.netconfig.$net\_netmask)
|
||||
[ -z "$netmask" ] && netmask="$interface_netmask"
|
||||
[ -z "$netmask" ] && netmask="255.255.0.0"
|
||||
|
||||
uci set network.$netrenamed="interface"
|
||||
set_defaults "interface_" network.$netrenamed
|
||||
|
||||
uci batch << EOF
|
||||
set network.$netrenamed="interface"
|
||||
set network.$netrenamed.proto="static"
|
||||
set network.$netrenamed.ipaddr="$ipaddr"
|
||||
set network.$netrenamed.netmask="$netmask"
|
||||
EOF
|
||||
|
||||
set_defaults "interface_" network.$netrenamed
|
||||
uci_commitverbose "Setup interface $netrenamed" network
|
||||
|
||||
# setup dhcp alias/interface
|
||||
|
@ -66,8 +71,7 @@ if [ "$net_dhcp" == 1 ]; then
|
|||
set network.${netrenamed}dhcp.proto=static
|
||||
set network.${netrenamed}dhcp.ipaddr="$START"
|
||||
set network.${netrenamed}dhcp.netmask="$NETMASK"
|
||||
uci_commitverbose "Setup interface for ${netrenamed}dhcp" network
|
||||
EOF
|
||||
uci_commitverbose "Setup interface for ${netrenamed}dhcp" network
|
||||
|
||||
fi
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@ fi
|
|||
|
||||
dhcprange=$(uci -q get meshwizard.netconfig.$net\_dhcprange)
|
||||
|
||||
if [ "$dhcp_range" == 1 ]; then
|
||||
if [ "$(uci -q get meshwizard.netconfig.$net\_dhcp)" == 1 ] && [ -n "$dhcprange" ]; then
|
||||
handle_splash() {
|
||||
config_get network "$1" network
|
||||
if [ "$network" == "${netrenamed}dhcp" ]; then
|
||||
|
|
|
@ -63,13 +63,17 @@ if [ "$wan_proto" == "static" ] && [ -n "$wan_ip4addr" ] && [ -n "$wan_netmask"
|
|||
$dir/helpers/setup_wan_static.sh
|
||||
fi
|
||||
|
||||
if [ "$lan_proto" == "static" ] && [ -n "$lan_ip4addr" ] && [ -n "$lan_netmask" ]; then
|
||||
$dir/helpers/setup_lan_static.sh
|
||||
fi
|
||||
|
||||
# Configure found networks
|
||||
for net in $networks; do
|
||||
# radioX devices need to be renamed
|
||||
netrenamed="${net/radio/wireless}"
|
||||
export netrenamed
|
||||
$dir/helpers/setup_network.sh $net
|
||||
if [ ! "$net" == "wan" ]; then
|
||||
if [ ! "$net" == "wan" ] && [ ! "$net" == "lan" ]; then
|
||||
$dir/helpers/setup_wifi.sh $net
|
||||
fi
|
||||
$dir/helpers/setup_olsrd_interface.sh $net
|
||||
|
|
Loading…
Reference in a new issue