diff --git a/package/gluon-mesh-babel/files/etc/init.d/gluon-mesh-babeld-0 b/package/gluon-mesh-babel/files/etc/init.d/gluon-mesh-babeld-0 new file mode 100755 index 00000000..1f024290 --- /dev/null +++ b/package/gluon-mesh-babel/files/etc/init.d/gluon-mesh-babeld-0 @@ -0,0 +1,28 @@ +#!/usr/bin/lua + +local site = require 'gluon.site_config' +local gmesh = require 'gluon.mesh' + +--local interfaces='/lib/gluon/core/mesh_interfaces' +local babelconf='/var/etc/gluon-babel.conf' + +file = io.open(babelconf, "w") +file:write("ipv6-subtrees true\n") +file:write("export-table 10\n") +file:write("import-table 255\n") +file:write("import-table 11\n") + +for interface in gmesh.interfaces() do + file:write("interface " .. interface .. "\n") +end +if site.mesh_on_wan then + file:write("interface br-wan\n") +end + +file:write(" redistribute ip " .. site.prefix6 .. " eq 128 allow\n") +file:write(" redistribute ip " .. site.babel_mesh.prefix .. " eq 128 allow\n") +file:write(" redistribute local deny\n") +file:write(" redistribute ip ::/0 eq 0 allow\n") +file:close() + + diff --git a/package/gluon-mesh-babel/files/etc/init.d/gluon-mesh-babeld-1 b/package/gluon-mesh-babel/files/etc/init.d/gluon-mesh-babeld-1 new file mode 100755 index 00000000..5486fcf3 --- /dev/null +++ b/package/gluon-mesh-babel/files/etc/init.d/gluon-mesh-babeld-1 @@ -0,0 +1,37 @@ +#!/bin/sh /etc/rc.common + +. $IPKG_INSTROOT/lib/functions/network.sh + +START=70 + +pidfile='/var/run/babeld.pid' +CONFIGFILE='/var/etc/gluon-babel.conf' +EXTRA_COMMANDS="status" +EXTRA_HELP=" status Dump Babel's table to the log file." + +start() { + mkdir -p /var/lib + mkdir -p /var/etc + + /usr/sbin/babeld -D -I "$pidfile" -c "$CONFIGFILE" + # Wait for the pidfile to appear + for i in 1 2 + do + [ -f "$pidfile" ] || sleep 1 + done + [ -f "$pidfile" ] || (echo "Failed to start babeld"; exit 42) +} + +stop() { + [ -f "$pidfile" ] && kill $(cat $pidfile) + # avoid race-condition on restart: wait for + # babeld to die for real. + [ -f "$pidfile" ] && sleep 1 + [ -f "$pidfile" ] && sleep 1 + [ -f "$pidfile" ] && sleep 1 + [ -f "$pidfile" ] && exit 42 +} + +status() { + [ -f "$pidfile" ] && kill -USR1 $(cat $pidfile) +} diff --git a/package/gluon-mesh-babel/files/lib/gluon/upgrade/330-gluon-mesh-babel-interfaces b/package/gluon-mesh-babel/files/lib/gluon/upgrade/330-gluon-mesh-babel-interfaces index 43fdb08c..b620da63 100755 --- a/package/gluon-mesh-babel/files/lib/gluon/upgrade/330-gluon-mesh-babel-interfaces +++ b/package/gluon-mesh-babel/files/lib/gluon/upgrade/330-gluon-mesh-babel-interfaces @@ -2,39 +2,12 @@ local uci = require('luci.model.uci').cursor() local site = require 'gluon.site_config' -local interfaces='/lib/gluon/core/mesh_interfaces' -local babelconf='/var/etc/gluon-babel.conf' +--local gmesh = require 'gluon.mesh' +-- TODO: do we need settings for more interfaces in the firewall? if site.mesh_on_wan then - uci:section('babeld', 'interface', 'mesh_wan', - { - ifname = 'br-wan', - } - ) - uci:add_to_set('firewall', 'mesh_babel', 'network', 'wan') end - -file = io.open(babelconf, "w") -file:write("ipv6-subtrees true\n") -file:write("export-table 10\n") -file:write("import-table 255\n") -file:write("import-table 11\n") - -pcall( function() - for interface in io.lines(interfaces) do - local section = interface:gsub('[^%w_]','_') - file:write("interface " .. interface .. "\n") - end -end) - -file:write(" redistribute ip " .. site.prefix6 .. " eq 128 allow\n") -file:write(" redistribute ip " .. site.babel_mesh.prefix .. " eq 128 allow\n") -file:write(" redistribute local deny\n") -file:write(" redistribute ip ::/0 eq 0 allow\n") -file:close() - - uci:add_to_set('firewall', 'mesh_babel', 'network', 'client') uci:add_to_set('firewall', 'mesh_babel', 'network', 'local_node4') uci:add_to_set('firewall', 'mesh_babel', 'network', 'local_node6')