Forráskód Böngészése

try ucitrack to apply

rufengsuixing 5 éve
szülő
commit
dcfbe0703f

+ 0 - 3
luasrc/model/cbi/AdGuardHome/base.lua

@@ -167,8 +167,5 @@ if fs.stat(value,"type")=="reg" then
 end 
 return value
 end
-function mp.on_commit(map)
-	io.popen("/etc/init.d/AdGuardHome reload &")
-end
 nixio.fs.writefile("/var/run/lucilogpos","0")
 return mp

+ 0 - 3
luasrc/model/cbi/AdGuardHome/manual.lua

@@ -88,7 +88,4 @@ o.write=function()
 end
 end
 end
-function m.on_commit(map)
-	io.popen("/etc/init.d/AdGuardHome reload &")
-end
 return m

+ 17 - 0
root/etc/uci-defaults/40_luci-AdGuardHome

@@ -0,0 +1,17 @@
+#!/bin/sh
+
+uci -q batch <<-EOF >/dev/null
+	delete ucitrack.@AdGuardHome[-1]
+	add ucitrack AdGuardHome
+	set ucitrack.@AdGuardHome[-1].init=AdGuardHome
+	commit ucitrack
+  delete firewall.AdGuardHome
+	set firewall.AdGuardHome=include
+	set firewall.AdGuardHome.type=script
+	set firewall.AdGuardHome.path=/usr/share/AdGuardHome/firewall.start
+	set firewall.AdGuardHome.reload=1
+	commit firewall
+EOF
+
+rm -f /tmp/luci-indexcache
+exit 0

+ 8 - 0
root/usr/share/AdGuardHome/firewall.start

@@ -0,0 +1,8 @@
+#!/bin/sh
+
+AdGuardHome_enable=$(uci get AdGuardHome.AdGuardHome.enabled)
+redirect=$(uci get AdGuardHome.AdGuardHome.redirect)
+
+if [ $AdGuardHome_enable -eq 1 -a "$redirect" == "redirect" ]; then
+	/etc/init.d/AdGuardHome do_redirect 1
+fi