Add updater.lua
This commit is contained in:
parent
866d8ef135
commit
a0fce31840
36
updater.lua
Normal file
36
updater.lua
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
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()
|
||||||
|
|
||||||
|
end
|
Loading…
Reference in New Issue
Block a user