firmware/src/packages/fff/fff-layer3-config/files/etc/layer3.d/30-network-client
Adrian Schmutzler f9a68be465 packages/fff: move config scripts to fff-layer3-config
configuregateway and it's gateway.d files represent a specific
functionality that other packages depend on. Thus, it is put into
a package of its own so dependencies can be expressed more properly.

While at, use the chance to get rid of the ambiguous term "gateway"
and rename the script to configure-layer3 and the folders to layer3.d.

Signed-off-by: Adrian Schmutzler <freifunk@adrianschmutzler.de>
Reviewed-by: Christian Dresel <freifunk@dresel.systems>
2020-12-17 15:38:20 +01:00

72 lines
1.8 KiB
Plaintext

# load board specific properties
BOARD="$(uci get board.model.name)"
. /etc/network.$BOARD
configure() {
# ipaddr
#remove old ipaddr
uci -q del network.mesh.ipaddr
#set new ipaddr
if ipaddr=$(uci -q get gateway.@client[0].ipaddr); then
for ip in $ipaddr; do
uci add_list network.mesh.ipaddr=$ip
done
else
echo "WARNING: No client ipaddr set!"
fi
#put interface routes from set addresses into fff table
uci set network.mesh.ip4table='fff'
# ip6addr
#remove old ip6addr
for ip in $(uci get network.mesh.ip6addr); do
if echo "$ip" | grep -v -e "fdff:" -e "fe80::1/64" > /dev/null; then
uci del_list network.mesh.ip6addr="$ip"
fi
done
#set new ip6addr
if ip6addr=$(uci -q get gateway.@client[0].ip6addr); then
for ip in $ip6addr; do
uci add_list network.mesh.ip6addr=$ip
done
else
echo "WARNING: No client ip6addr set!"
fi
#put interface routes from set addresses into fff table
uci set network.mesh.ip6table='fff'
# dhcp
uci -q del dhcp.mesh.start
uci -q del dhcp.mesh.limit
if dhcp_start=$(uci -q get gateway.@client[0].dhcp_start); then
uci set dhcp.mesh=dhcp
uci set dhcp.mesh.interface=mesh
uci set dhcp.mesh.start=$dhcp_start
uci set dhcp.mesh.limit=$(uci -q get gateway.@client[0].dhcp_limit)
else
echo "WARNING: No DHCP range start and/or limit set!"
fi
# set interface
#remove all eth interfaces
ifaces=$(uci get network.mesh.ifname | sed 's/\beth[^ ]* *//g')
if vlan=$(uci -q get gateway.@client[0].vlan); then
uci set network.mesh.ifname="${SWITCHDEV}.$vlan $ifaces"
elif iface=$(uci -q get gateway.@client[0].iface); then
uci set network.mesh.ifname="$iface $ifaces"
else
echo "WARNING: No Interface for client specified"
fi
}
apply() {
uci commit network
uci commit dhcp
}
revert() {
uci revert network
uci revert dhcp
}