-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstall.lua
201 lines (168 loc) · 6.44 KB
/
install.lua
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
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
--This entire file needs to be redone.
--... mostly.
--Needs to get file list from github, anyway, and download that.
--optionally, add a cui to select what to download
--If selecting something with dependancies, also select those if not allready.
--sort files, and allow groups of similar ones to be grouped.
--Will install from branch Master when im done with it.
--Each release will ALSO get its own install file.
--Correction; while each release will get its own install file, will use this main file for master and...
--generall ALL the branches. most notably with the latest branch and master branch.
--testing the new versions i add.
-- Download as "install", IE: >pastebin get 7W48dz3c install
-- this way i can move it into the main directory when startup loads.
-- (Although it seems to work fine just as a run, like> pastebin run 7W48dz3c)
args = {...}
if args[1] == "v" then
verbose = true
elseif args[1] == "storage" then
storage = true
end
function printVerbose(str)
if verbose == true then
print(str)
end
end
--if verbose, print string.
-- I will now need to make a install specifically for minecraft 1.7.10, should i want to keep it
-- functional...
--This now needs to change as im no longer building with my previous mindset of 'CCOSish,'
local gitlist = {
["startup.lua"] = "startup.lua",
["wireless.lua"] ="functions/wireless.lua",
["logic.lua"] = "functions/logic.lua",
["help.lua"] = "functions/help.lua",
["peripherals.lua"] = "functions/peripherals.lua",
["programs.lua"] = "functions/programs.lua"
}
--local exception = {"startup.lua"} -- doesnt go into the directory. stays in root.
--Currently unused, as key = value list is not deterministic.
local commitList = {
"master/", --main release channel
"beta-0.7/" --Classic CC release channel
}
--For now i wont change the above functionally. But im 99% sure it can be done with one array.
--Todo... Not important atm cause it actually works.
if not fs.exists("sys") then
dir = "sys/"
dircheck = true
end
while not dircheck do
--If something went wrong with getting the directory automatically...
write("Input a name for the directory that you would like to use. \nThis will contain pretty much all of the files. If it's not empty, then items inside may end up being deleted. \nThis only appears after 'sys' has been checked (this will be the name for a directory)\n>")
dir = read()
if not fs.exists(dir) then
dircheck=true
break
else
dircheck=false
write("\nWARNING: File/Folder exists. Continue? (y/n)\n>")
local input = read()
if input=='y' then
dircheck=true
write("\n")
break
else
dir=nil
end
end
--Warn the user that it will loop
write("\nWarning, this will loop until a usable directory has been found\n")
end
if dir then
local str=string.sub(dir,-2,-1)
if str ~= '/' or str ~= '\\' then
dir=dir.."/"
elseif str == '\\' then
dir=string.sub(dir,1,-2)
dir=dir.."/"
end
--Fixes problems with werid slashes.
--Honestly, i dont really remember why this was needed.
--I do remember it being added because of a really specific bug though.
fs.makeDir(dir)
local temp=fs.open(".system/notes","w")
temp.write("dir = ".."'"..dir.."'\n") -- this hurts my soul
temp.close() --but its the easiest way to turn it into a string to be read later
temp=nil
--This should prevent the need of repeating this 'fix' again anywhere else.
end
--write("Would you like to download the latest release or latest commit? (Commit may not launch.)\n('C' for commit, 'M' for release (or 'S' to specify)\n>")
--local commit = read()
--commit=string.lower(commit)
--[[Will leave this but currently unneeded i think.
if commit == "m" or commit == "master" or commit=="main" then
print("\nDownloading master branch. (Stable release)\n")
branch = commitList[1]
elseif commit == "c" or commit == "commit" or commit == "beta" then
print("\nDownloading latest commit; "..commitList[2].."\n")
branch = commitList[2]
end--]]
branch = "master/"
for key,value in pairs(gitlist) do
lista = value --github filenames
listb = key --CC filenames
printVerbose(key,value)
if lista==nil then
return --?
end
local temp, a = http.get("https://raw.githubusercontent.com/Link-Jon/Link-CC/"..branch..lista)
printVerbose(temp,a)
raw=temp.readAll()
--May need to do exceptions differently than before.
--Now, it manually excludes startup.
if lista=="startup.lua" or dir==nil then
file = fs.open(listb,"w")
else
file = fs.open(dir..listb,"w")
end
file.write(raw)
file.close()
print("Downloaded: "..lista.." as "..listb)
end
print("Finished!")
sleep(0.2)
--[[
write("Would you like to set up a username and password now? (y/n)\n>")
local temp = string.lower(read())
if temp == "y" or temp=="yes" then
write("\nEnter a username (It will be the admin username FYI)\n>")
local name=read()
write("\nEnter a password.\n>")
local pass=read()
temp=fs.open(".system/notes","a")
temp.write("user1={\""..name.."\",\""..pass.."\",2}\n") --name,pass,teir
temp.flush()
write("\nDo you want to add another user?\n>")
name=string.lower(read())
if name == "t" or name == "true" or name == "yes" or name == "y" then
looper=true
else
looper=false
end
while looper==true do
write("\nEnter the username\n>")
name=read()
write("\nEnter the password\n>")
pass=read()
write("\nEnter the teir\n(0 for guest, 1 for friend, 2 for admin. See readme for more detail.)\n>")
teir=read()
if teir==3 then
teir=2
end
temp.write("user1={\""..name.."\",\""..pass.."\","..teir.."}\n")
temp.flush()
write("\n>Do you want to add another user? (y/n)\n>")
name=string.lower(read())
if name == "f" or name == "false" or name == "no" or name == "n" then
looper=false
else
looper=true
end
end
temp.close()
temp=nil
else
write("\nUnderstood; name/password will be default.")
write("\nYou will be asked again whenever the program starts.\n")
end --]]