Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local oldPull = os.pullEvent
- os.pullEvent = os.pullEventRaw
- --Heimbriech OS Update Handler, used to gather Update Details, delete old files, download new Files, and check security.
- local Stage = 0
- local UpdateCode = nil
- local UpdateVersion = settings.get("OS_Version")
- start()
- function start()
- if Temp_UpdateID == nil then
- shell.run("ErrorHandler","Update ID not Found")
- else
- ReceiveInfo()
- end
- end
- function ReceiveInfo()
- resp = http.get("pastebin","get","hxRHKpz0","Temp_Updates.txt") --Updates File
- local file = fs.open("Temp_Updates.txt","r")
- local i = 1
- for i = 1, #file.list() do
- if file.readLine((i*3)+1) > UpdateVersion then
- UpdateVersion = file.readLine((i*3)+1)
- UpdateCode = file.readLine((i*3)+3)
- end
- end
- file.close()
- term.clear()
- if UpdateVersion == settings.get("OS_Version") then
- print("Was trying to find new update, but failed to find any new ones")
- print("sending User to Menu")
- CloseHandler("Menu")
- else
- UpdateAlert()
- end
- end
- function UpdateAlert()
- term.setCursorPos(1,1)
- print("New Update Avaliable!"
- print("Press e to download, otherwise press b to cancel")
- until Stage == 1 or Stage == -1 do
- local input = read()
- if input == "e" then
- Stage = 1
- else if input == "b" then"
- Stage = -1
- end
- input = nil
- end
- if Stage == -1 then
- textutils.slowWrite("Closing Update Handler",7)
- textutils.slowWrite("Starting Login",9)
- sleep(5)
- CloseHandler("Menu")
- else if Stage == 1 then
- print("Starting Update, User Interaction Disabled for time being")
- UpdateSetup()
- end
- end
- function UpdateSetup()
- print("Setting up update tools")
- resp = http.get("pastebin","get",UpdateCode,"Temp_Update.PRG) --Target Update File
- end
- function CloseHandler(Resolve)
- if Resolve == "Menu" then
- if settings.get("Security_Login") == "n" then
- shell.run(".Menu_1")
- else
- shell.run(".Login_1")
- end
- else if Resolve == "Restart" then
- shell.run(".ShutdownHandler","Restart","false")
- end
- end
- os.pullEvent = oldPull
Add Comment
Please, Sign In to add comment