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,7 +1,13 @@
local URL_MACHINE = "https://gitea.fse-media.group/Henry_Du/FSE-Ticket.sys/raw/branch/main/ticketmachine.lua"
local URL_MACHINE = "http://gitea.fse-media.group/Henry_Du/FSE-Ticket.sys/raw/branch/main/ticketmachine.lua"
local URL_UPDATE_MACHINE = "http://gitea.fse-media.group/Henry_Du/FSE-Ticket.sys/raw/branch/main/update_machine.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)
@@ -69,7 +75,7 @@ if not silent then
end
log("Downloading ticket machine program...")
local ok, code = httpGet(URL_MACHINE)
local ok, code = httpGet(getCacheBustedUrl(URL_MACHINE))
if not ok or type(code) ~= "string" or #code == 0 then
error("Download failed: " .. tostring(code or ""))
end
@@ -80,6 +86,12 @@ end
atomicWrite("startup", code, false)
if fs.exists("ticketmachine.lua") then atomicWrite("ticketmachine.lua", code, false) end
log("Downloading updater program...")
local okUp, codeUp = httpGet(getCacheBustedUrl(URL_UPDATE_MACHINE))
if okUp and type(codeUp) == "string" and #codeUp > 0 then
atomicWrite("update_machine.lua", codeUp, false)
end
if not silent then
log("")
log("Done.")