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,6 +1,12 @@
local URL_REFILL_MACHINE = "https://gitea.fse-media.group/Henry_Du/FSE-Ticket.sys/raw/branch/main/refillmachine.lua"
local URL_REFILL_MACHINE = "http://gitea.fse-media.group/Henry_Du/FSE-Ticket.sys/raw/branch/main/refillmachine.lua"
local URL_UPDATE_REFILL = "http://gitea.fse-media.group/Henry_Du/FSE-Ticket.sys/raw/branch/main/update_refill.lua"
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 writeFile(path, content, binary)
local mode = binary and "wb" or "w"
@@ -61,12 +67,18 @@ print("Refill Machine Updater")
print("")
print("Downloading refill machine program...")
local ok, code = httpGet(URL_REFILL_MACHINE)
local ok, code = httpGet(getCacheBustedUrl(URL_REFILL_MACHINE))
if not ok or type(code) ~= "string" or #code == 0 then
print("Download failed: " .. tostring(code or ""))
return
end
print("Downloading updater program...")
local okUp, codeUp = httpGet(getCacheBustedUrl(URL_UPDATE_REFILL))
if okUp and type(codeUp) == "string" and #codeUp > 0 then
atomicWrite("update_refill.lua", codeUp, false)
end
if not atomicWrite("startup.lua", code, false) then
print("Write failed: startup.lua")
return