2024-08-18 00:34:13 +00:00
|
|
|
local utils = require("utils.lua")
|
|
|
|
|
|
|
|
local LAST_USED = os.time()
|
|
|
|
|
2024-08-18 01:34:08 +00:00
|
|
|
local mod = {}
|
|
|
|
|
2024-08-18 00:34:13 +00:00
|
|
|
local function checkForUpdate()
|
|
|
|
local current_time = os.time()
|
|
|
|
local difference = math.abs(current_time - LAST_USED)
|
|
|
|
print("Checking for update... difference: " .. tostring(difference))
|
|
|
|
--its been considerable time since the keypad was interacted with
|
|
|
|
--therefore it's time to force an update down the users throat (microsoft moment)
|
|
|
|
if difference > .5 then
|
|
|
|
local update_code_request = http.get("https://git.mcorangehq.xyz/xomf/keypadOS/raw/branch/main/keypadOS.lua")
|
|
|
|
if update_code_request then
|
|
|
|
local update_code_text = update_code_request.readAll()
|
|
|
|
if update_code_text then
|
|
|
|
if string.find(update_code_text, "^local __BUNDLER_FILES = {}") then
|
|
|
|
--make backup
|
|
|
|
fs.copy("startup.lua","backup.lua")
|
|
|
|
|
|
|
|
--install update
|
|
|
|
local file = fs.open("startup.lua", "w")
|
|
|
|
file.write(update_code_text)
|
|
|
|
file.close()
|
|
|
|
os.reboot()
|
|
|
|
end
|
2024-08-18 01:50:23 +00:00
|
|
|
print("Bad file download (core)")
|
2024-08-18 00:34:13 +00:00
|
|
|
end
|
2024-08-18 01:50:23 +00:00
|
|
|
print("Bad mem read (core)")
|
2024-08-18 00:34:13 +00:00
|
|
|
end
|
2024-08-18 01:50:23 +00:00
|
|
|
print("Bad download (core)")
|
2024-08-18 00:34:13 +00:00
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-08-18 01:34:08 +00:00
|
|
|
function mod.UpdateChecker()
|
2024-08-18 00:34:13 +00:00
|
|
|
while true do
|
|
|
|
checkForUpdate()
|
|
|
|
sleep(1)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-08-18 01:34:08 +00:00
|
|
|
function mod.GetBasalt()
|
2024-08-18 00:34:13 +00:00
|
|
|
if fs.exists("basalt.lua") then
|
|
|
|
utils.MonPrint("Basalt found!")
|
|
|
|
else
|
|
|
|
utils.MonPrint("Downloading basalt...")
|
|
|
|
local basalt_code = http.get("https://raw.githubusercontent.com/Pyroxenium/Basalt/master/docs/versions/latest.lua").readAll()
|
|
|
|
utils.MonPrint("Installing basalt...")
|
|
|
|
|
|
|
|
local file = fs.open("basalt.lua", "w")
|
|
|
|
if not file then
|
|
|
|
utils.MonPrint("failed to get basalt")
|
|
|
|
sleep(60)
|
|
|
|
os.reboot()
|
|
|
|
end
|
|
|
|
|
2024-08-18 00:36:52 +00:00
|
|
|
file.write(utils.Cast(basalt_code))
|
2024-08-18 00:34:13 +00:00
|
|
|
file.close()
|
|
|
|
|
|
|
|
utils.MonPrint("Rebooting...")
|
|
|
|
os.reboot()
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2024-08-18 01:34:08 +00:00
|
|
|
return mod
|