luci: fix sing-box app update
This commit is contained in:
parent
0fbcb7de2e
commit
3cbdd15b50
@ -814,12 +814,23 @@ function to_extract(app_name, file, subfix)
|
||||
return {code = 1, error = i18n.translate("File path required.")}
|
||||
end
|
||||
|
||||
if sys.exec("echo -n $(opkg list-installed | grep -c unzip)") ~= "1" then
|
||||
exec("/bin/rm", {"-f", file})
|
||||
return {
|
||||
code = 1,
|
||||
error = i18n.translate("Not installed unzip, Can't unzip!")
|
||||
}
|
||||
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})
|
||||
return {
|
||||
code = 1,
|
||||
error = i18n.translate("Not installed %s, Can't unzip!" % { tools_name })
|
||||
}
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
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 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))
|
||||
|
||||
@ -853,7 +875,7 @@ function to_move(app_name,file)
|
||||
local bin_path = file
|
||||
local cmd_rm_tmp = "/bin/rm -rf /tmp/" .. app_name .. "_download.*"
|
||||
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.*"
|
||||
end
|
||||
|
||||
|
@ -55,6 +55,7 @@ _M.singbox = {
|
||||
get_url = gh_pre_release_url,
|
||||
cmd_version = "version | awk '{print $3}' | sed -n 1P",
|
||||
zipped = true,
|
||||
zipped_suffix = "tar.gz",
|
||||
default_path = "/usr/bin/sing-box",
|
||||
match_fmt_str = "linux%%-%s",
|
||||
file_tree = {
|
||||
|
@ -1372,8 +1372,8 @@ msgstr "无"
|
||||
msgid "You did not fill in the %s path. Please save and apply then update manually."
|
||||
msgstr "您没有填写 %s 路径。请保存应用后再手动更新。"
|
||||
|
||||
msgid "Not installed unzip, Can't unzip!"
|
||||
msgstr "未安装unzip,无法解压。"
|
||||
msgid "Not installed %s, Can't unzip!"
|
||||
msgstr "未安装 %s,无法解压!"
|
||||
|
||||
msgid "Can't determine ARCH, or ARCH not supported."
|
||||
msgstr "无法确认ARCH架构,或是不支持。"
|
||||
|
Loading…
Reference in New Issue
Block a user