Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Simple Graphic Library installer--
- local component = require ("component")
- local computer = require ("computer")
- local io = require ("io")
- local internet
- ---------------------------------------------
- local SGL_URL = "https://raw.githubusercontent.com/Smok1e/SGL/master/SGL.lua"
- local SGL_VERSION_URL = "https://raw.githubusercontent.com/Smok1e/SGL/master/SGL_Version.lua"
- local SGL_TEST_URL = "https://raw.githubusercontent.com/Smok1e/SGL/master/SGL_Test.lua"
- local SGL_AUTOUPDATE_URL = "https://raw.githubusercontent.com/Smok1e/SGL/master/SGL_AutoUpdate.lua"
- local SGL_INSTALL_PATH = "/lib/SGL.lua"
- local SGL_VERSION_INSTALL_PATH = "/lib/SGL_Version.lua"
- local SGL_TEST_INSTALL_PATH = "/home/SGL_Test.lua"
- local SGL_AUTOUPDATE_INSTALL_PATH = "/boot/100_SGL_Update.lua"
- ---------------------------------------------
- local function download (url, path)
- local request = internet.request (url)
- if not request or request.response () then return nil, "Failed to get data from " .. url end
- local file, reason = io.open (path, "w")
- if not file then return nil, reason end
- while true do
- local chunk = request.read ()
- if not chunk then break end
- file:write (chunk)
- end
- file:close ()
- return true
- end
- local function info_download (url, path)
- print ("Downloading from '" .. url .. "' to '" .. path .. "'...")
- local result, reason = download (url, path)
- if not result then print (reason) return false end
- return true
- end
- ---------------------------------------------
- do
- if component.list ("internet") () then
- internet = component.internet
- else
- print ("Failed to load SGL: You do not have internet card")
- end
- if not info_download (SGL_URL, SGL_INSTALL_PATH) then return end
- --if not info_download (SGL_VERSION_URL, SGL_VERSION_INSTALL_PATH) then return end
- if not info_download (SGL_TEST_URL, SGL_TEST_INSTALL_PATH) then return end
- --if not info_download (SGL_AUTOUPDATE_URL, SGL_AUTOUPDATE_INSTALL_PATH) then return end
- print ("Done")
- print ("Your computer will reboot in 3 seconds...")
- os.sleep (3)
- computer.shutdown (true)
- end
- ---------------------------------------------
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement