* print success or failed
This commit is contained in:
parent
801eb6a368
commit
594980b6c9
@ -1,7 +1,7 @@
|
|||||||
include $(TOPDIR)/rules.mk
|
include $(TOPDIR)/rules.mk
|
||||||
|
|
||||||
PKG_NAME:=luci-app-mosdns
|
PKG_NAME:=luci-app-mosdns
|
||||||
PKG_VERSION:=1.4.1
|
PKG_VERSION:=1.4.2
|
||||||
PKG_RELEASE:=1
|
PKG_RELEASE:=1
|
||||||
|
|
||||||
LUCI_TITLE:=LuCI Support for mosdns
|
LUCI_TITLE:=LuCI Support for mosdns
|
||||||
|
@ -16,6 +16,7 @@ function index()
|
|||||||
entry({"admin", "services", "mosdns", "status"}, call("act_status")).leaf = true
|
entry({"admin", "services", "mosdns", "status"}, call("act_status")).leaf = true
|
||||||
entry({"admin", "services", "mosdns", "get_log"}, call("get_log")).leaf = true
|
entry({"admin", "services", "mosdns", "get_log"}, call("get_log")).leaf = true
|
||||||
entry({"admin", "services", "mosdns", "clear_log"}, call("clear_log")).leaf = true
|
entry({"admin", "services", "mosdns", "clear_log"}, call("clear_log")).leaf = true
|
||||||
|
entry({"admin", "services", "mosdns", "geo_update"}, call("geo_update"))
|
||||||
end
|
end
|
||||||
|
|
||||||
function act_status()
|
function act_status()
|
||||||
@ -32,3 +33,10 @@ end
|
|||||||
function clear_log()
|
function clear_log()
|
||||||
luci.sys.call("cat /dev/null > $(/usr/share/mosdns/mosdns.sh logfile)")
|
luci.sys.call("cat /dev/null > $(/usr/share/mosdns/mosdns.sh logfile)")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function geo_update()
|
||||||
|
local e = {}
|
||||||
|
e.updating = luci.sys.call("/usr/share/mosdns/mosdns.sh geodata") == 0
|
||||||
|
luci.http.prepare_content("application/json")
|
||||||
|
luci.http.write_json(e)
|
||||||
|
end
|
||||||
|
@ -24,11 +24,8 @@ for t = 0, 23 do
|
|||||||
end
|
end
|
||||||
update_time.default = 0
|
update_time.default = 0
|
||||||
|
|
||||||
data_update = s:option(Button, "geo_update_database", translate("Database Update"))
|
data_update = s:option(Button, "geo_update_database", translate("Check And Update"))
|
||||||
data_update.inputtitle = translate("Check And Update")
|
data_update.rawhtml = true
|
||||||
data_update.inputstyle = "reload"
|
data_update.template = "mosdns/geo_update"
|
||||||
data_update.write = function()
|
|
||||||
luci.sys.exec("/usr/share/mosdns/mosdns.sh geodata &> /dev/null &")
|
|
||||||
end
|
|
||||||
|
|
||||||
return m
|
return m
|
||||||
|
34
luci-app-mosdns/luasrc/view/mosdns/geo_update.htm
Normal file
34
luci-app-mosdns/luasrc/view/mosdns/geo_update.htm
Normal file
@ -0,0 +1,34 @@
|
|||||||
|
<%+cbi/valueheader%>
|
||||||
|
<script type="text/javascript">//<![CDATA[
|
||||||
|
function update_data(btn, dataname)
|
||||||
|
{
|
||||||
|
btn.disabled = true;
|
||||||
|
btn.value = '<%:Updating...%> ';
|
||||||
|
st=dataname;
|
||||||
|
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "mosdns", "geo_update")%>',
|
||||||
|
{ set:st },
|
||||||
|
function(x,data)
|
||||||
|
{
|
||||||
|
var tb = document.getElementById(dataname+'-status');
|
||||||
|
if (tb)
|
||||||
|
{
|
||||||
|
switch (data.updating)
|
||||||
|
{
|
||||||
|
case true:
|
||||||
|
tb.innerHTML = "<font color='green'>" + "<%:Update success%>" + "</font>";
|
||||||
|
break;
|
||||||
|
case false:
|
||||||
|
tb.innerHTML = "<font color='red'>" + "<%:Update failed, Please check the network status%>" + "</font>";
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
btn.disabled = false;
|
||||||
|
btn.value = '<%:Check And Update%>';
|
||||||
|
}
|
||||||
|
);
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
//]]></script>
|
||||||
|
<input type="button" class="btn cbi-button cbi-button-reload" value="<%:Check And Update%>" onclick="return update_data(this,'<%=self.option%>')" />
|
||||||
|
<span id="<%=self.option%>-status"><em><%=self.value%></em></span>
|
||||||
|
<%+cbi/valuefooter%>
|
@ -85,6 +85,15 @@ msgstr "检查并更新"
|
|||||||
msgid "Enable Auto Database Update"
|
msgid "Enable Auto Database Update"
|
||||||
msgstr "启用自动更新"
|
msgstr "启用自动更新"
|
||||||
|
|
||||||
|
msgid "Updating..."
|
||||||
|
msgstr "正在更新..."
|
||||||
|
|
||||||
|
msgid "Update success"
|
||||||
|
msgstr "更新成功"
|
||||||
|
|
||||||
|
msgid "Update failed, Please check the network status"
|
||||||
|
msgstr "更新失败,请检查网络状态"
|
||||||
|
|
||||||
msgid "Config File"
|
msgid "Config File"
|
||||||
msgstr "配置文件"
|
msgstr "配置文件"
|
||||||
|
|
||||||
|
@ -36,16 +36,18 @@ geodat_update() (
|
|||||||
geodat_download() (
|
geodat_download() (
|
||||||
google_status=$(curl -I -4 -m 3 -o /dev/null -s -w %{http_code} http://www.google.com/generate_204)
|
google_status=$(curl -I -4 -m 3 -o /dev/null -s -w %{http_code} http://www.google.com/generate_204)
|
||||||
[ $google_status -ne "204" ] && mirror="https://github.cooluc.com/"
|
[ $google_status -ne "204" ] && mirror="https://github.cooluc.com/"
|
||||||
echo -e "\e[1;32m"$mirror"https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/$1\e[0m"
|
echo -e "\e[1;32mDownloading "$mirror"https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/$1\e[0m"
|
||||||
curl --connect-timeout 60 -m 900 -fSLo "$TMPDIR/$1" ""$mirror"https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/$1"
|
curl --connect-timeout 60 -m 900 --ipv4 -fSLo "$TMPDIR/$1" ""$mirror"https://github.com/Loyalsoldier/v2ray-rules-dat/releases/latest/download/$1"
|
||||||
)
|
)
|
||||||
TMPDIR=$(mktemp -d) || exit 1
|
TMPDIR=$(mktemp -d) || exit 1
|
||||||
geodat_download geoip.dat
|
geodat_download geoip.dat
|
||||||
geodat_download geosite.dat
|
geodat_download geosite.dat
|
||||||
if [ "$(grep -o CN "$TMPDIR"/geoip.dat | wc -l)" -eq "0" ]; then
|
if [ "$(grep -o CN "$TMPDIR"/geoip.dat | wc -l)" -eq "0" ]; then
|
||||||
rm -rf "$TMPDIR"/geoip.dat
|
rm -rf "$TMPDIR"/geoip.dat
|
||||||
|
exit 1
|
||||||
elif [ "$(grep -o .com "$TMPDIR"/geosite.dat | wc -l)" -lt "1000" ]; then
|
elif [ "$(grep -o .com "$TMPDIR"/geosite.dat | wc -l)" -lt "1000" ]; then
|
||||||
rm -rf "$TMPDIR"/geosite.dat
|
rm -rf "$TMPDIR"/geosite.dat
|
||||||
|
exit 1
|
||||||
fi
|
fi
|
||||||
cp -f "$TMPDIR"/* /usr/share/v2ray
|
cp -f "$TMPDIR"/* /usr/share/v2ray
|
||||||
rm -rf "$TMPDIR"
|
rm -rf "$TMPDIR"
|
||||||
|
Loading…
Reference in New Issue
Block a user