Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- local filesystem = require("filesystem");
- local component = require("component");
- local computer = require("computer");
- local internet = require("internet")
- local args = {...};
- --Yeah...I admit...I took this directly from the opencomputers pastebin program.
- function install(pasteId, filename)
- local f, reason = io.open(filename, "w")
- if not f then
- print("Failed opening file for writing: " .. reason)
- return
- end
- local url = "https://pastebin.com/raw/" .. pasteId
- local result, response = pcall(internet.request, url)
- if result then
- for chunk in response do
- -- string.gsub(chunk, "\r\n", "\n")
- f:write(chunk)
- end
- f:close()
- else
- f:close()
- fs.remove(filename)
- print("HTTP request failed: " .. response)
- end
- end
- if not component.isAvailable("internet") then
- print("Error! No internet card found. This program needs an internet card to update/install the program.");
- os.exit();
- end
- if args[1] == "-d" then
- install("iFrWyDs9", "/usr/CM_Automator/installer.lua");
- os.execute("/usr/CM_Automator/installer.lua");
- os.exit();
- end
- --Check if internet component exists. If not then abort as update cannot proceed.
- --Install Script
- print("Starting install script.");
- --First thing it does is check if the directory exists, if not then it creates it. If that fails for whatever reason
- --Then it aborts.
- if not filesystem.isDirectory("/usr/CM_Automator") then
- print("Directory could not be located. Creating.");
- local success = filesystem.makeDirectory("/usr/CM_Automator");
- if success then
- print("Directory created successfully!");
- else
- print("Error! Could not create directory. Aborting.");
- os.exit();
- end
- success = nil;
- else
- print("Directory already exists. Presumed to be update or repair.");
- end
- print("Installing Main Script...");
- install("5tKHxEdJ", "/usr/CM_Automator/main.lua");
- -- os.execute("pastebin get -f 5tKHxEdJ /usr/CM_Automator/main.lua");
- print("Installing Console Library...");
- install("epQvyACM", "/usr/CM_Automator/console.lua");
- -- os.execute("pastebin get -f Xwy0069d /usr/CM_Automator/console.lua");
- print("Installing Starter Wrapper...");
- install("1Yp5ys95", "/bin/cmauto.lua");
- -- os.execute("pastebin get -f 1Yp5ys95 /bin/cmauto.lua");
- print("Installing Networking Library...");
- install("aDDLpZ7q", "/usr/CM_Automator/network.lua");
- print("Installing startup script");
- install("YqChNPaJ", "/autorun.lua");
- install("iFrWyDs9", "/usr/CM_Automator/installer.lua");
- -- os.execute("pastebin get -f aDDLpZ7q /usr/CM_Automator/network.lua");
- print("Finished Setup. Restarting in 1 second");
- os.sleep(1);
- computer.shutdown(true);
Advertisement
Add Comment
Please, Sign In to add comment