slabOS/base_apps/Updater.lua
2025-06-02 10:42:08 +03:00

37 lines
885 B
Lua

local CURRENT_CLIENT_VERSION = "1.0.0.2"
local INSTALL_PATH = "/"
function http_get(url)
local req = http.get(url)
if not req then
print("FAIL " .. url)
end
local resp = req.readAll()
req.close()
return resp
end
print("Device Version: " .. CURRENT_CLIENT_VERSION)
print("Fetching latest version...")
local manifest = http_get("https://git.mcorangehq.xyz/xomf/slabOS/raw/branch/main/version.json")
local manifest_json = textutils.unserialiseJSON(manifest)
print("Latest: " .. manifest_json.version)
if manifest_json.version ~= CURRENT_CLIENT_VERSION then
print("Installing update...")
for path, url in pairs(manifest_json.sys_files) do
print("W " .. path)
local file = fs.open(INSTALL_PATH .. path, "w")
file.write(http_get(url))
file.close()
-- print("Written.")
end
print("Please reboot your device.")
os.reboot()
else
print("No update availiable.")
end