#!/bin/sh if [ "$(/sbin/uci -c /etc/config.mesh -q get aredn.@tunnel[0])" != "tunnel" ]; then /sbin/uci -c /etc/config.mesh -q add aredn tunnel /sbin/uci -c /etc/config.mesh -q set aredn.@tunnel[0].maxclients=10 /sbin/uci -c /etc/config.mesh -q set aredn.@tunnel[0].maxservers=10 /sbin/uci -c /etc/config.mesh -q commit aredn fi clients=$(/sbin/uci -c /etc/config.mesh -q get aredn.@tunnel[0].maxclients) servers=$(/sbin/uci -c /etc/config.mesh -q get aredn.@tunnel[0].maxservers) maxtun=$((49 + $clients + $servers)) # Check we have sufficient tunnels and regenerate network_tun if not if [ "$(/sbin/uci -c /etc/config.mesh -q get network_tun.tun$maxtun)" != "interface" -o "$(/sbin/uci -c /etc/config.mesh -q get network_tun.tun$((1 + $maxtun)))" != "" ]; then cp /dev/null /etc/config.mesh/network_tun for tun in $(seq 50 $maxtun) do cat >> /etc/config.mesh/network_tun <<__EOT__ config interface 'tun$tun' option ifname 'tun$tun' option proto 'none' __EOT__ done fi