36 lines
869 B
Lua
36 lines
869 B
Lua
local CURRENT_CLIENT_VERSION = "1.0.0.1"
|
|
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("Please reboot your device.")
|
|
os.reboot()
|
|
else
|
|
print("No update availiable.")
|
|
end |