update 2023-10-26 11:25:32

This commit is contained in:
github-actions[bot] 2023-10-26 11:25:32 +08:00
parent 67a1e565c4
commit 915f448b80
21 changed files with 723 additions and 604 deletions

View File

@ -1,3 +1,5 @@
# Copyright (C) 2018-2019 Lienol
#
# This is free software, licensed under the Apache License, Version 2.0 .
#
@ -11,7 +13,6 @@ LUCI_PKGARCH:=all
LUCI_DEPENDS:=+ca-certs +curl +wget-ssl +PACKAGE_$(PKG_NAME)_INCLUDE_binary:adguardhome
LUCI_DESCRIPTION:=LuCI support for AdGuardHome
define Package/$(PKG_NAME)/config
config PACKAGE_$(PKG_NAME)_INCLUDE_binary
bool "Include Binary File"
@ -26,7 +27,6 @@ define Package/luci-app-adguardhome/conffiles
/etc/AdGuardHome.yaml
endef
define Package/luci-app-adguardhome/postinst
#!/bin/sh
/etc/init.d/AdGuardHome enable >/dev/null 2>&1

View File

@ -1,22 +1,22 @@
module("luci.controller.AdGuardHome", package.seeall)
local fs = require "nixio.fs"
local http = require "luci.http"
local uci = require"luci.model.uci".cursor()
module("luci.controller.AdGuardHome",package.seeall)
local fs=require"nixio.fs"
local http=require"luci.http"
local uci=require"luci.model.uci".cursor()
function index()
local page = entry({"admin", "services", "AdGuardHome"},alias("admin", "services", "AdGuardHome", "base"),_("AdGuard Home"))
page.order = 11
page.order = 10
page.dependent = true
page.acl_depends = { "luci-app-adguardhome" }
entry({"admin", "services", "AdGuardHome", "base"}, cbi("AdGuardHome/base"), _("Base Setting"), 1).leaf = true
entry({"admin", "services", "AdGuardHome", "log"}, form("AdGuardHome/log"), _("Log"), 2).leaf = true
entry({"admin", "services", "AdGuardHome", "manual"}, cbi("AdGuardHome/manual"), _("Manual Config"), 3).leaf = true
entry({"admin", "services", "AdGuardHome", "status"}, call("act_status")).leaf = true
entry({"admin", "services", "AdGuardHome", "check"}, call("check_update"))
entry({"admin", "services", "AdGuardHome", "doupdate"}, call("do_update"))
entry({"admin", "services", "AdGuardHome", "getlog"}, call("get_log"))
entry({"admin", "services", "AdGuardHome", "dodellog"}, call("do_dellog"))
entry({"admin", "services", "AdGuardHome", "reloadconfig"}, call("reload_config"))
entry({"admin", "services", "AdGuardHome", "gettemplateconfig"}, call("get_template_config"))
entry({"admin","services","AdGuardHome","base"},cbi("AdGuardHome/base"),_("Base Setting"),1).leaf = true
entry({"admin","services","AdGuardHome","log"},form("AdGuardHome/log"),_("Log"),2).leaf = true
entry({"admin","services","AdGuardHome","manual"},cbi("AdGuardHome/manual"),_("Manual Config"),3).leaf = true
entry({"admin","services","AdGuardHome","status"},call("act_status")).leaf=true
entry({"admin", "services", "AdGuardHome", "check"}, call("check_update"))
entry({"admin", "services", "AdGuardHome", "doupdate"}, call("do_update"))
entry({"admin", "services", "AdGuardHome", "getlog"}, call("get_log"))
entry({"admin", "services", "AdGuardHome", "dodellog"}, call("do_dellog"))
entry({"admin", "services", "AdGuardHome", "reloadconfig"}, call("reload_config"))
entry({"admin", "services", "AdGuardHome", "gettemplateconfig"}, call("get_template_config"))
end
function get_template_config()
local b
@ -68,10 +68,10 @@ function do_update()
else
arg=""
end
if arg=="force" then
if fs.access("/var/run/update_core") then
if arg=="force" then
luci.sys.exec("kill $(pgrep /usr/share/AdGuardHome/update_core.sh) ; sh /usr/share/AdGuardHome/update_core.sh "..arg.." >/tmp/AdGuardHome_update.log 2>&1 &")
end
else
luci.sys.exec("sh /usr/share/AdGuardHome/update_core.sh "..arg.." >/tmp/AdGuardHome_update.log 2>&1 &")
end

View File

@ -5,7 +5,7 @@ local m,s,o,o1
local fs=require"nixio.fs"
local uci=require"luci.model.uci".cursor()
local configpath=uci:get("AdGuardHome","AdGuardHome","configpath") or "/etc/AdGuardHome.yaml"
local binpath = uci:get("AdGuardHome", "AdGuardHome", "binpath") or "/usr/bin/AdGuardHome/AdGuardHome"
local binpath=uci:get("AdGuardHome","AdGuardHome","binpath") or "/usr/bin/AdGuardHome"
httpport=uci:get("AdGuardHome","AdGuardHome","httpport") or "3000"
m = Map("AdGuardHome", "AdGuard Home")
m.description = translate("Free and open source, powerful network-wide ads & trackers blocking DNS server.")
@ -24,33 +24,29 @@ o.placeholder=3000
o.default=3000
o.datatype="port"
o.optional = false
o.description = translate("<input type='button' class='cbi-button cbi-button-apply' style=' text-align:center; font-weight:bold;' value='AdGuardHome Web:" .. httpport .. "' onclick=\"window.open('http://'+window.location.hostname+':" .. httpport .. "')\"/>")
o.description = translate("<input type=\"button\" style=\"width:210px;border-color:Teal; text-align:center;font-weight:bold;color:Green;\" value=\"AdGuardHome Web:"..httpport.."\" onclick=\"window.open('http://'+window.location.hostname+':"..httpport.."/')\"/>")
---- update warning not safe
local binmtime=uci:get("AdGuardHome","AdGuardHome","binmtime") or "0"
local e=""
if not fs.access(configpath) then e = e .. " " .. translate("no config") end
if not fs.access(configpath) then
e=e.." "..translate("no config")
end
if not fs.access(binpath) then
e=e.." "..translate("no core")
else
local version=uci:get("AdGuardHome","AdGuardHome","version")
local testtime=fs.stat(binpath,"mtime")
if testtime~=tonumber(binmtime) or version==nil then
-- local tmp=luci.sys.exec(binpath.." -c /dev/null --check-config 2>&1| grep -m 1 -E 'v[0-9.]+' -o")
-- version=string.sub(tmp, 1, -2)
version = luci.sys.exec(string.format("echo -n $(%s --version 2>&1 | awk -F 'version ' '{print $2}' | awk -F ',' '{print $1}')", binpath))
if version == "" then version = "core error" end
uci:set("AdGuardHome", "AdGuardHome", "version", version)
uci:set("AdGuardHome", "AdGuardHome", "binmtime", testtime)
uci:commit("AdGuardHome")
local tmp=luci.sys.exec(binpath.." --version | grep -m 1 -E 'v[0-9.]+' -o ")
version=string.sub(tmp, 1)
if version=="" then version="core error" end
uci:set("AdGuardHome","AdGuardHome","version",version)
uci:set("AdGuardHome","AdGuardHome","binmtime",testtime)
uci:save("AdGuardHome")
end
e=version..e
end
o = s:option(ListValue, "core_version", translate("Core Version"))
o:value("latest", translate("Latest Version"))
o:value("beta", translate("Beta Version"))
o.default = "latest"
o = s:option(Button, "restart", translate("Upgrade Core"))
o=s:option(Button,"restart",translate("Update"))
o.inputtitle=translate("Update core version")
o.template = "AdGuardHome/AdGuardHome_check"
o.showfastconfig=(not fs.access(configpath))
@ -69,8 +65,8 @@ o.default = "none"
o.optional = true
---- bin path
o = s:option(Value, "binpath", translate("Bin Path"), translate("AdGuardHome Bin path if no bin will auto download"))
o.default = "/usr/bin/AdGuardHome/AdGuardHome"
o.datatype = "string"
o.default = "/usr/bin/AdGuardHome"
o.datatype = "string"
o.optional = false
o.rmempty=false
o.validate=function(self, value)
@ -122,8 +118,8 @@ return value
end
---- work dir
o = s:option(Value, "workdir", translate("Work dir"), translate("AdGuardHome work dir include rules,audit log and database"))
o.default = "/usr/bin/AdGuardHome"
o.datatype = "string"
o.default = "/etc/AdGuardHome"
o.datatype = "string"
o.optional = false
o.rmempty=false
o.validate=function(self, value)
@ -212,7 +208,7 @@ o = s:option(Flag, "waitonboot", translate("On boot when network ok restart"))
o.default = 1
o.optional = true
---- backup workdir on shutdown
local workdir = uci:get("AdGuardHome", "AdGuardHome", "workdir") or "/usr/bin/AdGuardHome"
local workdir=uci:get("AdGuardHome","AdGuardHome","workdir") or "/etc/AdGuardHome"
o = s:option(MultiValue, "backupfile", translate("Backup workdir files when shutdown"))
o1 = s:option(Value, "backupwdpath", translate("Backup workdir path"))
local name
@ -238,7 +234,7 @@ o.optional=false
o.description=translate("Will be restore when workdir/data is empty")
----backup workdir path
o1.default = "/usr/bin/AdGuardHome"
o1.default = "/etc/AdGuardHome"
o1.datatype = "string"
o1.optional = false
o1.validate=function(self, value)
@ -268,12 +264,18 @@ o.widget = "checkbox"
o.default = nil
o.optional=true
o = s:option(Value, "update_url", translate("Core Update URL"))
o.default = "https://github.com/AdguardTeam/AdGuardHome/releases/download/${Cloud_Version}/AdGuardHome_linux_${Arch}.tar.gz"
o.placeholder = "https://github.com/AdguardTeam/AdGuardHome/releases/download/${Cloud_Version}/AdGuardHome_linux_${Arch}.tar.gz"
o.rmempty = false
----downloadpath
o = s:option(TextValue, "downloadlinks",translate("Download links for update"))
o.optional = false
o.rows = 4
o.wrap = "soft"
o.cfgvalue = function(self, section)
return fs.readfile("/usr/share/AdGuardHome/links.txt")
end
o.write = function(self, section, value)
fs.writefile("/usr/share/AdGuardHome/links.txt", value:gsub("\r\n", "\n"))
end
fs.writefile("/var/run/lucilogpos","0")
function m.on_commit(map)
if (fs.access("/var/run/AdGserverdis")) then
io.popen("/etc/init.d/AdGuardHome reload &")
@ -296,7 +298,7 @@ function m.on_commit(map)
uci:set("AdGuardHome","AdGuardHome","ucitracktest","2")
end
end
uci:commit("AdGuardHome")
uci:save("AdGuardHome")
end
end
return m

View File

@ -1,7 +1,7 @@
local fs = require "nixio.fs"
local uci = require"luci.model.uci".cursor()
local f, t
f = SimpleForm("logview")
local fs=require"nixio.fs"
local uci=require"luci.model.uci".cursor()
local f,t
f=SimpleForm("logview")
f.reset = false
f.submit = false
t=f:field(TextValue,"conf")

View File

@ -70,7 +70,7 @@ o.template = "AdGuardHome/yamleditor"
if not fs.access(binpath) then
o.description=translate("WARNING!!! no bin found apply config will not be test")
end
--- log
--- log
if (fs.access("/tmp/AdGuardHometmpconfig.yaml")) then
local c=fs.readfile("/tmp/AdGuardHometest.log")
if (c~="") then
@ -94,4 +94,4 @@ function m.on_commit(map)
fs.writefile("/var/run/AdGlucitest","")
end
end
return m
return m

View File

@ -75,4 +75,4 @@ XHR.poll(3, '<%=url([[admin]], [[services]], [[AdGuardHome]], [[check]])%>', nul
<%end%>
//]]>
</script>
<%+cbi/valuefooter%>
<%+cbi/valuefooter%>

View File

@ -46,4 +46,4 @@ function chpass(btn)
%> />
<% if self.password then %><img src="<%=resource%>/cbi/reload.gif" style="vertical-align:middle" title="<%:Reveal/hide password%>" onclick="var e = document.getElementById('<%=cbid%>'); e.type = (e.type=='password') ? 'text' : 'password';" /><% end %>
<input type="button" class="btn cbi-button cbi-button-apply" id="cbid.AdGuardHome.AdGuardHome.applychpass" value="<%:Load culculate model%>" onclick="return chpass(this)"/>
<%+cbi/valuefooter%>
<%+cbi/valuefooter%>

View File

@ -4,15 +4,15 @@ XHR.poll(3, '<%=url([[admin]], [[services]], [[AdGuardHome]], [[status]])%>', nu
var tb = document.getElementById('AdGuardHome_status');
if (data && tb) {
if (data.running) {
tb.innerHTML = '<em><b style=color:green>AdGuardHome <%:RUNNING%></b></em>';
tb.innerHTML = '<em><b><font color=green>AdGuardHome <%:RUNNING%></font></b></em>';
} else {
tb.innerHTML = '<em><b style=color:red>AdGuardHome <%:NOT RUNNING%></b></em>';
tb.innerHTML = '<em><b><font color=red>AdGuardHome <%:NOT RUNNING%></font></b></em>';
}
if (data.redirect)
{
tb.innerHTML+='<em><b style=color:green><%:Redirected%></b></em>'
tb.innerHTML+='<em><b><font color=green><%:Redirected%></font></b></em>'
} else {
tb.innerHTML+='<em><b style=color:red><%:Not redirect%></b></em>'
tb.innerHTML+='<em><b><font color=red><%:Not redirect%></font></b></em>'
}
}
}

View File

@ -108,4 +108,4 @@ lv.innerHTML="<%:Please add log path in config to enable log%>"
<%end%>
//]]>
</script>
<%+cbi/valuefooter%>
<%+cbi/valuefooter%>

View File

@ -0,0 +1 @@
zh_Hans

View File

@ -1,299 +0,0 @@
#/cgi-bin/luci/admin/services/AdGuardHome
msgid "Base Setting"
msgstr "基础设置"
msgid "Log"
msgstr "日志"
msgid "AdGuardHome's version"
msgstr "AdGuardHome 版本"
msgid "Needed to click 'save&apply' to generate the configuration file"
msgstr "需要点击“保存并应用”才能生成配置文件"
msgid "In case of the latest realease is a source code that can not download the binary file"
msgstr "防止最新release只有源码导致下载不成功"
msgid "Manual Config"
msgstr "手动设置"
msgid "Free and open source, powerful network-wide ads & trackers blocking DNS server."
msgstr "全网络广告和跟踪程序拦截DNS服务器默认账号和密码均为admin"
msgid "RUNNING"
msgstr "运行中"
msgid "NOT RUNNING"
msgstr "未运行"
msgid "Redirected"
msgstr "已重定向"
msgid "Not redirect"
msgstr "未重定向"
msgid "Collecting data..."
msgstr "获取数据中..."
msgid "Enable"
msgstr "启用"
msgid "Browser management port"
msgstr "网页管理账号和密码:admin ,端口:"
msgid "Upgrade Core"
msgstr "更新核心"
#button change
msgid "Update core version"
msgstr "更新核心版本"
msgid "Check..."
msgstr "检查中..."
msgid "Updated"
msgstr "已更新"
#button hide
msgid "Force update"
msgstr "强制更新核心"
msgid "Fast config"
msgstr "快速配置"
msgid "Core Version"
msgstr "核心版本"
msgid "Latest Version"
msgstr "最新版"
msgid "Beta Version"
msgstr "测试版"
msgid "Current core version:"
msgstr "当前核心版本:"
msgid "no config"
msgstr "没有配置文件"
msgid "no core"
msgstr "没有核心"
#
msgid "Redirect"
msgstr "重定向"
#inlist
msgid "none"
msgstr "无"
msgid "Run as dnsmasq upstream server"
msgstr "作为dnsmasq的上游服务器"
msgid "Redirect 53 port to AdGuardHome"
msgstr "重定向53端口到AdGuardHome"
msgid "Use port 53 replace dnsmasq"
msgstr "使用53端口替换dnsmasq"
#
msgid "AdGuardHome redirect mode"
msgstr "AdGuardHome重定向模式"
msgid "Bin Path"
msgstr "执行文件路径"
msgid "AdGuardHome Bin path if no bin will auto download"
msgstr "AdGuardHome 执行文件路径 如果没有执行文件将自动下载"
msgid "use upx to compress bin after download"
msgstr "下载后使用upx压缩执行文件"
#inlist
msgid "compress faster"
msgstr "快速压缩"
msgid "compress better"
msgstr "更好的压缩"
msgid "compress best(can be slow for big files)"
msgstr "最好的压缩(大文件可能慢)"
msgid "try all available compression methods & filters [slow]"
msgstr "尝试所有可能的压缩方法和过滤器[慢]"
msgid "try even more compression variants [very slow]"
msgstr "尝试更多变体压缩手段[很慢]"
msgid "bin use less space,but may have compatibility issues"
msgstr "减小执行文件空间占用,但是可能压缩后有兼容性问题"
#
msgid "Config Path"
msgstr "配置文件路径"
msgid "AdGuardHome config path"
msgstr "AdGuardHome 配置文件路径"
msgid "Work dir"
msgstr "工作目录"
msgid "AdGuardHome work dir include rules,audit log and database"
msgstr "AdGuardHome 工作目录包含规则,审计日志和数据库"
msgid "Runtime log file"
msgstr "运行日志路径"
msgid "AdGuardHome runtime Log file if 'syslog': write to system log;if empty no log"
msgstr "AdGuardHome 运行日志, 如果填 syslog 将写入系统日志; 如果该项为空则不记录运行日志"
msgid "Verbose log"
msgstr "输出详细日志"
#hide div
msgid "Add gfwlist"
msgstr "添加 GFW 列表"
msgid "Add"
msgstr "添加"
msgid "Added"
msgstr "已添加"
msgid "Not added"
msgstr "未添加"
#hide div
msgid "Del gfwlist"
msgstr "删除gfw列表"
msgid "Del"
msgstr "删除"
#hide div
msgid "Gfwlist upstream dns server"
msgstr "gfw列表上游服务器"
msgid "Gfwlist domain upstream dns service"
msgstr "gfw列表域名上游服务器"
#hide div
msgid "Change browser management password"
msgstr "更改网页登录密码"
msgid "Culculate"
msgstr "计算"
##button change
msgid "Load culculate model"
msgstr "载入计算模块"
msgid "loading..."
msgstr "载入中"
msgid "Please save/apply"
msgstr "请点击[保存/应用]"
msgid "is empty"
msgstr "为空"
msgid "Press load culculate model and culculate finally save/apply"
msgstr "先输入你想要的密码, 点击[载入计算模块], 然后点击[计算], 最后点击下方[保存&应用]"
#
msgid "Keep files when system upgrade"
msgstr "系统升级时保留文件"
#checkbox
msgid "core bin"
msgstr "核心执行文件"
msgid "config file"
msgstr "配置文件"
msgid "log file"
msgstr "日志文件"
msgid "querylog.json"
msgstr "审计日志.json"
#
msgid "On boot when network ok restart"
msgstr "开机后网络准备好时重启"
msgid "Backup workdir files when shutdown"
msgstr "在关机时备份工作目录文件"
msgid "Will be restore when workdir/data is empty"
msgstr "在工作目录/data为空的时候恢复"
msgid "Backup workdir path"
msgstr "工作目录备份路径"
msgid "Crontab task"
msgstr "计划任务"
msgid "Auto update core"
msgstr "自动升级核心"
msgid "Auto tail querylog"
msgstr "自动截短查询日志"
msgid "Auto tail runtime log"
msgstr "自动截短运行日志"
msgid "Auto update ipv6 hosts and restart adh"
msgstr "自动更新ipv6主机并重启adh"
msgid "Auto update gfwlist and restart adh"
msgstr "自动更新gfw列表并重启adh"
msgid "Please change time and args in crontab"
msgstr "请在计划任务中修改时间和参数"
msgid "Core Update URL"
msgstr "核心更新地址"
#/cgi-bin/luci/admin/services/AdGuardHome/log/
msgid "reverse"
msgstr "逆序"
msgid "localtime"
msgstr "本地时间"
msgid "Please add log path in config to enable log"
msgstr "请在设置里填写日志路径以启用日志"
msgid "dellog"
msgstr "删除日志"
msgid "download log"
msgstr "下载日志"
#/cgi-bin/luci//admin/services/AdGuardHome/manual/
msgid "Use template"
msgstr "使用模板"
#hide button
msgid "Reload Config"
msgstr "重新载入配置"
msgid "WARNING!!! no bin found apply config will not be test"
msgstr "警告!!!未找到执行文件,提交配置将不会进行校验"
#unused
msgid "Change browser management username"
msgstr "改变网页登录用户名"
msgid "Username"
msgstr "用户名"
msgid "Check Config"
msgstr "检查配置"
msgid "unknown"
msgstr "未知"
msgid "Keep database when system upgrade"
msgstr "系统升级时保留数据"
msgid "Boot delay until network ok"
msgstr "开机时直到网络准备好再启动"

View File

@ -1 +0,0 @@
zh-cn

View File

@ -0,0 +1,408 @@
msgid ""
msgstr ""
"Content-Type: text/plain; charset=UTF-8\n"
"Project-Id-Version: PACKAGE VERSION\n"
"Last-Translator: Automatically generated\n"
"Language-Team: none\n"
"Language: zh_Hans\n"
"MIME-Version: 1.0\n"
"Content-Transfer-Encoding: 8bit\n"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:27
msgid ""
"<input type=\"button\" style=\"width:210px;border-color:Teal; text-align:"
"center;font-weight:bold;color:Green;\" value=\"AdGuardHome Web:"
msgstr ""
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/controller/AdGuardHome.lua:6
msgid "AdGuard Home"
msgstr ""
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:67
msgid "AdGuardHome Bin path if no bin will auto download"
msgstr "AdGuardHome 执行文件路径 如果没有执行文件将自动下载"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:99
msgid "AdGuardHome config path"
msgstr "AdGuardHome 配置文件路径"
#
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:58
msgid "AdGuardHome redirect mode"
msgstr "AdGuardHome重定向模式"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:142
msgid ""
"AdGuardHome runtime Log file if 'syslog': write to system log;if empty no log"
msgstr "AdGuardHome 运行日志 如果填syslog将写入系统日志如果空则不记录日志"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:120
msgid "AdGuardHome work dir include rules,audit log and database"
msgstr "AdGuardHome 工作目录包含规则,审计日志和数据库"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:179
msgid "Add"
msgstr "添加"
# hide div
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:177
msgid "Add gfwlist"
msgstr "加入gfw列表"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:259
msgid "Auto tail querylog"
msgstr "自动截短查询日志"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:260
msgid "Auto tail runtime log"
msgstr "自动截短运行日志"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:258
msgid "Auto update core"
msgstr "自动升级核心"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:262
msgid "Auto update gfwlist and restart adh"
msgstr "自动更新gfw列表并重启adh"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:261
msgid "Auto update ipv6 hosts and restart adh"
msgstr "自动更新ipv6主机并重启adh"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:212
msgid "Backup workdir files when shutdown"
msgstr "在关机时备份工作目录文件"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:213
msgid "Backup workdir path"
msgstr "工作目录备份路径"
# /cgi-bin/luci/admin/services/AdGuardHome
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/controller/AdGuardHome.lua:7
msgid "Base Setting"
msgstr "基础设置"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:67
msgid "Bin Path"
msgstr "执行文件路径"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:22
msgid "Browser management port"
msgstr "网页管理端口"
# hide div
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:189
msgid "Change browser management password"
msgstr "改变网页登录密码"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/view/AdGuardHome/AdGuardHome_check.htm:37
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/view/AdGuardHome/AdGuardHome_check.htm:70
msgid "Check..."
msgstr "检查中..."
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/view/AdGuardHome/AdGuardHome_status.htm:25
msgid "Collecting data..."
msgstr "获取数据中..."
#
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:99
msgid "Config Path"
msgstr "配置文件路径"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:257
msgid "Crontab task"
msgstr "计划任务"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/view/AdGuardHome/AdGuardHome_chpass.htm:16
msgid "Culculate"
msgstr "计算"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:172
msgid "Del"
msgstr "删除"
# hide div
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:170
msgid "Del gfwlist"
msgstr "删除gfw列表"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:268
msgid "Download links for update"
msgstr "升级用的下载链接"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:18
msgid "Enable"
msgstr "启用"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/view/AdGuardHome/AdGuardHome_check.htm:6
msgid "Fast config"
msgstr "快速配置"
# button hide
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/view/AdGuardHome/AdGuardHome_check.htm:4
msgid "Force update"
msgstr "强制更新"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:11
msgid ""
"Free and open source, powerful network-wide ads & trackers blocking DNS "
"server."
msgstr "免费开源功能强大的全网络广告和跟踪程序拦截DNS服务器"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:184
msgid "Gfwlist domain upstream dns service"
msgstr "gfw列表域名上游服务器"
# hide div
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:184
msgid "Gfwlist upstream dns server"
msgstr "gfw列表上游服务器"
#
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:195
msgid "Keep files when system upgrade"
msgstr "系统升级时保留文件"
# #button change
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/view/AdGuardHome/AdGuardHome_chpass.htm:48
msgid "Load culculate model"
msgstr "载入计算模块"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/controller/AdGuardHome.lua:8
msgid "Log"
msgstr "日志"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/controller/AdGuardHome.lua:9
msgid "Manual Config"
msgstr "手动设置"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/view/AdGuardHome/AdGuardHome_status.htm:9
msgid "NOT RUNNING"
msgstr "未运行"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/view/AdGuardHome/AdGuardHome_status.htm:15
msgid "Not redirect"
msgstr "未重定向"
#
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:207
msgid "On boot when network ok restart"
msgstr "开机后网络准备好时重启"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/view/AdGuardHome/log.htm:106
msgid "Please add log path in config to enable log"
msgstr "请在设置里填写日志路径以启用日志"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:257
msgid "Please change time and args in crontab"
msgstr "请在计划任务中修改时间和参数"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/view/AdGuardHome/AdGuardHome_chpass.htm:24
msgid "Please save/apply"
msgstr "请提交"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:189
msgid "Press load culculate model and culculate finally save/apply"
msgstr "按载入计算模块 然后计算 最后保存/提交"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/view/AdGuardHome/AdGuardHome_status.htm:7
msgid "RUNNING"
msgstr "运行中"
#
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:58
msgid "Redirect"
msgstr "重定向"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:62
msgid "Redirect 53 port to AdGuardHome"
msgstr "重定向53端口到AdGuardHome"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/view/AdGuardHome/AdGuardHome_status.htm:13
msgid "Redirected"
msgstr "已重定向"
# hide button
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/view/AdGuardHome/yamleditor.htm:36
msgid "Reload Config"
msgstr "重新载入配置"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/view/AdGuardHome/AdGuardHome_chpass.htm:47
msgid "Reveal/hide password"
msgstr ""
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:61
msgid "Run as dnsmasq upstream server"
msgstr "作为dnsmasq的上游服务器"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:142
msgid "Runtime log file"
msgstr "运行日志"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:49
msgid "Update"
msgstr "更新"
# button change
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:50
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/view/AdGuardHome/AdGuardHome_check.htm:3
msgid "Update core version"
msgstr "更新核心版本"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/view/AdGuardHome/AdGuardHome_check.htm:54
msgid "Updated"
msgstr "已更新"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:63
msgid "Use port 53 replace dnsmasq"
msgstr "使用53端口替换dnsmasq"
# /cgi-bin/luci//admin/services/AdGuardHome/manual/
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/view/AdGuardHome/yamleditor.htm:38
msgid "Use template"
msgstr "使用模板"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:160
msgid "Verbose log"
msgstr "详细日志"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/manual.lua:71
msgid "WARNING!!! no bin found apply config will not be test"
msgstr "警告!!!未找到执行文件,提交配置将不会进行校验"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:234
msgid "Will be restore when workdir/data is empty"
msgstr "在工作目录/data为空的时候恢复"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:120
msgid "Work dir"
msgstr "工作目录"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:96
msgid "bin use less space,but may have compatibility issues"
msgstr "减小执行文件空间占用,但是可能压缩后有兼容性问题"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:92
msgid "compress best(can be slow for big files)"
msgstr "最好的压缩(大文件可能慢)"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:91
msgid "compress better"
msgstr "更好的压缩"
# inlist
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:90
msgid "compress faster"
msgstr "快速压缩"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:197
msgid "config file"
msgstr "配置文件"
# checkbox
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:196
msgid "core bin"
msgstr "核心执行文件"
#
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:53
msgid "core version:"
msgstr "核心版本:"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/view/AdGuardHome/log.htm:7
msgid "dellog"
msgstr "删除日志"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/view/AdGuardHome/log.htm:8
msgid "download log"
msgstr "下载日志"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:202
msgid "filters"
msgstr ""
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/view/AdGuardHome/AdGuardHome_chpass.htm:26
msgid "is empty"
msgstr "为空"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/view/AdGuardHome/AdGuardHome_chpass.htm:6
msgid "loading..."
msgstr "载入中"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/view/AdGuardHome/log.htm:4
msgid "localtime"
msgstr "本地时间"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:198
msgid "log file"
msgstr "日志文件"
# description change
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:32
msgid "no config"
msgstr "没有配置文件"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:35
msgid "no core"
msgstr "没有核心"
# inlist
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:60
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:89
msgid "none"
msgstr "无"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:201
msgid "querylog.json"
msgstr "审计日志.json"
# /cgi-bin/luci/admin/services/AdGuardHome/log/
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/view/AdGuardHome/AdGuardHome_check.htm:9
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/view/AdGuardHome/log.htm:2
msgid "reverse"
msgstr "逆序"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:199
msgid "sessions.db"
msgstr ""
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:200
msgid "stats.db"
msgstr ""
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:93
msgid "try all available compression methods & filters [slow]"
msgstr "尝试所有可能的压缩方法和过滤器[慢]"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:94
msgid "try even more compression variants [very slow]"
msgstr "尝试更多变体压缩手段[很慢]"
#: /mnt/A/openwrt-latest/package/ctcgfw/luci-app-adguardhome/luasrc/model/cbi/AdGuardHome/base.lua:88
msgid "use upx to compress bin after download"
msgstr "下载后使用upx压缩执行文件"
#~ msgid "Added"
#~ msgstr "已添加"
#~ msgid "Not added"
#~ msgstr "未添加"
# unused
#~ msgid "Change browser management username"
#~ msgstr "改变网页登录用户名"
#~ msgid "Username"
#~ msgstr "用户名"
#~ msgid "Check Config"
#~ msgstr "检查配置"
#~ msgid "unknown"
#~ msgstr "未知"
#~ msgid "Keep database when system upgrade"
#~ msgstr "系统升级时保留数据"
#~ msgid "Boot delay until network ok"
#~ msgstr "开机时直到网络准备好再启动"

14
luci-app-adguardhome/root/etc/config/AdGuardHome Executable file → Normal file
View File

@ -1,19 +1,11 @@
config AdGuardHome 'AdGuardHome'
option enabled '0'
option httpport '3000'
option redirect 'dnsmasq-upstream'
option redirect 'none'
option configpath '/etc/AdGuardHome.yaml'
option workdir '/tmp/AdGuardHome'
option workdir '/etc/AdGuardHome'
option logfile '/tmp/AdGuardHome.log'
option verbose '0'
option binpath '/usr/bin/AdGuardHome'
option upxflag '-1'
option upxflag ''
option waitonboot '0'
option update_url 'https://github.com/AdguardTeam/AdGuardHome/releases/download/${Cloud_Version}/AdGuardHome_linux_${Arch}.tar.gz'
option ucitracktest '2'
list old_redirect 'dnsmasq-upstream'
list old_port '5553'
list old_enabled '0'
option version 'v0.107.26'

49
luci-app-adguardhome/root/etc/init.d/AdGuardHome Executable file → Normal file
View File

@ -7,12 +7,12 @@ STOP=01
CONFIGURATION=AdGuardHome
CRON_FILE=/etc/crontabs/root
EXTRA_COMMANDS="do_redirect testbackup test_crontab force_reload isrunning"
EXTRA_HELP=" do_redirect 0 or 1\
testbackup backup or restore\
test_crontab
force_reload
isrunning"
extra_command "do_redirect" "0 or 1"
extra_command "testbackup" "backup or restore"
extra_command "test_crontab"
extra_command "force_reload"
extra_command "isrunning"
set_forward_dnsmasq()
{
@ -50,9 +50,7 @@ stop_forward_dnsmasq()
uci del_list dhcp.@dnsmasq[0].server=$addr 2>/dev/null
addrlist="`uci get dhcp.@dnsmasq[0].server 2>/dev/null`"
if [ -z "$addrlist" ] ; then
resolvfile="/tmp/resolv.conf.d/resolv.conf.auto"
[ ! -f "$resolvfile" ] && resolvfile="/tmp/resolv.conf.auto"
uci set dhcp.@dnsmasq[0].resolvfile="$resolvfile" 2>/dev/null
uci set dhcp.@dnsmasq[0].resolvfile=/tmp/resolv.conf.d/resolv.conf.auto 2>/dev/null
uci delete dhcp.@dnsmasq[0].noresolv 2>/dev/null
fi
uci commit dhcp
@ -76,9 +74,9 @@ EOF
for IP in $IPS
do
if [ "$tcp_server" == "1" ]; then
iptables -t nat -A PREROUTING -p tcp -d $IP --dport 53 -j REDIRECT --to-ports $AdGuardHome_PORT >/dev/null 2>&1
iptables -t nat -I PREROUTING -p tcp -d $IP --dport 53 -j REDIRECT --to-ports $AdGuardHome_PORT >/dev/null 2>&1
fi
iptables -t nat -A PREROUTING -p udp -d $IP --dport 53 -j REDIRECT --to-ports $AdGuardHome_PORT >/dev/null 2>&1
iptables -t nat -I PREROUTING -p udp -d $IP --dport 53 -j REDIRECT --to-ports $AdGuardHome_PORT >/dev/null 2>&1
done
if [ "$ipv6_server" == 0 ]; then
@ -89,9 +87,9 @@ EOF
for IP in $IPS
do
if [ "$tcp_server" == "1" ]; then
ip6tables -t nat -A PREROUTING -p tcp -d $IP --dport 53 -j REDIRECT --to-ports $AdGuardHome_PORT >/dev/null 2>&1
ip6tables -t nat -I PREROUTING -p tcp -d $IP --dport 53 -j REDIRECT --to-ports $AdGuardHome_PORT >/dev/null 2>&1
fi
ip6tables -t nat -A PREROUTING -p udp -d $IP --dport 53 -j REDIRECT --to-ports $AdGuardHome_PORT >/dev/null 2>&1
ip6tables -t nat -I PREROUTING -p udp -d $IP --dport 53 -j REDIRECT --to-ports $AdGuardHome_PORT >/dev/null 2>&1
done
}
@ -136,7 +134,7 @@ isrunning(){
}
_isrunning(){
config_get binpath $CONFIGURATION binpath "/usr/bin/AdGuardHome/AdGuardHome"
config_get binpath $CONFIGURATION binpath "/usr/bin/AdGuardHome"
[ ! -f "$binpath" ] && return 2
pgrep $binpath 2>&1 >/dev/null && return 0
return 1
@ -188,7 +186,7 @@ rm_port53()
config_editor "dns.port" "$dnsmasq_port" "$configpath"
uci set dhcp.@dnsmasq[0].port="53"
uci commit dhcp
config_get binpath $CONFIGURATION binpath "/usr/bin/AdGuardHome/AdGuardHome"
config_get binpath $CONFIGURATION binpath "/usr/bin/AdGuardHome"
killall -9 $binpath
/etc/init.d/dnsmasq restart
}
@ -210,7 +208,7 @@ use_port53()
config_editor "dns.port" "53" "$configpath"
uci set dhcp.@dnsmasq[0].port="$AdGuardHome_PORT"
uci commit dhcp
/etc/init.d/dnsmasq restart
/etc/init.d/dnsmasq reload
}
do_redirect()
@ -244,7 +242,6 @@ _do_redirect()
config_get "old_port" "$section" "old_port" "0"
config_get "old_enabled" "$section" "old_enabled" "0"
uci get dhcp.@dnsmasq[0].port >/dev/null 2>&1 || uci set dhcp.@dnsmasq[0].port="53" >/dev/null 2>&1
uci commit dhcp
if [ "$old_enabled" = "1" -a "$old_redirect" == "exchange" ]; then
AdGuardHome_PORT=$(uci get dhcp.@dnsmasq[0].port 2>/dev/null)
fi
@ -353,7 +350,7 @@ boot_service() {
config_load "${CONFIGURATION}"
config_get waitonboot $CONFIGURATION waitonboot "0"
config_get_bool enabled $CONFIGURATION enabled 0
config_get binpath $CONFIGURATION binpath "/usr/bin/AdGuardHome/AdGuardHome"
config_get binpath $CONFIGURATION binpath "/usr/bin/AdGuardHome"
[ -f "$binpath" ] && start_service
if [ "$enabled" == "1" ] && [ "$waitonboot" == "1" ]; then
procd_open_instance "waitnet"
@ -374,15 +371,15 @@ testbackup(){
restore()
{
config_get workdir $CONFIGURATION workdir "/usr/bin/AdGuardHome"
config_get backupwdpath $CONFIGURATION backupwdpath "/usr/bin/AdGuardHome"
config_get workdir $CONFIGURATION workdir "/etc/AdGuardHome"
config_get backupwdpath $CONFIGURATION backupwdpath "/etc/AdGuardHome"
cp -u -r -f $backupwdpath/data $workdir
}
backup() {
config_get backupwdpath $CONFIGURATION backupwdpath "/usr/bin/AdGuardHome"
config_get backupwdpath $CONFIGURATION backupwdpath "/etc/AdGuardHome"
mkdir -p $backupwdpath/data
config_get workdir $CONFIGURATION workdir "/usr/bin/AdGuardHome"
config_get workdir $CONFIGURATION workdir "/etc/AdGuardHome"
config_get backupfile $CONFIGURATION backupfile ""
for one in $backupfile;
do
@ -427,7 +424,7 @@ start_service() {
return
fi
#what need to do before reload
config_get workdir $CONFIGURATION workdir "/usr/bin/AdGuardHome"
config_get workdir $CONFIGURATION workdir "/etc/AdGuardHome"
config_get backupfile $CONFIGURATION backupfile ""
mkdir -p $workdir/data
@ -452,7 +449,7 @@ start_service() {
fi
fi
local ADDITIONAL_ARGS=""
config_get binpath $CONFIGURATION binpath "/usr/bin/AdGuardHome/AdGuardHome"
config_get binpath $CONFIGURATION binpath "/usr/bin/AdGuardHome"
mkdir -p ${binpath%/*}
ADDITIONAL_ARGS="$ADDITIONAL_ARGS -c $configpath"
@ -577,8 +574,8 @@ do_crontab(){
[ "$enabled" == "0" ] || [ "${crontab//autoupdate/}" == "$crontab" ] && cronenable=0 || cronenable=1
crontab_editor
config_get workdir $CONFIGURATION workdir "/usr/bin/AdGuardHome"
config_get lastworkdir $CONFIGURATION lastworkdir "/usr/bin/AdGuardHome"
config_get workdir $CONFIGURATION workdir "/etc/AdGuardHome"
config_get lastworkdir $CONFIGURATION lastworkdir "/etc/AdGuardHome"
findstr="/usr/share/AdGuardHome/tailto.sh [0-9]* \$(uci get AdGuardHome.AdGuardHome.workdir)/data/querylog.json"
#[ -n "$lastworkdir" ] && findstr="/usr/share/AdGuardHome/tailto.sh [0-9]* $lastworkdir/data/querylog.json" && [ "$lastworkdir" != "$workdir" ] && replace="${lastworkdir//\//\\/}/${workdir//\//\\/}"
default="0 * * * * /usr/share/AdGuardHome/tailto.sh 2000 \$(uci get AdGuardHome.AdGuardHome.workdir)/data/querylog.json"

View File

@ -6,7 +6,10 @@ uci -q batch <<-EOF >/dev/null 2>&1
set ucitrack.@AdGuardHome[-1].init=AdGuardHome
commit ucitrack
delete AdGuardHome.AdGuardHome.ucitracktest
/etc/init.d/AdGuardHome restart
EOF
rm -f /tmp/luci-indexcache
chmod +x /etc/init.d/AdGuardHome /usr/share/AdGuardHome/*
exit 0

View File

@ -11,7 +11,8 @@ language: zh-cn
debug_pprof: false
web_session_ttl: 720
dns:
bind_host: 0.0.0.0
bind_hosts:
- 0.0.0.0
port: 1745
statistics_interval: 30
querylog_enabled: true
@ -98,14 +99,7 @@ filters:
name: 'CHN: anti-AD'
id: 1628750871
whitelist_filters: []
user_rules:
- '@@||taobao.com^$important'
- '@@||jd.com^important'
- '@@||flyme.cn^$important'
- '@@||meizu.com^$important'
- '@@||wl.jd.com^$important'
- '@@||flydigi.com^'
- '@@||pv.sohu.com^$important'
user_rules: []
dhcp:
enabled: false
interface_name: ""
@ -130,4 +124,8 @@ log_max_size: 100
log_max_age: 3
log_file: ""
verbose: false
schema_version: 7
os:
group: ""
user: ""
rlimit_nofile: 0
schema_version: 12

View File

View File

@ -1,3 +1,3 @@
https://static.adguard.com/adguardhome/beta/AdGuardHome_linux_${Arch}.tar.gz
https://github.com/AdguardTeam/AdGuardHome/releases/download/${latest_ver}/AdGuardHome_linux_${Arch}.tar.gz
https://static.adguard.com/adguardhome/release/AdGuardHome_linux_${Arch}.tar.gz
https://static.adguard.com/adguardhome/beta/AdGuardHome_linux_${Arch}.tar.gz

View File

@ -1,218 +1,236 @@
#!/bin/sh
#!/bin/bash
PATH="/usr/sbin:/usr/bin:/sbin:/bin"
update_mode=$1
binpath=$(uci get AdGuardHome.AdGuardHome.binpath)
if [[ -z ${binpath} ]]; then
uci set AdGuardHome.AdGuardHome.binpath="/tmp/AdGuardHome/AdGuardHome"
binpath="/tmp/AdGuardHome/AdGuardHome"
if [ -z "$binpath" ]; then
uci set AdGuardHome.AdGuardHome.binpath="/tmp/AdGuardHome/AdGuardHome"
binpath="/tmp/AdGuardHome/AdGuardHome"
fi
[[ ! -d ${binpath%/*} ]] && mkdir -p ${binpath%/*}
mkdir -p ${binpath%/*}
upxflag=$(uci get AdGuardHome.AdGuardHome.upxflag 2>/dev/null)
[[ -z ${upxflag} ]] && upxflag=off
enabled=$(uci get AdGuardHome.AdGuardHome.enabled 2>/dev/null)
core_version=$(uci get AdGuardHome.AdGuardHome.core_version 2>/dev/null)
update_url=$(uci get AdGuardHome.AdGuardHome.update_url 2>/dev/null)
case "${core_version}" in
beta)
core_api_url=https://api.github.com/repos/AdguardTeam/AdGuardHome/releases
;;
*)
core_api_url=https://api.github.com/repos/AdguardTeam/AdGuardHome/releases/latest
;;
esac
Check_Task(){
running_tasks="$(ps -efww | grep -v grep | grep "AdGuardHome" | grep "update_core" | awk '{print $1}' | wc -l)"
case $1 in
force)
echo -e "执行: 强制更新核心"
echo -e "清除 ${running_tasks} 个进程 ..."
ps -efww | grep -v grep | grep -v $$ | grep "AdGuardHome" | grep "update_core" | awk '{print $1}' | xargs kill -9 2> /dev/null
;;
*)
[[ ${running_tasks} -gt 2 ]] && echo -e "已经有 ${running_tasks} 个任务正在运行, 请等待其执行结束或将其强行停止!" && EXIT 2
;;
esac
check_if_already_running(){
running_tasks="$(ps |grep "AdGuardHome" |grep "update_core" |grep -v "grep" |awk '{print $1}' |wc -l)"
[ "${running_tasks}" -gt "2" ] && echo -e "\nA task is already running." && EXIT 2
}
Check_Downloader(){
which curl > /dev/null 2>&1 && PKG="curl" && return
echo -e "\n未安装 curl"
which wget-ssl > /dev/null 2>&1 && PKG="wget-ssl" && return
echo "未安装 curl 和 wget, 无法检测更新!" && EXIT 1
check_wgetcurl(){
which curl && downloader="curl -L -k --retry 2 --connect-timeout 20 -o" && return
which wget-ssl && downloader="wget-ssl --no-check-certificate -t 2 -T 20 -O" && return
[ -z "$1" ] && opkg update || (echo error opkg && EXIT 1)
[ -z "$1" ] && (opkg remove wget wget-nossl --force-depends ; opkg install wget ; check_wgetcurl 1 ;return)
[ "$1" == "1" ] && (opkg install curl ; check_wgetcurl 2 ; return)
echo error curl and wget && EXIT 1
}
Check_Updates(){
Check_Downloader
case "${PKG}" in
curl)
Downloader="curl -L -k -o"
_Downloader="curl -s"
;;
wget-ssl)
Downloader="wget-ssl --no-check-certificate -T 5 -O"
_Downloader="wget-ssl -q -O -"
;;
esac
echo "[${PKG}] 开始检查更新, 请耐心等待 ..."
Cloud_Version="$(${_Downloader} ${core_api_url} 2>/dev/null | grep 'tag_name' | egrep -o "v[0-9].+[0-9.]" | awk 'NR==1')"
[[ -z ${Cloud_Version} ]] && echo -e "\n检查更新失败, 请检查网络或稍后重试!" && EXIT 1
if [[ -f ${binpath} ]]; then
Current_Version="$(${binpath} --version 2>/dev/null | egrep -o "v[0-9].+[0-9]" | sed -r 's/(.*), c(.*)/\1/')"
else
Current_Version="未知"
check_latest_version(){
check_wgetcurl
latest_ver="$($downloader - https://api.github.com/repos/AdguardTeam/AdGuardHome/releases/latest 2>/dev/null|grep -E 'tag_name' |grep -E 'v[0-9.]+' -o 2>/dev/null)"
if [ -z "${latest_ver}" ]; then
echo -e "\nFailed to check latest version, please try again later." && EXIT 1
fi
[[ -z ${Current_Version} ]] && Current_Version="未知"
echo -e "\n执行文件路径: ${binpath%/*}\n\n正在检查更新, 请耐心等待 ..."
echo -e "\n当前 AdGuardHome 版本: ${Current_Version}\n云端 AdGuardHome 版本: ${Cloud_Version}"
if [[ ! "${Cloud_Version}" == "${Current_Version}" || "$1" == force ]]; then
Update_Core
now_ver="$($binpath -c /dev/null --check-config 2>&1| grep -m 1 -E 'v[0-9.]+' -o)"
if [ "${latest_ver}"x != "${now_ver}"x ] || [ "$1" == "force" ]; then
echo -e "Local version: ${now_ver}., cloud version: ${latest_ver}."
doupdate_core
else
echo -e "\n已是最新版本, 无需更新!"
echo -e "\nLocal version: ${now_ver}, cloud version: ${latest_ver}."
echo -e "You're already using the latest version."
if [ ! -z "$upxflag" ]; then
filesize=$(ls -l $binpath | awk '{ print $5 }')
if [ $filesize -gt 8000000 ]; then
echo -e "start upx may take a long time"
doupx
mkdir -p "/tmp/AdGuardHomeupdate/AdGuardHome" >/dev/null 2>&1
rm -fr /tmp/AdGuardHomeupdate/AdGuardHome/${binpath##*/}
/tmp/upx-${upx_latest_ver}-${Arch}_linux/upx $upxflag $binpath -o /tmp/AdGuardHomeupdate/AdGuardHome/${binpath##*/}
rm -rf /tmp/upx-${upx_latest_ver}-${Arch}_linux
/etc/init.d/AdGuardHome stop nobackup
rm $binpath
mv -f /tmp/AdGuardHomeupdate/AdGuardHome/${binpath##*/} $binpath
/etc/init.d/AdGuardHome start
echo -e "finished"
fi
fi
EXIT 0
fi
}
doupx(){
Archt="$(opkg info kernel | grep Architecture | awk -F "[ _]" '{print($2)}')"
case $Archt in
"i386")
Arch="i386"
;;
"i686")
Arch="i386"
echo -e "i686 use $Arch may have bug"
;;
"x86")
Arch="amd64"
;;
"mipsel")
Arch="mipsel"
;;
"mips64el")
Arch="mips64el"
Arch="mipsel"
echo -e "mips64el use $Arch may have bug"
;;
"mips")
Arch="mips"
;;
"mips64")
Arch="mips64"
Arch="mips"
echo -e "mips64 use $Arch may have bug"
;;
"arm")
Arch="arm"
;;
"armeb")
Arch="armeb"
;;
"aarch64")
Arch="arm64"
;;
"powerpc")
Arch="powerpc"
;;
"powerpc64")
Arch="powerpc64"
;;
*)
echo -e "error not support $Archt if you can use offical release please issue a bug"
EXIT 1
;;
esac
upx_latest_ver="$($downloader - https://api.github.com/repos/upx/upx/releases/latest 2>/dev/null|grep -E 'tag_name' |grep -E '[0-9.]+' -o 2>/dev/null)"
$downloader /tmp/upx-${upx_latest_ver}-${Arch}_linux.tar.xz "https://github.com/upx/upx/releases/download/v${upx_latest_ver}/upx-${upx_latest_ver}-${Arch}_linux.tar.xz" 2>&1
#tar xvJf
which xz || (opkg list | grep ^xz || opkg update && opkg install xz) || (echo "xz download fail" && EXIT 1)
mkdir -p /tmp/upx-${upx_latest_ver}-${Arch}_linux
xz -d -c /tmp/upx-${upx_latest_ver}-${Arch}_linux.tar.xz| tar -x -C "/tmp" >/dev/null 2>&1
if [ ! -e "/tmp/upx-${upx_latest_ver}-${Arch}_linux/upx" ]; then
echo -e "Failed to download upx."
EXIT 1
fi
rm /tmp/upx-${upx_latest_ver}-${Arch}_linux.tar.xz
}
doupdate_core(){
echo -e "Updating core..."
mkdir -p "/tmp/AdGuardHomeupdate"
rm -rf /tmp/AdGuardHomeupdate/* >/dev/null 2>&1
Archt="$(opkg info kernel | grep Architecture | awk -F "[ _]" '{print($2)}')"
case $Archt in
"i386")
Arch="386"
;;
"i686")
Arch="386"
;;
"x86")
Arch="amd64"
;;
"mipsel")
Arch="mipsle"
;;
"mips64el")
Arch="mips64le"
Arch="mipsle"
echo -e "mips64el use $Arch may have bug"
;;
"mips")
Arch="mips"
;;
"mips64")
Arch="mips64"
Arch="mips"
echo -e "mips64 use $Arch may have bug"
;;
"arm")
Arch="arm"
;;
"aarch64")
Arch="arm64"
;;
"powerpc")
Arch="ppc"
echo -e "error not support $Archt"
EXIT 1
;;
"powerpc64")
Arch="ppc64"
echo -e "error not support $Archt"
EXIT 1
;;
*)
echo -e "error not support $Archt if you can use offical release please issue a bug"
EXIT 1
;;
esac
echo -e "start download"
grep -v "^#" /usr/share/AdGuardHome/links.txt >/tmp/run/AdHlinks.txt
while read link
do
eval link="$link"
$downloader /tmp/AdGuardHomeupdate/${link##*/} "$link" 2>&1
if [ "$?" != "0" ]; then
echo "download failed try another download"
rm -f /tmp/AdGuardHomeupdate/${link##*/}
else
local success="1"
break
fi
done < "/tmp/run/AdHlinks.txt"
rm /tmp/run/AdHlinks.txt
[ -z "$success" ] && echo "no download success" && EXIT 1
if [ "${link##*.}" == "gz" ]; then
tar -zxf "/tmp/AdGuardHomeupdate/${link##*/}" -C "/tmp/AdGuardHomeupdate/"
if [ ! -e "/tmp/AdGuardHomeupdate/AdGuardHome" ]; then
echo -e "Failed to download core."
rm -rf "/tmp/AdGuardHomeupdate" >/dev/null 2>&1
EXIT 1
fi
downloadbin="/tmp/AdGuardHomeupdate/AdGuardHome/AdGuardHome"
else
downloadbin="/tmp/AdGuardHomeupdate/${link##*/}"
fi
chmod 755 $downloadbin
echo -e "download success start copy"
if [ -n "$upxflag" ]; then
echo -e "start upx may take a long time"
doupx
/tmp/upx-${upx_latest_ver}-${Arch}_linux/upx $upxflag $downloadbin
rm -rf /tmp/upx-${upx_latest_ver}-${Arch}_linux
fi
echo -e "start copy"
/etc/init.d/AdGuardHome stop nobackup
rm "$binpath"
mv -f "$downloadbin" "$binpath"
if [ "$?" == "1" ]; then
echo "mv failed maybe not enough space please use upx or change bin to /tmp/AdGuardHome"
EXIT 1
fi
/etc/init.d/AdGuardHome start
rm -rf "/tmp/AdGuardHomeupdate" >/dev/null 2>&1
echo -e "Succeeded in updating core."
echo -e "Local version: ${latest_ver}, cloud version: ${latest_ver}.\n"
EXIT 0
}
UPX_Compress(){
GET_Arch
upx_name="upx-${upx_latest_ver}-${Arch_upx}_linux.tar.xz"
echo -e "开始下载 ${upx_name} ...\n"
$Downloader /tmp/upx-${upx_latest_ver}-${Arch_upx}_linux.tar.xz "https://github.com/upx/upx/releases/download/v${upx_latest_ver}/${upx_name}"
if [[ ! -e /tmp/upx-${upx_latest_ver}-${Arch_upx}_linux.tar.xz ]]; then
echo -e "\n${upx_name} 下载失败!\n"
EXIT 1
else
echo -e "\n${upx_name} 下载成功!\n"
fi
which xz > /dev/null 2>&1 || (opkg list | grep ^xz || opkg update > /dev/null 2>&1 && opkg install xz --force-depends) || (echo "软件包 xz 安装失败!" && EXIT 1)
mkdir -p /tmp/upx-${upx_latest_ver}-${Arch_upx}_linux
echo -e "正在解压 ${upx_name} ...\n"
xz -d -c /tmp/upx-${upx_latest_ver}-${Arch_upx}_linux.tar.xz | tar -x -C "/tmp"
[[ ! -f /tmp/upx-${upx_latest_ver}-${Arch_upx}_linux/upx ]] && echo -e "\n${upx_name} 解压失败!" && EXIT 1
}
Update_Core(){
rm -r /tmp/AdGuardHome_Update > /dev/null 2>&1
mkdir -p "/tmp/AdGuardHome_Update"
GET_Arch
eval link="${update_url}"
echo -e "下载链接:${link}"
echo -e "文件名称:${link##*/}"
echo -e "\n开始下载 AdGuardHome 核心文件 ...\n"
$Downloader /tmp/AdGuardHome_Update/${link##*/} ${link}
if [[ $? != 0 ]];then
echo -e "\nAdGuardHome 核心下载失败 ..."
rm -r /tmp/AdGuardHome_Update
EXIT 1
fi
if [[ ${link##*.} == gz ]]; then
echo -e "\n正在解压 AdGuardHome ..."
tar -zxf "/tmp/AdGuardHome_Update/${link##*/}" -C "/tmp/AdGuardHome_Update/"
if [[ ! -e /tmp/AdGuardHome_Update/AdGuardHome ]]
then
echo "AdGuardHome 核心解压失败!"
rm -rf "/tmp/AdGuardHome_Update" > /dev/null 2>&1
EXIT 1
fi
downloadbin="/tmp/AdGuardHome_Update/AdGuardHome/AdGuardHome"
else
downloadbin="/tmp/AdGuardHome_Update/${link##*/}"
fi
chmod +x ${downloadbin}
echo -e "\nAdGuardHome 核心体积: $(awk 'BEGIN{printf "%.2fMB\n",'$((`ls -l $downloadbin | awk '{print $5}'`))'/1000000}')"
if [[ ${upxflag} != off ]]; then
UPX_Compress
echo -e "使用 UPX 压缩可能会花很长时间, 期间请耐心等待!\n正在压缩 $downloadbin ..."
/tmp/upx-${upx_latest_ver}-${Arch_upx}_linux/upx $upxflag $downloadbin > /dev/null 2>&1
echo -e "\n压缩后的核心体积: $(awk 'BEGIN{printf "%.2fMB\n",'$((`ls -l $downloadbin | awk '{print $5}'`))'/1000000}')"
else
echo "未启用 UPX 压缩, 跳过操作..."
fi
/etc/init.d/AdGuardHome stop > /dev/null 2>&1
echo -e "\n移动 AdGuardHome 核心文件到 ${binpath%/*} ..."
mv -f ${downloadbin} ${binpath} > /dev/null 2>&1
if [[ ! -s ${binpath} && $? != 0 ]]; then
echo -e "AdGuardHome 核心移动失败!\n可能是设备空间不足导致, 请尝试开启 UPX 压缩, 或更改 [执行文件路径] 为 /tmp/AdGuardHome"
EXIT 1
fi
rm -f /tmp/upx*.tar.xz
rm -rf /tmp/upx*
rm -rf /tmp/AdGuardHome_Update
chmod +x ${binpath}
if [[ ${enabled} == 1 ]]; then
echo -e "\n正在重启 AdGuardHome 服务..."
/etc/init.d/AdGuardHome restart
fi
echo -e "\nAdGuardHome 核心更新成功!"
}
GET_Arch() {
Archt="$(opkg info kernel | grep Architecture | awk -F "[ _]" '{print($2)}')"
case "${Archt}" in
i386)
Arch=i386
;;
i686)
Arch=i386
;;
x86)
Arch=amd64
;;
mipsel)
Arch=mipsle_softfloat
;;
mips)
Arch=mips_softfloat
;;
mips64el)
Arch=mips64le_softfloat
;;
mips64)
Arch=mips64_softfloat
;;
arm)
Arch=arm
;;
armeb)
Arch=armeb
;;
aarch64)
Arch=arm64
;;
*)
echo -e "\nAdGuardHome 暂不支持当前的设备架构: [${Archt}]!"
EXIT 1
esac
case "${Archt}" in
mipsel)
Arch_upx="mipsel"
upx_latest_ver="3.95"
;;
*)
Arch_upx="${Arch}"
upx_latest_ver="$(${_Downloader} https://api.github.com/repos/upx/upx/releases/latest 2>/dev/null | egrep 'tag_name' | egrep '[0-9.]+' -o 2>/dev/null)"
esac
echo -e "\n当前设备架构: ${Arch}\n"
}
EXIT(){
rm -rf /var/run/update_core $LOCKU 2>/dev/null
[[ $1 != 0 ]] && touch /var/run/update_core_error
rm /var/run/update_core 2>/dev/null
[ "$1" != "0" ] && touch /var/run/update_core_error
exit $1
}
main(){
Check_Task ${update_mode}
Check_Updates ${update_mode}
check_if_already_running
check_latest_version $1
}
trap "EXIT 1" SIGTERM SIGINT
touch /var/run/update_core
rm - rf /var/run/update_core_error 2>/dev/null
main
trap "EXIT 1" SIGTERM SIGINT
touch /var/run/update_core
rm /var/run/update_core_error 2>/dev/null
main $1