Skip to content

Commit

Permalink
test 2 method to submit
Browse files Browse the repository at this point in the history
  • Loading branch information
rufengsuixing committed Dec 20, 2019
1 parent e3ccfd6 commit 1fb7543
Show file tree
Hide file tree
Showing 4 changed files with 27 additions and 6 deletions.
4 changes: 2 additions & 2 deletions Makefile
Expand Up @@ -50,9 +50,9 @@ endef
define Package/luci-app-adguardhome/postinst
#!/bin/sh
/etc/init.d/AdGuardHome enable >/dev/null 2>&1
enable=$(uci get AdGuardHome.AdGuardHome.enabled)
enable=$(uci get AdGuardHome.AdGuardHome.enabled 2>/dev/null)
if [ "$enable"x == "1"x ]; then
/etc/init.d/AdGuardHome start
/etc/init.d/AdGuardHome reload
fi
rm -f /tmp/luci-indexcache
rm -f /tmp/luci-modulecache/*
Expand Down
20 changes: 18 additions & 2 deletions luasrc/model/cbi/AdGuardHome/base.lua
Expand Up @@ -248,9 +248,25 @@ o.write = function(self, section, value)
end
fs.writefile("/var/run/lucilogpos","0")
function m.on_commit(map)
if (fs.access("/var/run/AdGucitest")) then
local ucitracktest=uci:get("AdGuardHome","AdGuardHome","ucitracktest")
if ucitracktest=="1" then
return
elseif ucitracktest=="0" then
io.popen("/etc/init.d/AdGuardHome reload &")
else
if (fs.access("/var/run/AdGucitest")) then
uci:set("AdGuardHome","AdGuardHome","ucitracktest","0")
io.popen("/etc/init.d/AdGuardHome reload &")
else
fs.writefile("/var/run/AdGucitest","")
if (ucitracktest=="2") then
uci:set("AdGuardHome","AdGuardHome","ucitracktest","1")
else
uci:set("AdGuardHome","AdGuardHome","ucitracktest","2")
end
end
uci:save("AdGuardHome")
uci:commit("AdGuardHome")
end
fs.writefile("/var/run/AdGucitest","")
end
return m
8 changes: 6 additions & 2 deletions luasrc/model/cbi/AdGuardHome/manual.lua
Expand Up @@ -85,9 +85,13 @@ end
end
end
function m.on_commit(map)
if (fs.access("/var/run/AdGucitest")) then
local ucitracktest=uci:get("AdGuardHome","AdGuardHome","ucitracktest")
if ucitracktest=="1" then
return
elseif ucitracktest=="0" then
io.popen("/etc/init.d/AdGuardHome reload &")
else
fs.writefile("/var/run/AdGucitest","")
end
fs.writefile("/var/run/AdGucitest","")
end
return m
1 change: 1 addition & 0 deletions root/etc/uci-defaults/40_luci-AdGuardHome
Expand Up @@ -5,6 +5,7 @@ uci -q batch <<-EOF 2>&1 >/dev/null
add ucitrack AdGuardHome
set ucitrack.@AdGuardHome[-1].init=AdGuardHome
commit ucitrack
delete AdGuardHome.AdGuardHome.ucitracktest
EOF

rm -f /tmp/luci-indexcache
Expand Down

0 comments on commit 1fb7543

Please sign in to comment.