luci-app-unblockneteasemusic: update to latest git HEAD
This commit is contained in:
parent
9a7589571e
commit
5794c23bf4
@ -12,7 +12,7 @@ LUCI_DEPENDS:=+bash +busybox +coreutils-nohup +curl +dnsmasq-full +ipset +libope
|
||||
LUCI_PKGARCH:=all
|
||||
PKG_NAME:=luci-app-unblockneteasemusic
|
||||
PKG_VERSION:=2.1
|
||||
PKG_RELEASE:=2
|
||||
PKG_RELEASE:=3
|
||||
|
||||
PKG_MAINTAINER:=[CTCGFW]Project-OpenWrt
|
||||
|
||||
|
||||
@ -10,16 +10,47 @@ function index()
|
||||
end
|
||||
|
||||
entry({"admin", "services", "unblockneteasemusic"},firstchild(), _("解除网易云音乐播放限制"), 50).dependent = false
|
||||
|
||||
entry({"admin", "services", "unblockneteasemusic", "general"},cbi("unblockneteasemusic"), _("Base Setting"), 1)
|
||||
entry({"admin", "services", "unblockneteasemusic", "log"},form("unblockneteasemusiclog"), _("Log"), 2)
|
||||
|
||||
|
||||
entry({"admin", "services", "unblockneteasemusic", "general"},cbi("unblockneteasemusic"), _("基本设定"), 1)
|
||||
entry({"admin", "services", "unblockneteasemusic", "updt_core"},form("unblockneteasemusic_upcore"), _("更新核心"), 2).leaf = true
|
||||
entry({"admin", "services", "unblockneteasemusic", "log"},form("unblockneteasemusiclog"), _("日志"), 3)
|
||||
|
||||
entry({"admin", "services", "unblockneteasemusic", "status"},call("act_status")).leaf=true
|
||||
entry({"admin", "services", "unblockneteasemusic", "update_core"},call("act_update_core"))
|
||||
end
|
||||
|
||||
function act_status()
|
||||
local e={}
|
||||
e.running=luci.sys.call("ps |grep unblockneteasemusic |grep app.js |grep -v grep >/dev/null")==0
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
local e={}
|
||||
e.running=luci.sys.call("ps |grep unblockneteasemusic |grep app.js |grep -v grep >/dev/null")==0
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json(e)
|
||||
end
|
||||
|
||||
function update_core()
|
||||
cloud_ver=luci.sys.exec("curl -s 'https://github.com/nondanee/UnblockNeteaseMusic/commits/master' |tr -d '\n' |grep -Eo 'commit\/[0-9a-z]+' |sed -n 1p |sed 's#commit/##g'")
|
||||
cloud_ver_mini=luci.sys.exec("curl -s 'https://github.com/nondanee/UnblockNeteaseMusic/commits/master' |tr -d '\n' |grep -Eo 'BtnGroup-item.> [0-9a-z]+' |sed -n 1p |sed 's#BtnGroup-item.> ##g'")
|
||||
if not cloud_ver or not cloud_ver_mini then
|
||||
return "1"
|
||||
else
|
||||
local_ver=luci.sys.exec("cat '/usr/share/unblockneteasemusic/local_ver'")
|
||||
if not local_ver or (local_ver ~= cloud_ver) then
|
||||
luci.sys.call("rm -f /usr/share/unblockneteasemusic/update_successfully")
|
||||
luci.sys.call("/bin/bash /usr/share/unblockneteasemusic/update_core.sh luci_update")
|
||||
if not nixio.fs.access("/usr/share/unblockneteasemusic/update_successfully") then
|
||||
return "2"
|
||||
else
|
||||
luci.sys.call("rm -f /usr/share/unblockneteasemusic/update_successfully")
|
||||
return cloud_ver_mini
|
||||
end
|
||||
else
|
||||
return "0"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function act_update_core()
|
||||
luci.http.prepare_content("application/json")
|
||||
luci.http.write_json({
|
||||
ret = update_core();
|
||||
})
|
||||
end
|
||||
@ -1,7 +1,7 @@
|
||||
mp = Map("unblockneteasemusic", translate("解除网易云音乐播放限制"))
|
||||
mp.description = translate("原理:采用 [QQ/虾米/百度/酷狗/酷我/咕咪/JOOX] 等音源,替换网易云音乐 无版权/收费 歌曲链接<br/>具体使用方法参见:https://github.com/project-openwrt/luci-app-unblockneteasemusic")
|
||||
|
||||
mp:section(SimpleSection).template = "unblockneteasemusic/unblockneteasemusic_status"
|
||||
mp:section(SimpleSection).template = "unblockneteasemusic/unblockneteasemusic_status"
|
||||
|
||||
s = mp:section(TypedSection, "unblockneteasemusic")
|
||||
s.anonymous=true
|
||||
@ -12,15 +12,6 @@ enabled.description = translate("启用本插件以解除网易云音乐播放
|
||||
enabled.default = 0
|
||||
enabled.rmempty = false
|
||||
|
||||
button_update_core = s:option (Button, "_button_update_core", translate("更新主程序"))
|
||||
button_update_core.description = translate("更新完毕后会自动重启插件;更新主程序需要一点时间,请不要反复点击按钮")
|
||||
local latest_ver = luci.sys.exec("/bin/bash /usr/share/unblockneteasemusic/check_update.sh")
|
||||
button_update_core.inputtitle = translate (latest_ver)
|
||||
button_update_core.inputstyle = "apply"
|
||||
function button_update_core.write (self, section, value)
|
||||
luci.sys.call ("/bin/bash /usr/share/unblockneteasemusic/update_core.sh &")
|
||||
end
|
||||
|
||||
account = s:option(Value, "http_port", translate("[HTTP] 监听端口"))
|
||||
account.description = translate("本插件监听的HTTP端口,不可与其他程序/HTTPS共用一个端口")
|
||||
account.placeholder = "5200"
|
||||
|
||||
@ -0,0 +1,13 @@
|
||||
local m, up_core
|
||||
|
||||
m = SimpleForm("Version")
|
||||
m.reset = false
|
||||
m.submit = false
|
||||
|
||||
up_core=m:field(DummyValue,"update_core",translate("更新主程序"))
|
||||
up_core.rawhtml = true
|
||||
up_core.template = "unblockneteasemusic/update_core"
|
||||
up_core.value = translate("未检查")
|
||||
up_core.description = "更新完毕后会自动在后台重启插件,无需手动重启"
|
||||
|
||||
return m
|
||||
@ -0,0 +1,36 @@
|
||||
<%+cbi/valueheader%>
|
||||
|
||||
<script type="text/javascript">//<![CDATA[
|
||||
function act_update_core(btn,dataname)
|
||||
{
|
||||
btn.disabled = true;
|
||||
btn.value = '<%:正在更新主程序...%> ';
|
||||
XHR.get('<%=luci.dispatcher.build_url("admin", "services", "unblockneteasemusic","update_core")%>',
|
||||
status.ret,
|
||||
function(x,status)
|
||||
{
|
||||
var s = document.getElementById(dataname+'-status');
|
||||
if (s)
|
||||
{
|
||||
if(status.ret=="0")
|
||||
s.innerHTML ="<font color='green'>"+"<%:当前已是最新版本%>"+"</font>";
|
||||
else if (status.ret=="1")
|
||||
s.innerHTML ="<font color='red'>"+"<%:无法检测最新版本%>"+"</font>";
|
||||
else if(status.ret=="2")
|
||||
s.innerHTML ="<font color='red'>"+"<%:更新失败,请稍后重试%>"+"</font>";
|
||||
else
|
||||
s.innerHTML ="<font color='green'>"+"<%:更新成功,当前版本号:%>"+status.ret+"</font>";
|
||||
}
|
||||
btn.disabled = false;
|
||||
btn.value = '<%:点此更新主程序%>';
|
||||
}
|
||||
);
|
||||
return false;
|
||||
}
|
||||
//]]></script>
|
||||
|
||||
|
||||
<input type="button" class="cbi-button cbi-input-reload" value="<%:点此更新主程序%> " onclick="return act_update_core(this,'<%=self.option%>')" />
|
||||
<span id="<%=self.option%>-status"><em><%=self.value%></em></span>
|
||||
|
||||
<%+cbi/valuefooter%>
|
||||
@ -1,21 +0,0 @@
|
||||
#!/bin/bash
|
||||
# Created By [CTCGFW]Project OpenWRT
|
||||
# https://github.com/project-openwrt
|
||||
|
||||
commit_info="$(curl -s https://github.com/nondanee/UnblockNeteaseMusic/commits/master)"
|
||||
latest_ver="$(echo -e "${commit_info}" |tr -d '\n' | grep -Eo 'commit\/[0-9a-z]+' |sed -n 1p |sed 's#commit/##g')"
|
||||
latest_ver_mini="$(echo -e "${commit_info}" |tr -d '\n' | grep -Eo 'BtnGroup-item"> [0-9a-z]+' |sed -n 1p |sed 's#BtnGroup-item"> ##g')"
|
||||
|
||||
[ -z "${commit_info}" ] && echo "无法检测最新版本,请稍后重试" && exit 1
|
||||
[ -z "${latest_ver}" ] && echo "无法检测最新版本,请稍后重试" && exit 1
|
||||
[ -z "${latest_ver_mini}" ] && echo "无法检测最新版本,请稍后重试" && exit 1
|
||||
|
||||
if [ ! -e "/usr/share/unblockneteasemusic/local_ver" ]; then
|
||||
echo "最新版本:${latest_ver_mini},点此更新"
|
||||
else
|
||||
if [ "$(cat /usr/share/unblockneteasemusic/local_ver)" != "${latest_ver}" ]; then
|
||||
echo "最新版本:${latest_ver_mini},点此更新"
|
||||
else
|
||||
echo "目前已是最新版本,无需更新"
|
||||
fi
|
||||
fi
|
||||
@ -50,6 +50,7 @@ function update_core(){
|
||||
echo -e "Failed to download core." >>/tmp/unblockneteasemusic.log
|
||||
exit 1
|
||||
else
|
||||
[ "${luci_update}" == "y" ] && touch "/usr/share/unblockneteasemusic/update_successfully"
|
||||
echo -e "${latest_ver}" > /usr/share/unblockneteasemusic/local_ver
|
||||
/etc/init.d/unblockneteasemusic restart
|
||||
fi
|
||||
@ -64,4 +65,5 @@ function main(){
|
||||
check_latest_version
|
||||
}
|
||||
|
||||
main
|
||||
[ "$1" == "luci_update" ] && luci_update="y"
|
||||
main
|
||||
Loading…
Reference in New Issue
Block a user