· 2 years ago · Mar 10, 2023, 01:50 PM
1-- wget https://raw.githubusercontent.com/Corbinhol/Nuclear-Crafter-fusion-reactor-controller/main/Setup.lua -Q && Setup.lua -p -f -r
2
3local filesystem = require("filesystem");
4local component = require("component");
5local term = require("term");
6local shell = require("shell");
7local computer = require("computer");
8local version = "0.1";
9
10local args = {...};
11
12local uninstall = false;
13local forceInstall = false;
14local repair = false;
15local pastebin = false;
16
17for i,arg in ipairs(args) do
18 if arg == "-u" then uninstall = true; end
19 if arg == "-f" then forceInstall = true; end
20 if arg == "-r" then repair = true; end
21 if arg == "-p" then pastebin = true; end
22end
23
24function pastebinInstall()
25 print("Starting Install...");
26 shell.execute("mkdir /home/FusionController")
27 shell.execute("pastebin get wJCXfem8 /bin/Controller.lua"); --Download Controller
28 shell.execute("pastebin get KAR6jmr8 /home/FusionController/API.lua"); --Download Controller API
29end
30
31function run_uninstall()
32 print("Uninstalling Reactor Controller...");
33 os.sleep(1);
34 filesystem.remove("/bin/Controller.lua");
35 filesystem.remove("/home/FusionController/");
36end
37
38term.clear();
39print(string.rep("═", 80));
40if uninstall then
41 run_uninstall()
42 shell.execute("rm Setup.lua");
43 print("Finished Uninstalling. Press any key to restart.");
44 io.read();
45 computer.shutdown(true);
46else
47 if component.isAvailable("nc_fusion_reactor") or forceInstall then
48 print("Starting Reactor Controller Setup | " .. version);
49 if filesystem.exists("/bin/Controller.lua") then
50 if repair == false then
51 print("Detected controller already on system...");
52 print("Would you like to uninstall the Controller first? [Y/n]");
53 local answer = io.read();
54 else
55 answer = "Y"
56 end
57 if answer == "n" or answer == "N" then
58 print("Closing Setup...");
59 os.sleep(1);
60 term.clear();
61 os.exit();
62 else
63 run_uninstall();
64 end
65 end
66 if pastebin then
67 if not forceInstall then
68 print("[WARNING] Pastebin Argument detected. Using pastebin is not the recommended form, since pastes aren't permanent. Would you like to continue [Y/n]");
69 local pastebinAnswer = io.read();
70 else
71 local pastebinAnswer = "y";
72 end
73 if pastebinAnswer == "n" or pastebinAnswer == "N" then
74 print("Closing Setup...");
75 os.sleep(1);
76 term.clear();
77 os.exit();
78 end
79 pastebinInstall();
80 else
81 print("Starting Install...");
82 shell.execute("mkdir /home/FusionController")
83 shell.execute("wget https://raw.githubusercontent.com/Corbinhol/Nuclear-Crafter-fusion-reactor-controller/main/Controller.lua /bin/Controller.lua -Q");
84 shell.execute("wget https://raw.githubusercontent.com/Corbinhol/Nuclear-Crafter-fusion-reactor-controller/main/Api.lua /home/FusionController/Api.lua -Q");
85 end
86 print("Finished Installing. Press any key to restart.");
87 io.read();
88 computer.shutdown(true);
89 else
90 print("Error: No fusion reactor found, [Use -f to force install without it]");
91 os.exit();
92 end
93end
94
95