local utils = require("utils.lua") local LAST_USED = os.time() local mod = {} 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?x=" .. tostring(math.random(11111111, 99999999))) -- I HATE CACHE REEEEEEEEEEEEEEEEE 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") if not string.find(update_code_text, KEYPADOS_UPDATE_HASH) then local file = fs.open("startup.lua", "w") file.write(update_code_text) file.close() os.reboot() else print("Nothing changed, not updating.") LAST_USED = os.time() return end else print("Bad file download (core)") end else print("Bad mem read (core)") end else print("Bad download (core)") end end end function mod.UpdateChecker() while true do checkForUpdate() sleep(1) end end function mod.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(utils.Cast(basalt_code)) file.close() utils.MonPrint("Rebooting...") os.reboot() end end return mod