mirror of
https://github.com/hanwckf/immortalwrt-mt798x.git
synced 2025-01-10 03:09:08 +08:00
luci-app-zerotier: restart service when network changed
This commit is contained in:
parent
e0fdc3f2d1
commit
a0adaa4a38
@ -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
|
||||
|
||||
|
@ -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
|
||||
|
@ -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
|
||||
|
Loading…
x
Reference in New Issue
Block a user