luci: fix sing-box app update
This commit is contained in:
parent
0fbcb7de2e
commit
3cbdd15b50
@ -814,13 +814,24 @@ function to_extract(app_name, file, subfix)
|
|||||||
return {code = 1, error = i18n.translate("File path required.")}
|
return {code = 1, error = i18n.translate("File path required.")}
|
||||||
end
|
end
|
||||||
|
|
||||||
if sys.exec("echo -n $(opkg list-installed | grep -c unzip)") ~= "1" then
|
local tools_name
|
||||||
|
if com[app_name].zipped then
|
||||||
|
if not com[app_name].zipped_suffix or com[app_name].zipped_suffix == "zip" then
|
||||||
|
tools_name = "unzip"
|
||||||
|
end
|
||||||
|
if com[app_name].zipped_suffix and com[app_name].zipped_suffix == "tar.gz" then
|
||||||
|
tools_name = "tar"
|
||||||
|
end
|
||||||
|
if tools_name then
|
||||||
|
if sys.exec("echo -n $(command -v %s)" % { tools_name }) == "" then
|
||||||
exec("/bin/rm", {"-f", file})
|
exec("/bin/rm", {"-f", file})
|
||||||
return {
|
return {
|
||||||
code = 1,
|
code = 1,
|
||||||
error = i18n.translate("Not installed unzip, Can't unzip!")
|
error = i18n.translate("Not installed %s, Can't unzip!" % { tools_name })
|
||||||
}
|
}
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
sys.call("/bin/rm -rf /tmp/".. app_name .."_extract.*")
|
sys.call("/bin/rm -rf /tmp/".. app_name .."_extract.*")
|
||||||
|
|
||||||
@ -833,8 +844,19 @@ function to_extract(app_name, file, subfix)
|
|||||||
local tmp_dir = util.trim(util.exec("mktemp -d -t ".. app_name .."_extract.XXXXXX"))
|
local tmp_dir = util.trim(util.exec("mktemp -d -t ".. app_name .."_extract.XXXXXX"))
|
||||||
|
|
||||||
local output = {}
|
local output = {}
|
||||||
exec("/usr/bin/unzip", {"-o", file, app_name, "-d", tmp_dir},
|
|
||||||
function(chunk) output[#output + 1] = chunk end)
|
if tools_name then
|
||||||
|
if tools_name == "unzip" then
|
||||||
|
local bin = sys.exec("echo -n $(command -v unzip)")
|
||||||
|
exec(bin, {"-o", file, app_name, "-d", tmp_dir}, function(chunk) output[#output + 1] = chunk end)
|
||||||
|
elseif tools_name == "tar" then
|
||||||
|
local bin = sys.exec("echo -n $(command -v tar)")
|
||||||
|
if com[app_name].zipped_suffix == "tar.gz" then
|
||||||
|
exec(bin, {"-zxf", file, "-C", tmp_dir}, function(chunk) output[#output + 1] = chunk end)
|
||||||
|
sys.call("/bin/mv -f " .. tmp_dir .. "/*/" .. com[app_name].name:lower() .. " " .. tmp_dir)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
local files = util.split(table.concat(output))
|
local files = util.split(table.concat(output))
|
||||||
|
|
||||||
@ -853,7 +875,7 @@ function to_move(app_name,file)
|
|||||||
local bin_path = file
|
local bin_path = file
|
||||||
local cmd_rm_tmp = "/bin/rm -rf /tmp/" .. app_name .. "_download.*"
|
local cmd_rm_tmp = "/bin/rm -rf /tmp/" .. app_name .. "_download.*"
|
||||||
if fs.stat(file, "type") == "dir" then
|
if fs.stat(file, "type") == "dir" then
|
||||||
bin_path = file .. "/" .. app_name
|
bin_path = file .. "/" .. com[app_name].name:lower()
|
||||||
cmd_rm_tmp = "/bin/rm -rf /tmp/" .. app_name .. "_extract.*"
|
cmd_rm_tmp = "/bin/rm -rf /tmp/" .. app_name .. "_extract.*"
|
||||||
end
|
end
|
||||||
|
|
||||||
|
@ -55,6 +55,7 @@ _M.singbox = {
|
|||||||
get_url = gh_pre_release_url,
|
get_url = gh_pre_release_url,
|
||||||
cmd_version = "version | awk '{print $3}' | sed -n 1P",
|
cmd_version = "version | awk '{print $3}' | sed -n 1P",
|
||||||
zipped = true,
|
zipped = true,
|
||||||
|
zipped_suffix = "tar.gz",
|
||||||
default_path = "/usr/bin/sing-box",
|
default_path = "/usr/bin/sing-box",
|
||||||
match_fmt_str = "linux%%-%s",
|
match_fmt_str = "linux%%-%s",
|
||||||
file_tree = {
|
file_tree = {
|
||||||
|
@ -1372,8 +1372,8 @@ msgstr "无"
|
|||||||
msgid "You did not fill in the %s path. Please save and apply then update manually."
|
msgid "You did not fill in the %s path. Please save and apply then update manually."
|
||||||
msgstr "您没有填写 %s 路径。请保存应用后再手动更新。"
|
msgstr "您没有填写 %s 路径。请保存应用后再手动更新。"
|
||||||
|
|
||||||
msgid "Not installed unzip, Can't unzip!"
|
msgid "Not installed %s, Can't unzip!"
|
||||||
msgstr "未安装unzip,无法解压。"
|
msgstr "未安装 %s,无法解压!"
|
||||||
|
|
||||||
msgid "Can't determine ARCH, or ARCH not supported."
|
msgid "Can't determine ARCH, or ARCH not supported."
|
||||||
msgstr "无法确认ARCH架构,或是不支持。"
|
msgstr "无法确认ARCH架构,或是不支持。"
|
||||||
|
Loading…
Reference in New Issue
Block a user