batman-adv: Fix uci commit target
[feed/routing.git] / batman-adv / files / etc / uci-defaults / 99-migrate-batadv_hardif
1 #!/bin/sh
2
3 # This UCI-Defaults script will split the batadv proto network interfaces
4 # in batadv_hardif and batadv proto. The configuration options from
5 # /etc/config/batman-adv will be moved to the latter.
6
7 . /lib/functions.sh
8
9 proto_batadv_to_batadv_hardif() {
10 local section="$1"
11 local proto
12 local mesh
13 local routing_algo
14
15 config_get proto "${section}" proto
16 config_get mesh "${section}" mesh
17 config_get routing_algo "${section}" routing_algo
18
19 if [ -z "$mesh" -o "${proto}" != "batadv" ]; then
20 continue
21 fi
22
23 uci set network."${section}".proto="batadv_hardif"
24 uci rename network."${section}".mesh="master"
25 uci delete network."${section}".routing_algo
26
27 # create new section or adjust existing one
28 uci set network."${mesh}"=interface
29 uci set network."${mesh}".proto=batadv
30 [ -n "${routing_algo}" ] && uci set network."${mesh}".routing_algo="${routing_algo}"
31 }
32
33 mv_batadv_config_section() {
34 local section="$1"
35 local aggregated_ogms
36 local ap_isolation
37 local bonding
38 local bridge_loop_avoidance
39 local distributed_arp_table
40 local fragmentation
41 local gw_bandwidth
42 local gw_mode
43 local gw_sel_class
44 local hop_penalty
45 local isolation_mark
46 local log_level
47 local multicast_mode
48 local network_coding
49 local orig_interval
50
51 config_get aggregated_ogms "${section}" aggregated_ogms
52 config_get ap_isolation "${section}" ap_isolation
53 config_get bonding "${section}" bonding
54 config_get bridge_loop_avoidance "${section}" bridge_loop_avoidance
55 config_get distributed_arp_table "${section}" distributed_arp_table
56 config_get fragmentation "${section}" fragmentation
57 config_get gw_bandwidth "${section}" gw_bandwidth
58 config_get gw_mode "${section}" gw_mode
59 config_get gw_sel_class "${section}" gw_sel_class
60 config_get hop_penalty "${section}" hop_penalty
61 config_get isolation_mark "${section}" isolation_mark
62 config_get log_level "${section}" log_level
63 config_get multicast_mode "${section}" multicast_mode
64 config_get network_coding "${section}" network_coding
65 config_get orig_interval "${section}" orig_interval
66
67 # update section in case it exists
68 [ -n "${aggregated_ogms}" ] && uci set network."${section}".aggregated_ogms="${aggregated_ogms}"
69 [ -n "${ap_isolation}" ] && uci set network."${section}".ap_isolation="${ap_isolation}"
70 [ -n "${bonding}" ] && uci set network."${section}".bonding="${bonding}"
71 [ -n "${bridge_loop_avoidance}" ] && uci set network."${section}".bridge_loop_avoidance="${bridge_loop_avoidance}"
72 [ -n "${distributed_arp_table}" ] && uci set network."${section}".distributed_arp_table="${distributed_arp_table}"
73 [ -n "${fragmentation}" ] && uci set network."${section}".fragmentation="${fragmentation}"
74 [ -n "${gw_bandwidth}" ] && uci set network."${section}".gw_bandwidth="${gw_bandwidth}"
75 [ -n "${gw_mode}" ] && uci set network."${section}".gw_mode="${gw_mode}"
76 [ -n "${gw_sel_class}" ] && uci set network."${section}".gw_sel_class="${gw_sel_class}"
77 [ -n "${hop_penalty}" ] && uci set network."${section}".hop_penalty="${hop_penalty}"
78 [ -n "${isolation_mark}" ] && uci set network."${section}".isolation_mark="${isolation_mark}"
79 [ -n "${log_level}" ] && uci set network."${section}".log_level="${log_level}"
80 [ -n "${multicast_mode}" ] && uci set network."${section}".multicast_mode="${multicast_mode}"
81 [ -n "${network_coding}" ] && uci set network."${section}".network_coding="${network_coding}"
82 [ -n "${orig_interval}" ] && uci set network."${section}".orig_interval="${orig_interval}"
83 }
84
85 if [ -f /etc/config/batman-adv ]; then
86 config_load network
87 config_foreach proto_batadv_to_batadv_hardif 'interface'
88 uci commit network
89
90 config_load batman-adv
91 config_foreach mv_batadv_config_section 'mesh'
92 uci commit network
93
94 rm -f /etc/config/batman-adv
95 fi
96
97 exit 0