51 lines
1.3 KiB
Lua
51 lines
1.3 KiB
Lua
-- keycardOS "bootloader", has no access to basalt
|
|
-- intended for checking for updates, and automatically updating basalt if it is missing
|
|
|
|
LAST_USED = os.time()
|
|
|
|
local function checkForUpdate()
|
|
current_time = os.time()
|
|
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 > 4 then
|
|
if difference > .5 then
|
|
--logic for updating
|
|
end
|
|
|
|
end
|
|
|
|
function updateChecker()
|
|
while true do
|
|
checkForUpdate()
|
|
sleep(1)
|
|
end
|
|
end
|
|
|
|
local function getBasalt()
|
|
if fs.exists("basalt.lua") then
|
|
mPrint("Basalt found!")
|
|
else
|
|
mPrint("Download basalt...")
|
|
basalt_code = http.get("https://raw.githubusercontent.com/Pyroxenium/Basalt/master/docs/versions/latest.lua").readAll()
|
|
mPrint("Install basalt...")
|
|
local file = fs.open("basalt.lua", "w")
|
|
file.write(basalt_code)
|
|
file.close()
|
|
mPrint("Rebooting...")
|
|
os.reboot()
|
|
end
|
|
end
|
|
|
|
KEYPADOS_VERSION = "3.0"
|
|
MONITOR = peripheral.find("monitor")
|
|
|
|
local function boot()
|
|
mon_reset(0.5);
|
|
mPrint("keypadOS v" .. KEYPADOS_VERSION)
|
|
mon_reset(1);
|
|
end
|
|
|
|
boot()
|