Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --Installer for OpenComputers Gitlab API Library
- --For More Info See: https://gitlab.com/Corbinhol/opencomputers-gitlab-api-library
- if gitlab ~= nil then
- io.write("It seems that the gitlab library is already loaded. Unloading...");
- gitlab = nil;
- if gitlab ~= nil then
- io.write("Failed.\n");
- os.exit();
- end
- io.write("Done.\n")
- end
- local filesystem = require("filesystem");
- local internet = require("internet");
- local term = require("term");
- function combine(handle)
- local out = "";
- for chunk in handle do out = out .. chunk end
- return out;
- end
- function download(url, dir)
- local handle = internet.request(url);
- local result, data = pcall(combine, handle);
- if not result then
- error("Failure to connect to " .. url);
- end
- local file = io.open(dir, "w");
- file:write(data);
- file:close();
- return true;
- end
- if not filesystem.exists("/usr/lib") then
- io.write("User library folder does not seem to exist. Creating now...");
- filesystem.makeDirectory("/usr/lib");
- io.write("done.\n");
- end
- io.write("Beginning Installation of Gitlab API Library...\n");
- io.write("Downloading Gitlab Module...");
- download("https://gitlab.com/Corbinhol/opencomputers-gitlab-api-library/-/raw/main/gitlab.lua?ref_type=heads", "/usr/lib/gitlab.lua");
- io.write("done.\n");
- io.write("Downloading Base64 Dependency...");
- download("https://gitlab.com/Corbinhol/opencomputers-gitlab-api-library/-/raw/main/base64.lua?ref_type=heads", "/usr/lib/base64.lua");
- io.write("done.\n");
- io.write("Downloading JSON Dependency...");
- download("https://gitlab.com/Corbinhol/opencomputers-gitlab-api-library/-/raw/main/json.lua?ref_type=heads", "/usr/lib/json.lua");
- io.write("done.\n");
- if not filesystem.exists("/usr/bin") then
- io.write("User bin folder does not seem to exist. Creating now...");
- filesystem.makeDirectory("/usr/bin");
- io.write("done.\n");
- end
- io.write("Downloading Gitlab Application...");
- download("https://gitlab.com/Corbinhol/opencomputers-gitlab-api-library/-/raw/main/Program/Gitlab.lua?ref_type=heads", "/usr/bin/gitlab.lua");
- io.write("done.\n");
- io.write("If you have an API Key you'd like to use, please enter it. If not, then just press enter. [Warning Key will be saved on computer.\nDo not use if you share this computer with others you do not trust!!]: ");
- local key = term.read({pwchar = "*", dobreak=false});
- local key = string.gsub(key, "\n", "");
- if key ~= "" then
- io.write("\nSaving key...");
- local gitlab = require("gitlab");
- gitlab.save_key(key);
- io.write("done.\n");
- else
- io.write("\nSkipping Key.\n");
- end
- io.write("Instalation Complete!");
Add Comment
Please, Sign In to add comment