1
0
forked from xomf/slabOS
slabOS/updater.lua
2025-05-31 17:38:35 +00:00

37 lines
883 B
Lua

local CURRENT_CLIENT_VERSION = "0.0.0.3"
local INSTALL_PATH = "/"
function http_get(url)
local req = http.get(url)
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("Writing " .. path)
local file = fs.open(INSTALL_PATH .. path, "w")
file.write( http_get(url) )
file.close()
print("Written.")
end
print("Rebooting device in 5 seconds.")
sleep(5)
os.reboot()
else
print("No update availiable")
end