luci-app-zerotier: restart service when network changed

This commit is contained in:
CN_SZTL 2020-08-04 02:40:35 +08:00
parent e0fdc3f2d1
commit a0adaa4a38
No known key found for this signature in database
GPG Key ID: 6850B6345C862176
3 changed files with 6 additions and 10 deletions

View File

@ -10,7 +10,7 @@ LUCI_TITLE:=LuCI for Zerotier
LUCI_DEPENDS:=+zerotier
LUCI_PKGARCH:=all
PKG_VERSION:=1.0
PKG_RELEASE:=19
PKG_RELEASE:=20
include $(TOPDIR)/feeds/luci/luci.mk

View File

@ -8,7 +8,8 @@ PROG=/usr/bin/zerotier-one
CONFIG_PATH=/var/lib/zerotier-one
service_triggers() {
procd_add_reload_trigger zerotier
procd_add_reload_trigger "zerotier"
procd_add_interface_trigger "interface.*.up" wan /etc/init.d/zerotier restart
}
section_enabled() {
@ -94,6 +95,8 @@ stop_instance() {
rm -f /tmp/zero.log
local cfg="$1"
/etc/zerotier.stop > /tmp/zero.log 2>&1 &
# Remove existing link or folder
rm -f $CONFIG_PATH/networks.d/*.conf
rm -rf $CONFIG_PATH

View File

@ -5,7 +5,7 @@ zero_enable="$(uci get zerotier.sample_config.enabled)"
[ "${zero_enable}" -ne "1" ] && exit 0
[ -f "/tmp/zero.log" ] && {
while [ "$(ifconfig | grep 'zt' | awk '{print $1}')" = "" ]
while [ "$(ifconfig | grep 'zt' | awk '{print $1}')" = "" ]
do
sleep 1
done
@ -15,13 +15,6 @@ nat_enable="$(uci get zerotier.sample_config.nat)"
zt0="$(ifconfig | grep 'zt' | awk '{print $1}')"
echo "${zt0}" > "/tmp/zt.nif"
for i in ${zt0}
do
iptables -D FORWARD -i "$i" -j ACCEPT 2>/dev/null
iptables -D FORWARD -o "$i" -j ACCEPT 2>/dev/null
iptables -t nat -D POSTROUTING -o "$i" -j MASQUERADE 2>/dev/null
done
[ "${nat_enable}" -eq "1" ] && {
for i in ${zt0}
do