-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstaller.lua
More file actions
108 lines (87 loc) · 2.66 KB
/
Installer.lua
File metadata and controls
108 lines (87 loc) · 2.66 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
-- Generic installer that asks which component to install then runs the relevant installer
local args = {...}
local toInstall = ""
local overwrite = false
local helpText = [[
Usage:
Installer -> Run install wizard
Shortcuts:
Installer -S -> Install Server
Installer -G -> Install Monitor_GUI
Installer -T -> Install TUI
Options:
-o -> Overwrite any existing CCStorage files
]]
for k, v in pairs(args) do
if v == "-h" or v == "--help" then
print(helpText)
return
end
if v == "-S" then toInstall = "Server"
elseif v == "-G" then toInstall = "Monitor_GUI"
elseif v == "-T" then toInstall = "TUI"
end
if v == "-o" then overwrite = true end
end
term.setCursorPos(1,1)
term.clear()
if not overwrite and fs.exists("/CCStorage") then
print("CCStorage seems to already be installed.")
print("Please wipe any existing files before reinstalling, or run with the '-o' flag to overwrite")
return
end
local installPrompt = [[
Which component do you want to install?
1: Server
2: Monitor_GUI
3: TUI
]]
if toInstall == "" then --if no shortcuts set it already
print(installPrompt)
while toInstall == "" do
local response = read()
if response == "1" then toInstall = "Server"
elseif response == "2" then toInstall = "Monitor_GUI"
elseif response == "3" then toInstall = "TUI"
else
print("Unrecognised value, please try again")
end
end
end
-- safety check
if toInstall == "" then
print("something has gone very wrong")
return
end
-- actually do the installing
fs.makeDir("/CCStorage")
local mainURL = "https://raw.githubusercontent.com/Ictoan42/CCStorage/main/"
if overwrite then
shell.run("wget run " .. mainURL .. toInstall .. "/Installer.lua -o")
else
shell.run("wget run " .. mainURL .. toInstall .. "/Installer.lua")
end
--[[ while true do
print("Would you like the component to run on startup? [Y/n]")
local response = read()
if response == "Y" or response == "" then
print("Creating startup script...")
if fs.exists("/startup.lua") then
print("Failed to create startup script: startup.lua already exists")
else
local f = fs.open("/startup.lua", "w")
f.write("term.clear()")
f.write("term.setCursorPos(1, 1)")
f.write("shell.run(\"CCStorage/Main.lua\")")
f.close()
end
break
elseif response == "n" then
print("No startup script will be created")
break
else
print("Unrecognised response, please re enter")
end
end ]]
print("")
print("Installation complete")