This repository was archived by the owner on Jan 8, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinstaller.lua
70 lines (61 loc) · 1.42 KB
/
installer.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
local FILES_DIR = "https://raw.githubusercontent.com/MaximPixel/CCLauncher/master/files.xml"
function downloadFile(link, path)
data = http.get(link)
if data then
text = data.readAll()
data.close()
if text then
file = fs.open(path, "w")
file.write(text)
file.close()
return true
end
end
return false
end
function reinstallAll()
filesData = http.get(FILES_DIR)
if filesData then
filesText = filesData.readAll()
filesData.close()
if filesText then
filesTable = textutils.unserialise(filesText)
if filesTable and type(filesTable.files) == "table" and type(filesTable.version) == "string" then
if filesTable.files.main then
for _,i in ipairs(filesTable.files.main) do
flag = downloadFile(i.link, i.path)
if flag then
print("intalled " .. i.path)
else
print("failed " .. i.path)
end
end
end
if turtle and filesTable.files.turtle then
for _,i in ipairs(filesTable.files.turtle) do
flag = downloadFile(i.link, i.path)
if flag then
print("intalled " .. i.path)
else
print("failed " .. i.path)
end
end
end
return true
end
return false, "Unknown format"
end
end
return false, "No connection"
end
print("Reinstall? [y/n]")
answer = read()
if answer == "y" or answer == "Y" then
print("Reinstalling...")
suc, err = reinstallAll()
if suc then
print("Done!")
else
print(err)
end
end