fix(ota): make update scripts self-updating and add cache-busting to installers

This commit is contained in:
2026-07-11 16:00:37 +08:00
parent de187db646
commit 4fe3a24eaf
7 changed files with 70 additions and 14 deletions
+14 -2
View File
@@ -1,8 +1,14 @@
local URL_GATE = "https://gitea.fse-media.group/Henry_Du/FSE-Ticket.sys/raw/branch/main/gate.lua"
local URL_GATE = "http://gitea.fse-media.group/Henry_Du/FSE-Ticket.sys/raw/branch/main/gate.lua"
local URL_UPDATE_GATE = "http://gitea.fse-media.group/Henry_Du/FSE-Ticket.sys/raw/branch/main/update_gate.lua"
local args = { ... }
local silent = AUTO_UPDATE_SILENT == true or args[1] == "--silent"
local function getCacheBustedUrl(url)
local sep = url:find("?") and "&" or "?"
return url .. sep .. "_t=" .. tostring(os.epoch and os.epoch("utc") or math.random(1, 999999))
end
local function log(msg)
if not silent then
print(msg)
@@ -70,7 +76,7 @@ if not silent then
end
log("Downloading gate program...")
local ok, code = httpGet(URL_GATE)
local ok, code = httpGet(getCacheBustedUrl(URL_GATE))
if not ok or type(code) ~= "string" or #code == 0 then
error("Download failed: " .. tostring(code or ""))
end
@@ -81,6 +87,12 @@ end
atomicWrite("startup", code, false)
if fs.exists("gate.lua") then atomicWrite("gate.lua", code, false) end
log("Downloading updater program...")
local okUp, codeUp = httpGet(getCacheBustedUrl(URL_UPDATE_GATE))
if okUp and type(codeUp) == "string" and #codeUp > 0 then
atomicWrite("update_gate.lua", codeUp, false)
end
if not silent then
log("")
log("Done.")