contrib/imagebuilder: Cleanups, seperate basic and network config of firewall and...
[project/luci.git] / contrib / package / meshwizard / files / usr / bin / meshwizard / helpers / setup_olsrd_interface.sh
1 #!/bin/sh
2 # Sets up olsrd interfaces
3 # arg $1 = net
4
5 net=$1
6
7 . /etc/functions.sh
8 . $dir/functions.sh
9
10 # Rename interface for $netrenamed
11 handle_interface() {
12 config_get interface "$1" Interface
13 if [ "$interface" == "$netrenamed" ]; then
14 if [ -z "${1/cfg[0-9a-fA-F]*/}" ]; then
15 section_rename olsrd $1 $netrenamed
16 fi
17 fi
18 }
19
20 config_foreach handle_interface Interface
21
22 # Setup new interface for $netrenamed
23
24 uci set olsrd.$netrenamed=Interface
25 set_defaults "olsr_interface_" olsrd.$net
26 uci set olsrd.$netrenamed.interface="$netrenamed"
27
28 uci_commitverbose "Setup olsr interface for $netrenamed." olsrd
29
30 # If dhcp-network is inside the mesh_network then add HNA for it
31 dhcprange=$(uci -q get meshwizard.netconfig.$net\_dhcprange)
32
33 uci -q delete olsrd.${netrenamed}clients
34
35 # check if the dhcprange is inside meshnet
36
37 if [ "$dhcp_range" == 1 ]; then
38 dhcpinmesh="$($dir/helpers/check-range-in-range.sh $dhcprange $meshnet)"
39 meshnet="$(uci get profile_$community.profile.mesh_network)"
40
41 # If it is setup hna for it
42 if [ "$dhcpinmesh" == 1 ]; then
43 uci set olsrd.${netrenamed}clients="Hna4"
44 eval $(sh $dir/helpers/ipcalc-cidr.sh $dhcprange)
45 uci set olsrd.${netrenamed}clients.netaddr="$NETWORK"
46 uci set olsrd.${netrenamed}clients.netmask="$NETMASK"
47 uci_commitverbose "Setup HNA for network $dhcprange" olsrd
48 fi
49 fi
50