contrib/freifunk-policyrouting: use olsrd and olsrd6 configs
authorManuel Munz <freifunk@somakoma.de>
Sat, 9 Aug 2014 12:23:27 +0000 (12:23 +0000)
committerManuel Munz <freifunk@somakoma.de>
Sat, 9 Aug 2014 12:23:27 +0000 (12:23 +0000)
contrib/package/freifunk-policyrouting/files/etc/init.d/freifunk-policyrouting

index 10cb4454d538b554abb9303d1cd0117222a4f482..05a75407d8c0bdc729d4d7b8d62cd5c9cffcd2f5 100755 (executable)
@@ -6,28 +6,35 @@ START=15
 
 proto="4"
 [ -f /proc/net/ipv6_route ] && proto="4 6"
+[ -f /etc/config/olsrd ] && cfgs="olsrd"
+[ -f /etc/config/olsrd6 ] && cfgs="$cfgs olsrd6"
 
 config_load freifunk-policyrouting
 config_get enable pr enable
 config_get fallback pr fallback
 config_get zones pr zones
 
+
 olsrd_rmtables() {
-       # Remove custom routing tables from olsrd
-       if [ "`uci -q get olsrd.@olsrd[0].RtTable`" == "111" ] || [ "`uci -q get olsrd.@olsrd[0].RtTableDefault`" == "112" ]; then
-               uci delete olsrd.@olsrd[0].RtTable
-               uci delete olsrd.@olsrd[0].RtTableDefault
-               uci commit
-       fi
+       for cfg in $cfgs; do
+               # Remove custom routing tables from olsrd 
+               if [ "`uci -q get $cfg.@olsrd[0].RtTable`" == "111" ] || [ "`uci -q get $cfg.@olsrd[0].RtTableDefault`" == "112" ]; then
+                       uci delete $cfg.@olsrd[0].RtTable
+                       uci delete $cfg.@olsrd[0].RtTableDefault
+                       uci commit
+               fi
+       done
 }
 
 olsrd_intalltables() {
-       if [ ! "`uci -q get olsrd.@olsrd[0].RtTable`" == "111" ] || [ ! "`uci -q get olsrd.@olsrd[0].RtTableDefault`" == "112" ]; then
-               uci set olsrd.@olsrd[0].RtTable='111'
-               uci set olsrd.@olsrd[0].RtTableDefault='112'
-               uci commit olsrd
-               /etc/init.d/olsrd restart 2&> /dev/null
-       fi
+       for cfg in $cfgs; do
+               if [ ! "`uci -q get $cfg.@olsrd[0].RtTable`" == "111" ] || [ ! "`uci -q get $cfg.@olsrd[0].RtTableDefault`" == "112" ]; then
+                       uci set $cfg.@olsrd[0].RtTable='111'
+                       uci set $cfg.@olsrd[0].RtTableDefault='112'
+                       uci commit $cfg
+                       /etc/init.d/$cfg restart 2&> /dev/null
+               fi
+       done
 }
 
 rt_tables() {
@@ -45,26 +52,30 @@ rt_tables() {
 }
 
 disable_dyngw() {
-       dyngwlib=`uci show olsrd |grep dyn_gw.so |awk {' FS="."; print $1"."$2 '}`
-       if [ -n "$dyngwlib" ]; then
-               uci set $dyngwlib.ignore=1
-               uci commit olsrd
-       fi
+       for cfg in $cfgs; do
+               local dyngwlib=`uci show $cfg |grep dyn_gw.so |awk {' FS="."; print $1"."$2 '}`
+               if [ -n "$dyngwlib" ]; then
+                       uci set $dyngwlib.ignore=1
+                       uci commit $cfg
+               fi
 
-       dyngwplainlib=`uci show olsrd |grep dyn_gw_plain |awk {' FS="."; print $1"."$2 '}`
-       if [ -n "$dyngwplainlib" ]; then
-               rttable="$(uci -q get $dyngwplainlib.RtTable)"
-               if [ -z "$rttable" ] || [ "$rttable" = "254" ]; then 
-                       uci set $dyngwplainlib.ignore=1
-                       uci commit olsrd
+               dyngwplainlib=`uci show $cfg |grep dyn_gw_plain |awk {' FS="."; print $1"."$2 '}`
+               if [ -n "$dyngwplainlib" ]; then
+                       rttable="$(uci -q get $dyngwplainlib.RtTable)"
+                       if [ -z "$rttable" ] || [ "$rttable" = "254" ]; then 
+                               uci set $dyngwplainlib.ignore=1
+                               uci commit $cfg
+                       fi
                fi
-       fi
+       done
 }
 
 restart_services() {
        logger -s -t policyrouting -p info "Restarting services"
        /etc/init.d/network restart 2&> /dev/null
-       /etc/init.d/olsrd restart 2&> /dev/null
+       for cfg in $cfgs; do
+               /etc/init.d/$cfg restart 2&> /dev/null
+       done
 }
 
 boot() {