luci-app-olsrd2: upgrade uci-defaults for ucitrack handling to use json
[feed/routing.git] / cjdns / files / cjdns.defaults
index f6ca7720ed57db0aef9a793681e0ece0892eb0b5..04e9ceb4f4c903cd12b9685bd3b9364c78b87440 100644 (file)
@@ -4,47 +4,34 @@
 uci get cjdns.cjdns.ipv6 >/dev/null 2>&1
 if [ $? -ne 0 ]; then
 
-  # register commit handler
-  uci -q batch <<-EOF >/dev/null
-    delete ucitrack.@cjdns[-1]
-    add ucitrack cjdns
-    set ucitrack.@cjdns[-1].init=cjdns
-    commit ucitrack
-EOF
-
   # generate configuration
   touch /etc/config/cjdns
   cjdroute --genconf | cjdroute --cleanconf | cjdrouteconf set
 
   # make sure config is present (might fail for any reason)
   uci get cjdns.cjdns.ipv6 >/dev/null 2>&1
-  if [ $? -ne 0]; then
+  if [ $? -ne 0 ]; then
     exit 1
   fi
 
-  # enable auto-peering on ethernet
-  uci show network.lan | grep bridge >/dev/null 2>&1
-  if [ $? -eq 0 ]; then
-    # most routers will set up an ethernet bridge for the lan
-    ifname="br-lan"
-  else
-    # docker containers don't have permission to create bridges by default,
-    # so we bind to the underlying interface instead (likely eth0)
-    ifname=`uci get network.lan.ifname`
-  fi
-  uci -q batch <<-EOF >/dev/null
-    add cjdns eth_interface
-    set cjdns.@eth_interface[-1].beacon=2
-    set cjdns.@eth_interface[-1].bind=$ifname
+  # enable auto-peering on ethernet interface lan, if existing
+  ifname=$(uci -q get network.lan.device || \
+           ([ "$(uci -q get network.lan.type)" == "bridge" ] && echo br-lan) || \
+           uci -q get network.lan.ifname)
+  if [ -n "$ifname" ]; then
+    uci -q batch <<-EOF >/dev/null
+      add cjdns eth_interface
+      set cjdns.@eth_interface[-1].beacon=2
+      set cjdns.@eth_interface[-1].bind=$ifname
 EOF
-
+  fi
   # set the tun interface name
   uci set cjdns.cjdns.tun_device=tuncjdns
 
   # create the network interface
   uci -q batch <<-EOF >/dev/null
     set network.cjdns=interface
-    set network.cjdns.ifname=tuncjdns
+    set network.cjdns.device=tuncjdns
     set network.cjdns.proto=none
 EOF