local utils = require("utils.lua") local LAST_USED = os.time() 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 end end end end function UpdateChecker() while true do checkForUpdate() sleep(1) end end function GetBasalt() 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 file.write(Cast(basalt_code)) file.close() utils.MonPrint("Rebooting...") os.reboot() end end return { UpdateChecker, GetBasalt }