mirror of
https://github.com/coolsnowwolf/lede.git
synced 2025-04-16 04:13:31 +00:00
luci-app-adbyby-plus: refactoring new version
This commit is contained in:
parent
af3c61718c
commit
0740c83268
@ -8,7 +8,7 @@ include $(TOPDIR)/rules.mk
|
||||
|
||||
PKG_NAME:=adbyby
|
||||
PKG_VERSION:=2.7
|
||||
PKG_RELEASE:=20200308
|
||||
PKG_RELEASE:=20200310
|
||||
|
||||
include $(INCLUDE_DIR)/package.mk
|
||||
|
||||
@ -61,8 +61,6 @@ endef
|
||||
define Package/$(PKG_NAME)/install
|
||||
$(INSTALL_DIR) $(1)/usr/share/adbyby
|
||||
$(INSTALL_BIN) ./files/adbyby.sh $(1)/usr/share/adbyby/
|
||||
$(INSTALL_BIN) ./files/adbybyfirst.sh $(1)/usr/share/adbyby/
|
||||
$(INSTALL_BIN) ./files/adbybyupdate.sh $(1)/usr/share/adbyby/
|
||||
$(INSTALL_CONF) ./files/adhook.ini $(1)/usr/share/adbyby/
|
||||
$(INSTALL_CONF) ./files/user.action $(1)/usr/share/adbyby/
|
||||
|
||||
|
@ -1,11 +0,0 @@
|
||||
#!/bin/sh
|
||||
PROG_PATH=/usr/share/adbyby
|
||||
if [ -z "$(dnsmasq --version | grep no-ipset)" ]; then
|
||||
[ $(uci get adbyby.@adbyby[-1].wan_mode) -ne 2 ] && \
|
||||
[ $(awk -F= '/^ipset/{print $2}' $PROG_PATH/adhook.ini) -eq 1 ] && \
|
||||
{
|
||||
sed -i 's/adbyby_list/adbyby_wan/' /tmp/adbyby_host.conf
|
||||
echo conf-file=/tmp/adbyby_host.conf >> /etc/dnsmasq.conf
|
||||
/etc/init.d/dnsmasq restart
|
||||
}
|
||||
fi
|
@ -1,11 +0,0 @@
|
||||
#!/bin/sh
|
||||
PROG_PATH=/usr/share/adbyby
|
||||
if [ -z "$(dnsmasq --version | grep no-ipset)" ]; then
|
||||
[ $(uci get adbyby.@adbyby[-1].wan_mode) -ne 2 ] && \
|
||||
[ $(awk -F= '/^ipset/{print $2}' $PROG_PATH/adhook.ini) -eq 1 ] && \
|
||||
{
|
||||
sed -i 's/adbyby_list/adbyby_wan/' /tmp/adbyby_host.conf
|
||||
ipset -F adbyby_wan 2>/dev/null
|
||||
/etc/init.d/dnsmasq restart
|
||||
}
|
||||
fi
|
@ -10,7 +10,7 @@ LUCI_DEPENDS:=+adbyby +wget +ipset +dnsmasq-full
|
||||
LUCI_PKGARCH:=all
|
||||
PKG_NAME:=luci-app-adbyby-plus
|
||||
PKG_VERSION:=2.0
|
||||
PKG_RELEASE:=46
|
||||
PKG_RELEASE:=48
|
||||
|
||||
include $(TOPDIR)/feeds/luci/luci.mk
|
||||
|
||||
|
@ -6,7 +6,13 @@ function index()
|
||||
return
|
||||
end
|
||||
|
||||
entry({"admin", "services", "adbyby"}, cbi("adbyby"), _("ADBYBY Plus +"), 10).dependent = true
|
||||
entry({"admin", "services", "adbyby"}, alias("admin", "services", "adbyby", "base"),_("ADBYBY Plus +"), 9).dependent = true
|
||||
|
||||
entry({"admin", "services", "adbyby", "base"}, cbi("adbyby/base"), _("Base Setting"), 10).leaf=true
|
||||
entry({"admin", "services", "adbyby", "advanced"}, cbi("adbyby/advanced"), _("Advance Setting"), 20).leaf=true
|
||||
entry({"admin", "services", "adbyby", "help"}, form("adbyby/help"), _("Plus+ Domain List"), 30).leaf=true
|
||||
|
||||
|
||||
entry({"admin","services","adbyby","status"},call("act_status")).leaf=true
|
||||
end
|
||||
|
||||
|
@ -1,167 +0,0 @@
|
||||
|
||||
local NXFS = require "nixio.fs"
|
||||
local SYS = require "luci.sys"
|
||||
local HTTP = require "luci.http"
|
||||
local DISP = require "luci.dispatcher"
|
||||
|
||||
local DL = SYS.exec("head -1 /tmp/adbyby/data/lazy.txt | awk -F' ' '{print $3,$4}'") or ""
|
||||
local DV = SYS.exec("head -1 /tmp/adbyby/data/video.txt | awk -F' ' '{print $3,$4}'") or ""
|
||||
local NR = SYS.exec("grep -v '^!' /usr/share/adbyby/data/rules.txt | wc -l")
|
||||
local NU = SYS.exec("cat /usr/share/adbyby/data/user.txt | wc -l")
|
||||
local UD = NXFS.readfile("/tmp/adbyby.updated") or "1970-01-01 00:00:00"
|
||||
local ND = SYS.exec("cat /usr/share/adbyby/dnsmasq.adblock | wc -l")
|
||||
|
||||
m = Map("adbyby")
|
||||
m.title = translate("Adbyby Plus +")
|
||||
m.description = translate("Adbyby Plus + can filter all kinds of banners, popups, video ads, and prevent tracking, privacy theft and a variety of malicious websites<br /><font color=\"red\">Plus + version combination mode can operation with Adblock Plus Host,filtering ads without losing bandwidth</font>")
|
||||
|
||||
m:section(SimpleSection).template = "adbyby/adbyby_status"
|
||||
|
||||
s = m:section(TypedSection, "adbyby")
|
||||
s.anonymous = true
|
||||
|
||||
s:tab("basic", translate("Base Setting"))
|
||||
|
||||
o = s:taboption("basic", Flag, "enable")
|
||||
o.title = translate("Enable")
|
||||
o.default = 0
|
||||
o.rmempty = false
|
||||
|
||||
o = s:taboption("basic", ListValue, "wan_mode")
|
||||
o.title = translate("Running Mode")
|
||||
o:value("0", translate("Global Mode(The slowest, the best effects)"))
|
||||
o:value("1", translate("Plus + Mode(Filter domain name list and blacklist website.Recommended)"))
|
||||
o:value("2", translate("No filter Mode (Must set in Client Filter Mode Settings manually)"))
|
||||
o.default = 1
|
||||
o.rmempty = false
|
||||
|
||||
o = s:taboption("basic", Button, "restart")
|
||||
o.title = translate("Adbyby and Rule state")
|
||||
o.inputtitle = translate("Restart Adbyby")
|
||||
o.description = string.format("<strong>"..translate("Last Update Checked")..":</strong> %s<br /><strong>"..translate("Lazy Rule")..":</strong>%s <br /><strong>"..translate("Video Rule")..":</strong>%s", UD, DL, DV)
|
||||
o.inputstyle = "reload"
|
||||
o.write = function()
|
||||
SYS.call("rm -rf /tmp/adbyby.updated && /usr/share/adbyby/admem.sh > /tmp/adupdate.log 2>&1 &")
|
||||
SYS.call("sleep 5")
|
||||
HTTP.redirect(DISP.build_url("admin", "services", "adbyby"))
|
||||
end
|
||||
|
||||
s:tab("advanced", translate("Advance Setting"))
|
||||
|
||||
o = s:taboption("advanced", Flag, "cron_mode")
|
||||
o.title = translate("Update the rule at 6 a.m. every morning and restart adbyby")
|
||||
o.default = 0
|
||||
o.rmempty = false
|
||||
o.description = translate(string.format("<strong><font color=blue>Adblock Plus Host List:</font></strong> %s Lines<br /><br />", ND))
|
||||
|
||||
updatead = s:taboption("advanced", Button, "updatead", translate("Manually force update<br />Adblock Plus Host List"), translate("Note: It needs to download and convert the rules. The background process may takes 60-120 seconds to run. <br / > After completed it would automatically refresh, please do not duplicate click!"))
|
||||
updatead.inputtitle = translate("Manually force update")
|
||||
updatead.inputstyle = "apply"
|
||||
updatead.write = function()
|
||||
SYS.call("nohup sh /usr/share/adbyby/adblock.sh > /tmp/adupdate.log 2>&1 &")
|
||||
end
|
||||
|
||||
o = s:taboption("advanced", Flag, "block_ios")
|
||||
o.title = translate("Block Apple iOS OTA update")
|
||||
o.default = 0
|
||||
o.rmempty = false
|
||||
|
||||
s:tab("help", translate("Plus+ Domain List"))
|
||||
|
||||
local conf = "/usr/share/adbyby/adhost.conf"
|
||||
o = s:taboption("help", TextValue, "conf")
|
||||
o.description = translate("(!)Note that you should fill to the domain name ONLY. For example, http://www.baidu.com only needs to write to baidu.com. One line for each")
|
||||
o.rows = 13
|
||||
o.wrap = "off"
|
||||
o.cfgvalue = function(self, section)
|
||||
return NXFS.readfile(conf) or ""
|
||||
end
|
||||
o.write = function(self, section, value)
|
||||
NXFS.writefile(conf, value:gsub("\r\n", "\n"))
|
||||
--SYS.call("/etc/init.d/adbyby restart")
|
||||
end
|
||||
|
||||
s:tab("esc", translate("Bypass Domain List"))
|
||||
|
||||
local escconf = "/usr/share/adbyby/adesc.conf"
|
||||
o = s:taboption("esc", TextValue, "escconf")
|
||||
o.description = translate("(!)Will Never filter these Domain")
|
||||
o.rows = 13
|
||||
o.wrap = "off"
|
||||
o.cfgvalue = function(self, section)
|
||||
return NXFS.readfile(escconf) or ""
|
||||
end
|
||||
o.write = function(self, section, value)
|
||||
NXFS.writefile(escconf, value:gsub("\r\n", "\n"))
|
||||
--SYS.call("/etc/init.d/adbyby restart")
|
||||
end
|
||||
|
||||
s:tab("black", translate("Black Domain List"))
|
||||
|
||||
local blackconf = "/usr/share/adbyby/adblack.conf"
|
||||
o = s:taboption("black", TextValue, "blackconf")
|
||||
o.description = translate("(!)Will Always block these Domain")
|
||||
o.rows = 13
|
||||
o.wrap = "off"
|
||||
o.cfgvalue = function(self, section)
|
||||
return NXFS.readfile(blackconf) or ""
|
||||
end
|
||||
o.write = function(self, section, value)
|
||||
NXFS.writefile(blackconf, value:gsub("\r\n", "\n"))
|
||||
--SYS.call("/etc/init.d/adbyby restart")
|
||||
end
|
||||
|
||||
s:tab("block", translate("Black IP List"))
|
||||
|
||||
local blockconf = "/usr/share/adbyby/blockip.conf"
|
||||
o = s:taboption("block", TextValue, "blockconf")
|
||||
o.description = translate("(!)Will Always block these IP")
|
||||
o.rows = 13
|
||||
o.wrap = "off"
|
||||
o.cfgvalue = function(self, section)
|
||||
return NXFS.readfile(blockconf) or " "
|
||||
end
|
||||
o.write = function(self, section, value)
|
||||
NXFS.writefile(blockconf, value:gsub("\r\n", "\n"))
|
||||
--SYS.call("/etc/init.d/adbyby restart")
|
||||
end
|
||||
|
||||
s:tab("user", translate("User-defined Rule"))
|
||||
|
||||
local file = "/usr/share/adbyby/rules.txt"
|
||||
o = s:taboption("user", TextValue, "rules")
|
||||
o.description = translate("Each line of the beginning exclamation mark is considered an annotation.")
|
||||
o.rows = 13
|
||||
o.wrap = "off"
|
||||
o.cfgvalue = function(self, section)
|
||||
return NXFS.readfile(file) or ""
|
||||
end
|
||||
o.write = function(self, section, value)
|
||||
NXFS.writefile(file, value:gsub("\r\n", "\n"))
|
||||
end
|
||||
|
||||
t=m:section(TypedSection,"acl_rule",translate("<strong>Client Filter Mode Settings</strong>"),
|
||||
translate("Filter mode settings can be set to specific LAN clients ( <font color=blue> No filter , Global filter </font> ) . Does not need to be set by default."))
|
||||
t.template="cbi/tblsection"
|
||||
t.sortable=true
|
||||
t.anonymous=true
|
||||
t.addremove=true
|
||||
|
||||
e=t:option(Value,"ipaddr",translate("IP Address"))
|
||||
e.width="40%"
|
||||
e.datatype="ip4addr"
|
||||
e.placeholder="0.0.0.0/0"
|
||||
luci.ip.neighbors({ family = 4 }, function(entry)
|
||||
if entry.reachable then
|
||||
e:value(entry.dest:string())
|
||||
end
|
||||
end)
|
||||
|
||||
e=t:option(ListValue,"filter_mode",translate("Filter Mode"))
|
||||
e.width="40%"
|
||||
e.default="disable"
|
||||
e.rmempty=false
|
||||
e:value("disable",translate("No filter"))
|
||||
e:value("global",translate("Global filter"))
|
||||
|
||||
return m
|
@ -0,0 +1,28 @@
|
||||
|
||||
local SYS = require "luci.sys"
|
||||
local ND = SYS.exec("cat /usr/share/adbyby/dnsmasq.adblock | wc -l")
|
||||
|
||||
m = Map("adbyby")
|
||||
|
||||
s = m:section(TypedSection, "adbyby")
|
||||
s.anonymous = true
|
||||
|
||||
o = s:option(Flag, "cron_mode")
|
||||
o.title = translate("Update the rule at 6 a.m. every morning and restart adbyby")
|
||||
o.default = 0
|
||||
o.rmempty = false
|
||||
o.description = string.format("<strong>"..translate("ADP Host List")..":</strong> %s", ND)
|
||||
|
||||
updatead = s:option(Button, "updatead", translate("Manually force update<br />Adblock Plus Host List"), translate("Note: It needs to download and convert the rules. The background process may takes 60-120 seconds to run. <br / > After completed it would automatically refresh, please do not duplicate click!"))
|
||||
updatead.inputtitle = translate("Manually force update")
|
||||
updatead.inputstyle = "apply"
|
||||
updatead.write = function()
|
||||
SYS.call("sh /usr/share/adbyby/adblock.sh > /tmp/adupdate.log 2>&1 &")
|
||||
end
|
||||
|
||||
o = s:option(Flag, "block_ios")
|
||||
o.title = translate("Block Apple iOS OTA update")
|
||||
o.default = 0
|
||||
o.rmempty = false
|
||||
|
||||
return m
|
@ -0,0 +1,70 @@
|
||||
local NXFS = require "nixio.fs"
|
||||
local SYS = require "luci.sys"
|
||||
local HTTP = require "luci.http"
|
||||
local DISP = require "luci.dispatcher"
|
||||
|
||||
local DL = SYS.exec("head -1 /tmp/adbyby/data/lazy.txt | awk -F' ' '{print $3,$4}'") or ""
|
||||
local DV = SYS.exec("head -1 /tmp/adbyby/data/video.txt | awk -F' ' '{print $3,$4}'") or ""
|
||||
local NR = SYS.exec("grep -v '^!' /usr/share/adbyby/data/rules.txt | wc -l")
|
||||
local NU = SYS.exec("cat /usr/share/adbyby/data/user.txt | wc -l")
|
||||
local UD = NXFS.readfile("/tmp/adbyby.updated") or "1970-01-01 00:00:00"
|
||||
local ND = SYS.exec("cat /usr/share/adbyby/dnsmasq.adblock | wc -l")
|
||||
|
||||
m = Map("adbyby")
|
||||
m.title = translate("Adbyby Plus +")
|
||||
m.description = translate("Adbyby Plus + can filter all kinds of banners, popups, video ads, and prevent tracking, privacy theft and a variety of malicious websites<br /><font color=\"red\">Plus + version combination mode can operation with Adblock Plus Host,filtering ads without losing bandwidth</font>")
|
||||
|
||||
m:section(SimpleSection).template = "adbyby/adbyby_status"
|
||||
|
||||
s = m:section(TypedSection, "adbyby")
|
||||
s.anonymous = true
|
||||
|
||||
o = s:option(Flag, "enable")
|
||||
o.title = translate("Enable")
|
||||
o.default = 0
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(ListValue, "wan_mode")
|
||||
o.title = translate("Running Mode")
|
||||
o:value("0", translate("Global Mode (The slowest and the best effects)"))
|
||||
o:value("1", translate("Plus + Mode (Filter domain name list and blacklist website.Recommended)"))
|
||||
o:value("2", translate("No filter Mode (Must set in Client Filter Mode Settings manually)"))
|
||||
o.default = 1
|
||||
o.rmempty = false
|
||||
|
||||
o = s:option(Button, "restart")
|
||||
o.title = translate("Adbyby and Rule state")
|
||||
o.inputtitle = translate("Update Adbyby Rules Manually")
|
||||
o.description = string.format("<strong>"..translate("Last Update Checked")..":</strong> %s<br /><strong>"..translate("Lazy Rule")..":</strong>%s <br /><strong>"..translate("Video Rule")..":</strong>%s", UD, DL, DV)
|
||||
o.inputstyle = "reload"
|
||||
o.write = function()
|
||||
SYS.call("rm -rf /tmp/adbyby.updated /tmp/adbyby/admd5.json && /usr/share/adbyby/adbybyupdate.sh > /tmp/adupdate.log 2>&1 &")
|
||||
SYS.call("sleep 5")
|
||||
HTTP.redirect(DISP.build_url("admin", "services", "adbyby"))
|
||||
end
|
||||
|
||||
t=m:section(TypedSection,"acl_rule",translate("<strong>Client Filter Mode Settings</strong>"),
|
||||
translate("Filter mode settings can be set to specific LAN clients ( <font color=blue> No filter , Global filter </font> ) . Does not need to be set by default."))
|
||||
t.template="cbi/tblsection"
|
||||
t.sortable=true
|
||||
t.anonymous=true
|
||||
t.addremove=true
|
||||
|
||||
e=t:option(Value,"ipaddr",translate("IP Address"))
|
||||
e.width="40%"
|
||||
e.datatype="ip4addr"
|
||||
e.placeholder="0.0.0.0/0"
|
||||
luci.ip.neighbors({ family = 4 }, function(entry)
|
||||
if entry.reachable then
|
||||
e:value(entry.dest:string())
|
||||
end
|
||||
end)
|
||||
|
||||
e=t:option(ListValue,"filter_mode",translate("Filter Mode"))
|
||||
e.width="40%"
|
||||
e.default="disable"
|
||||
e.rmempty=false
|
||||
e:value("disable",translate("No filter"))
|
||||
e:value("global",translate("Global filter"))
|
||||
|
||||
return m
|
@ -0,0 +1,24 @@
|
||||
local fs = require "nixio.fs"
|
||||
local conffile = "/usr/share/adbyby/adhost.conf"
|
||||
|
||||
f = SimpleForm("custom")
|
||||
|
||||
t = f:field(TextValue, "conf")
|
||||
t.rmempty = true
|
||||
t.rows = 13
|
||||
function t.cfgvalue()
|
||||
return fs.readfile(conffile) or ""
|
||||
end
|
||||
|
||||
function f.handle(self, state, data)
|
||||
if state == FORM_VALID then
|
||||
if data.conf then
|
||||
fs.writefile(conffile, data.conf:gsub("\r\n", "\n"))
|
||||
luci.sys.call("/etc/init.d/adbyby restart")
|
||||
end
|
||||
end
|
||||
return true
|
||||
end
|
||||
|
||||
return f
|
||||
|
@ -7,7 +7,7 @@ msgstr "<strong><font color=\"green\">广告屏蔽大师 Plus + 正在运行</fo
|
||||
msgid "<strong><font color=\"red\">Adbyby Plus + is Not Running</font></strong>"
|
||||
msgstr "<strong><font color=\"red\">广告屏蔽大师 Plus + 没有运行</font></strong>"
|
||||
|
||||
msgid "Adbyby Plus + can filter all kinds of banners, popups, video ads, and prevent tracking, privacy theft and a variety of malicious websites<br /><font color=\"red\">Plus + version combination mode can operation with Adblock Plus Host,filtering ads without losing bandwidth</font>"
|
||||
msgid "Adbyby Plus + can filter all kinds of banners, popups, video ads, and prevent tracking, privacy theft and a variety of malicious websites<br /><font color=\"red\">Plus + version combination mode can operation with Adblock Plus Host,filtering ads without losing bandwidth</font>"
|
||||
msgstr "广告屏蔽大师 Plus + 可以全面过滤各种横幅、弹窗、视频广告,同时阻止跟踪、隐私窃取及各种恶意网站<br /><font color=\"red\">Plus + 版本可以和 Adblock Plus Host 结合方式运行,过滤广告不损失带宽</font>"
|
||||
|
||||
msgid "Adbyby Plus +"
|
||||
@ -19,10 +19,10 @@ msgstr "基本设置"
|
||||
msgid "Running Mode"
|
||||
msgstr "运行模式"
|
||||
|
||||
msgid "Global Mode(The slowest, the best effects)"
|
||||
msgid "Global Mode (The slowest and the best effects)"
|
||||
msgstr "全局模式(最慢, 效果最好)"
|
||||
|
||||
msgid "Plus + Mode(Filter domain name list and blacklist website.Recommended)"
|
||||
msgid "Plus + Mode (Filter domain name list and blacklist website.Recommended)"
|
||||
msgstr "Plus + 模式(只过滤列表内域名结合ABP名单。推荐!)"
|
||||
|
||||
msgid "No filter Mode (Must set in Client Filter Mode Settings manually)"
|
||||
@ -62,11 +62,14 @@ msgstr "高级设置"
|
||||
msgid "Update the rule at 6 a.m. every morning and restart adbyby"
|
||||
msgstr "每天凌晨6点更新规则并重启"
|
||||
|
||||
msgid "ADP Host List"
|
||||
msgstr "Adblock Plus Hosts 记录数"
|
||||
|
||||
msgid "Manually force update<br />Adblock Plus Host List"
|
||||
msgstr "手动强制更新<br />Adblock Plus Host List"
|
||||
|
||||
msgid "Manually force update"
|
||||
msgstr "手动强制更新"
|
||||
msgid "Update Adbyby Rules Manually"
|
||||
msgstr "手动更新规则"
|
||||
|
||||
msgid "Block Apple iOS OTA update"
|
||||
msgstr "拦截 Apple iOS 的OTA更新"
|
||||
|
@ -134,6 +134,9 @@ add_rule()
|
||||
fi
|
||||
$ipt_n -A ADBYBY -p tcp -j REDIRECT --to-ports 8118
|
||||
$ipt_n -I PREROUTING -p tcp --dport 80 -j ADBYBY
|
||||
|
||||
mkdir -p /var/etc
|
||||
echo -e "/etc/init.d/adbyby reload_rule" > "/var/etc/adbyby.include"
|
||||
}
|
||||
|
||||
del_rule()
|
||||
@ -156,8 +159,8 @@ reload_rule()
|
||||
config_load adbyby
|
||||
config_foreach get_config adbyby
|
||||
del_rule
|
||||
iptables-save | grep ADBYBY >/dev/null || \
|
||||
add_rule
|
||||
[ $enable -eq 0 ] && exit 0
|
||||
iptables-save | grep ADBYBY >/dev/null || add_rule
|
||||
}
|
||||
|
||||
start()
|
||||
@ -167,7 +170,6 @@ start()
|
||||
[ $enable -eq 0 ] && exit 0
|
||||
add_cron
|
||||
[ ! -d "/tmp/adbyby/data" ] && cp -a /usr/share/adbyby /tmp/ && rm -f /tmp/adbyby.updated
|
||||
/usr/share/adbyby/admem.sh &>/dev/null &
|
||||
add_rules
|
||||
/tmp/adbyby/adbyby &>/dev/null &
|
||||
add_dns
|
||||
|
@ -8,7 +8,7 @@ uci -q batch <<-EOF >/dev/null
|
||||
delete firewall.adbyby
|
||||
set firewall.adbyby=include
|
||||
set firewall.adbyby.type=script
|
||||
set firewall.adbyby.path=/usr/share/adbyby/firewall.include
|
||||
set firewall.adbyby.path=/var/etc/adbyby.include
|
||||
set firewall.adbyby.reload=1
|
||||
delete firewall.adblock
|
||||
add firewall rule
|
||||
|
4
package/lean/luci-app-adbyby-plus/root/usr/share/adbyby/adbybyfirst.sh
Executable file
4
package/lean/luci-app-adbyby-plus/root/usr/share/adbyby/adbybyfirst.sh
Executable file
@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
PROG_PATH=$(pwd)
|
||||
$PROG_PATH/adbybyupdate.sh
|
48
package/lean/luci-app-adbyby-plus/root/usr/share/adbyby/adbybyupdate.sh
Executable file
48
package/lean/luci-app-adbyby-plus/root/usr/share/adbyby/adbybyupdate.sh
Executable file
@ -0,0 +1,48 @@
|
||||
#!/bin/sh
|
||||
|
||||
if [ ! -f "/tmp/adbyby.updated" ];then
|
||||
wget_ok="0"
|
||||
while [ "$wget_ok" = "0" ]
|
||||
do
|
||||
wget-ssl --spider --quiet --tries=1 --timeout=3 www.baidu.com
|
||||
if [ "$?" == "0" ]; then
|
||||
wget_ok="1"
|
||||
|
||||
touch /tmp/md5.json && wget-ssl --no-check-certificate -t 1 -T 10 -O /tmp/md5.json https://adbyby.coding.net/p/xwhyc-rules/d/xwhyc-rules/git/raw/master/md5.json
|
||||
adm5=$(md5sum /tmp/md5.json | awk -F' ' '{print $1}')
|
||||
touch /tmp/adbyby/admd5.json && bmd5=$(md5sum /tmp/adbyby/admd5.json | awk -F' ' '{print $1}')
|
||||
if [ "$adm5" == "$bmd5" ];then
|
||||
echo "Rules MD5 are the same!"
|
||||
echo $(date "+%Y-%m-%d %H:%M:%S") > /tmp/adbyby.updated
|
||||
exit 0
|
||||
else
|
||||
|
||||
touch /tmp/lazy.txt && wget-ssl --no-check-certificate -t 1 -T 10 -O /tmp/lazy.txt https://adbyby.coding.net/p/xwhyc-rules/d/xwhyc-rules/git/raw/master/lazy.txt
|
||||
touch /tmp/video.txt && wget-ssl --no-check-certificate -t 1 -T 10 -O /tmp/video.txt https://adbyby.coding.net/p/xwhyc-rules/d/xwhyc-rules/git/raw/master/video.txt
|
||||
|
||||
touch /tmp/local-md5.json && md5sum /tmp/lazy.txt /tmp/video.txt > /tmp/local-md5.json
|
||||
|
||||
|
||||
lazy_local=$(grep 'lazy' /tmp/local-md5.json | awk -F' ' '{print $1}')
|
||||
video_local=$(grep 'video' /tmp/local-md5.json | awk -F' ' '{print $1}')
|
||||
lazy_online=$(sed 's/":"/\n/g' /tmp/md5.json | sed 's/","/\n/g' | sed -n '2p')
|
||||
video_online=$(sed 's/":"/\n/g' /tmp/md5.json | sed 's/","/\n/g' | sed -n '4p')
|
||||
|
||||
if [ "$lazy_online"x == "$lazy_local"x -a "$video_online"x == "$video_local"x ]; then
|
||||
echo "adbyby rules MD5 OK!"
|
||||
mv /tmp/lazy.txt /tmp/adbyby/data/lazy.txt
|
||||
mv /tmp/video.txt /tmp/adbyby/data/video.txt
|
||||
mv /tmp/md5.json /tmp/adbyby/admd5.json
|
||||
echo $(date "+%Y-%m-%d %H:%M:%S") > /tmp/adbyby.updated
|
||||
fi
|
||||
fi
|
||||
else
|
||||
sleep 10
|
||||
fi
|
||||
done
|
||||
|
||||
rm -f /tmp/adbyby/data/*.bak
|
||||
|
||||
/etc/init.d/adbyby restart
|
||||
fi
|
||||
|
Loading…
Reference in New Issue
Block a user