Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --[[
- Lithium OS Launcher by LegoStax
- ]]--
- function download(url, fn)
- -- Download Function --
- -- check for http api
- if not http then
- print("The HTTP API is not enabled.")
- print("Please enable the API in ComputerCraft settings.")
- return
- else
- -- if it's enabled then we download the file into the variable response and then write response to the file specified when the function is called
- local response = http.get(url)
- if response then
- local data = response.readAll()
- response.close()
- local file = fs.open(fn, "w")
- file.write(data)
- file.close()
- else
- -- if there's no response or response is nil
- print("No Response. Are you connected to the internet?")
- print("If you are, then Pastebin is down.")
- return
- end
- end
- end
- -- OS installation. I'm going to replace this with a gui sooner or later
- if not fs.exists(".programs") then
- shell.run("delete", "lithos")
- print("Installing Lithium OS")
- download("http://pastebin.com/raw.php?i=m5vPnePf", "lithos")
- print("Installing Programs")
- shell.run("mkdir", ".programs")
- download("http://pastebin.com/raw.php?i=JSFdbuSJ", ".programs/lith")
- download("http://pastebin.com/raw.php?i=aH3S7VhP", ".programs/login")
- download("http://pastebin.com/raw.php?i=Mipa0pFt", ".programs/settings")
- download("http://pastebin.com/raw.php?i=XcSsVkiN", ".programs/sha")
- download("http://pastebin.com/raw.php?i=pnzdr8FB", ".programs/explorer")
- print("Installing Images")
- download("http://pastebin.com/raw.php?i=VjMZQdCX", ".programs/set-bg")
- download("http://pastebin.com/raw.php?i=Uy34X768", ".programs/login_img")
- download("http://pastebin.com/raw.php?i=WPUztxL0", ".programs/update_img")
- download("http://pastebin.com/raw.php?i=Hdwh8X1C", ".programs/desktop")
- print("Finished.")
- print("NOTE: Anything seen in red is an unfinished feature")
- print("Setup:")
- write "Username: "
- user = read()
- x,y = term.getCursorPos()
- term.setCursorPos(x,y+1)
- write "Password: "
- cpass = read("*")
- os.loadAPI(".programs/sha")
- cpass = sha.sha256(cpass)
- info = {
- user = nil;
- cpass = nil;
- }
- info.user = user
- info.cpass = cpass
- local file = fs.open(".programs/user", "w")
- file.write(info)
- file.close()
- print("Rebooting...")
- sleep(2)
- os.reboot()
- else
- if not fs.exists(".programs/config") then
- config = {
- autoupdate = nil,
- desktop_img = ".programs/desktop",
- bgcolor = colors.white,
- taskside = "top"
- }
- running = true
- while running do
- term.clear()
- term.setCursorPos(1,1)
- term.write("Autoupdate? (y/n)")
- e = {os.pullEvent("key")}
- if e[2] == keys.y then
- config.autoupdate = true
- running = false
- elseif e[2] == keys.n then
- config.autoupdate = false
- running = false
- end
- end
- local file = fs.open(".programs/config", "w")
- file.write(textutils.serialize(config))
- file.close()
- end
- if not fs.exists(".programs/user") then
- write "Username: "
- user = read()
- x,y = term.getCursorPos()
- term.setCursorPos(x,y+1)
- write "Password: "
- cpass = read("*")
- os.loadAPI(".programs/sha")
- cpass = sha.sha256(cpass)
- info = {
- user = nil;
- cpass = nil;
- }
- info.user = user
- info.cpass = cpass
- local file = fs.open(".programs/user", "w")
- file.write(textutils.serialize(info))
- file.close()
- end
- config = {}
- local file = fs.open(".programs/config", "r")
- config = textutils.unserialize(file.readAll())
- file.close()
- if config.autoupdate == true then
- bg = paintutils.loadImage(".programs/update_img")
- paintutils.drawImage(bg, 1, 1)
- term.setBackgroundColor(colors.lightGray)
- term.setCursorPos(3,1)
- term.write("Lithium OS - Update")
- term.setCursorPos(26,14)
- term.write(" Checking for updates...")
- if not http then
- -- tell user to turn on http api
- term.setCursorPos(26,14)
- term.write(" LithOS Updater cannot ")
- term.setCursorPos(26,15)
- term.write(" work without the HTTP API")
- sleep(3)
- else
- -- download file
- local response = http.get("http://pastebin.com/raw.php?i=8Kvh0Sze")
- if response then
- local data = response.readAll()
- response.close()
- local file = fs.open(".programs/update", "w")
- file.write(data)
- file.close()
- shell.run(".programs/update")
- if ver > 2.03 then
- term.setCursorPos(26,15)
- term.write(" New Version Available ")
- term.setCursorPos(26,16)
- term.write(" ")
- term.setBackgroundColor(colors.gray)
- term.setCursorPos(27,16)
- term.write("Update")
- term.setCursorPos(34,16)
- term.write("Later")
- choice = false
- while not choice do
- local event, button, x, y = os.pullEvent("mouse_click")
- if button == 1 then
- if x >= 27 and x <= 32 and y == 16 then
- choice = true
- -- Download new installer
- local response = http.get("http://pastebin.com/raw.php?i=XYLELffE")
- if response then
- local data = response.readAll()
- response.close()
- local file = fs.open(".programs/startup", "w")
- file.write(data)
- file.close()
- shell.run("delete", ".programs")
- sleep(1)
- os.reboot()
- end
- elseif x >= 34 and x <= 38 and y == 16 then
- choice = true
- -- Begin OS
- end
- end
- end
- else
- term.setCursorPos(26,14)
- term.write(" No Updates Found ")
- sleep(3)
- end
- else
- -- if no response, we assume this
- term.setCursorPos(26,14)
- term.write(" Unable to connect ")
- term.setCursorPos(26,15)
- term.write(" to the internet.")
- sleep(3)
- end
- end
- end
- shell.run(".programs/login")
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement