Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local gpu = require("component").gpu
- local internet = require("component").internet
- local fs = require("filesystem")
- --Проверка компонентов--
- do
- NeedCom = {}
- NowW,NowH = gpu.maxResolution()
- if NowW < 80 then
- table.insert(NeedCom,"Your monitor is 1 tier. Upgrade it to 2 tier or upper...")
- end
- if fs.get("bin/edit.lua") == nil or fs.get("bin/edit.lua").isReadOnly() then
- table.insert(NeedCom,"You don't install OpenOS. Please intall it...")
- end
- if NeedCom ~= nil then
- local i = 1
- for i = 1,#NeedCom do
- print(NeedCom[i])
- end
- else
- print("O'key! All components is ready!\nStart download...")
- end
- end
- --Скачивание необходимого--
- do
- DownloadList =
- {
- GPAPI = "Good-Pudge/OpenComputers-OS/master/Uduntu/GPAPI.lua",
- }
- local function request(url)
- local success, response = pcall(component.internet.request, url)
- if success then
- local responseData = ""
- while true do
- local data, responseChunk = response.read()
- if data then
- responseData = responseData .. data
- else
- if responseChunk then
- return false, responseChunk
- else
- return responseData
- end
- end
- end
- else
- return false, reason
- end
- end
- --БЕЗОПАСНАЯ ЗАГРУЗОЧКА
- local function getFromGitHubSafely(url, path)
- local success, reason = request(url)
- if success then
- fs.makeDirectory(fs.path(path) or "")
- fs.remove(path)
- local file = io.open(path, "w")
- file:write(success)
- file:close()
- return success
- else
- io.stderr:write("Can't download \"" .. url .. "\"!\n")
- return -1
- end
- end
- local GitHubUserUrl = "https://raw.githubusercontent.com/"
- for k,v in pairs(DownloadList) do
- print("Downloading \"" .. fs.name(DownloadList[k]) .. "\"")
- getFromGitHubSafely(GitHubUserUrl..DownloadList[v], DownloadList[k])
- end
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement