2017-02-23 14:49:32 +00:00
|
|
|
#!/bin/sh /etc/rc.common
|
|
|
|
|
|
|
|
START=55
|
|
|
|
|
|
|
|
USE_PROCD=1
|
|
|
|
PROG=/usr/sbin/l3roamd
|
|
|
|
|
2018-11-19 06:21:02 +00:00
|
|
|
echotol3roamd() {
|
|
|
|
local count=0
|
|
|
|
local line="$1"
|
|
|
|
while ! (echo -e "$line" | uc /var/run/l3roamd.sock >/dev/null 2>&1)
|
|
|
|
do
|
|
|
|
sleep 1
|
|
|
|
echo retrying to connect to l3roamd in PID $$, waited ${count}s >&2
|
|
|
|
count=$((count+1))
|
|
|
|
done
|
|
|
|
return 0
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reload_service() {
|
|
|
|
for i in $(ubus call network.interface dump | jsonfilter -e "@.interface[@.proto='gluon_mesh' && @.up=true].device")
|
|
|
|
do
|
|
|
|
echotol3roamd "add_meshif $i"
|
|
|
|
done
|
|
|
|
|
|
|
|
for i in $(echotol3roamd "get_meshifs"| jsonfilter -e "@.mesh_interfaces[@]")
|
|
|
|
do
|
|
|
|
if ! ubus call network.interface dump | jsonfilter -e "@.interface[@.proto='gluon_mesh' && @.up=true].device"|grep -q $i
|
|
|
|
then
|
|
|
|
echotol3roamd "del_meshif $i"
|
|
|
|
fi
|
|
|
|
done
|
|
|
|
}
|
|
|
|
|
2017-02-23 14:49:32 +00:00
|
|
|
start_service () {
|
2018-04-15 10:49:52 +00:00
|
|
|
local interfaces=$(
|
2018-11-19 06:21:02 +00:00
|
|
|
for dev in $(gluon-list-mesh-interfaces); do echo " -m $dev"; done
|
|
|
|
[ "$(ifstatus local_node | jsonfilter -e '@.up')" = 'true' ] && echo ' -i local-node'
|
2018-04-15 10:49:52 +00:00
|
|
|
)
|
2019-09-08 14:06:00 +00:00
|
|
|
|
|
|
|
local prefix4="$(lua -e 'prefix4 = require("gluon.site").prefix4() if prefix4 then print(" -p " .. prefix4) end')"
|
|
|
|
local prefix6="$(lua -e 'print(" -p " .. require("gluon.site").prefix6())')"
|
|
|
|
local localip="$(uci get network.loopback.ip6addr | cut -d/ -f1)"
|
2022-06-25 03:28:12 +00:00
|
|
|
local roamingprefix="$(lua -e 'print(" -P " .. require("gluon.l3").node_client_prefix6())')"
|
2019-09-08 14:06:00 +00:00
|
|
|
|
2018-02-16 22:12:38 +00:00
|
|
|
/sbin/sysctl -w net.ipv6.neigh.default.gc_thresh1=2
|
|
|
|
/sbin/sysctl -w net.ipv4.neigh.default.gc_thresh1=2
|
2018-04-15 10:49:52 +00:00
|
|
|
|
2017-02-23 14:49:32 +00:00
|
|
|
procd_open_instance
|
|
|
|
procd_set_param stdout 1
|
|
|
|
procd_set_param stderr 1
|
|
|
|
procd_set_param respawn ${respawn_threshold:-3660} ${respawn_timeout:-5} ${respawn_retry:-0}
|
2019-09-08 14:06:00 +00:00
|
|
|
procd_set_param command "$PROG" -s /var/run/l3roamd.sock $prefix4 $prefix6 $interfaces -t 254 -a $localip -b br-client $roamingprefix
|
2017-02-23 14:49:32 +00:00
|
|
|
procd_close_instance
|
|
|
|
}
|
|
|
|
|
|
|
|
service_triggers() {
|
|
|
|
local script=$(readlink "$initscript")
|
|
|
|
local name=$(basename "${script:-$initscript}")
|
|
|
|
|
|
|
|
procd_open_trigger
|
2018-04-15 10:49:52 +00:00
|
|
|
procd_add_raw_trigger 'interface.*' 0 "/etc/init.d/$name" reload
|
2017-02-23 14:49:32 +00:00
|
|
|
procd_close_trigger
|
|
|
|
}
|