Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local filesystem = require("filesystem")
- local component = require("component")
- local term = require("term")
- local internet = require("internet")
- local gpu = component.gpu
- local shell = require("shell")
- local os = require("os")
- local function download(_file)
- if component.isAvailable("internet") then
- if _file == "bcore_api" then
- local f1, _ = io.open("/bAPIS/bcore.lua","w")
- local result, response = pcall(internet.request, "http://pastebin.com/raw.php?i=8czw0qSx")
- if result then
- for chunk in response do
- f1:write(chunk)
- end
- f1:close()
- else
- io.stderr:write("Error downloading bcore")
- return
- end
- elseif _file == "bcolor_api" then
- local f2, _ = io.open("/bAPIS/bcolor.lua","w")
- local result2, response2 = pcall(internet.request, "http://pastebin.com/raw.php?i=ayxkDdwg")
- if result2 then
- for chunk in response2 do
- f2:write(chunk)
- end
- f2:close()
- else
- io.stderr:write("Error downloading bcolor")
- return
- end
- elseif _file == "package_new" then
- filesystem.remove("/lib/package.lua")
- local f3, _ = io.open("/lib/package.lua", "w")
- local result3, response3 = pcall(internet.request, "http://pastebin.com/raw.php?i=sPKxWynf")
- if result3 then
- for chunk in response3 do
- f3:write(chunk)
- end
- f3:close()
- else
- io.stderr:write("Error downloading new package file")
- return
- end
- end
- else
- io.stderr:write("No internet connection: component internet missing\nYou have to download the bAPIS manually.")
- return
- end
- end
- local function status(msg)
- local w,h = gpu.getResolution
- term.write(msg)
- xt, yt = term.getCursor()
- term.setCursor(1,yt+1)
- end
- term.clear()
- status("Checking APIS...")
- if not filesystem.exists("/bAPIS/") then
- status("Creating API-Folder")
- filesystem.makeDirectory("/bAPIS/")
- else
- status("API-Folder existing - skipping")
- os.sleep(0.2)
- end
- if not filesystem.exists("/bAPIS/bcore.lua") then
- status("downloading API bcore")
- download("bcore_api")
- else
- status("bcore existing - skipping")
- os.sleep(0.2)
- end
- if not filesystem.exists("/bAPIS/bcolor.lua") then
- status("downloading API bcolor")
- download("bcolor_api")
- else
- status("bcolor existing - skipping")
- os.sleep(0.2)
- end
- status("Finished checking apis")
- status("Replacing systemfile: package.lua")
- download("package_new")
- status("Finished replacing package.lua")
- term.clear()
- shell.execute("shell")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement