-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathInstaller.lua
More file actions
71 lines (46 loc) · 1.5 KB
/
Installer.lua
File metadata and controls
71 lines (46 loc) · 1.5 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
-- Program to update devRant
-- Essentially a "git pull git@github.com:olback/devRant-computercraft"
local downloadMain = "https://raw.githubusercontent.com/olback/devRant-computercraft/master/devRant.lua"
local downloadJSON = "https://raw.githubusercontent.com/olback/devRant-computercraft/master/json.lua"
local downloadInstaller = "https://raw.githubusercontent.com/olback/devRant-computercraft/master/Installer.lua"
local version = "1.0d"
local headers = {["User-Agent"] = "ComputerCraft devRant Updater" .. version}
local main = http.get(downloadMain, headers)
local json = http.get(downloadJSON, headers)
local installer = http.get(downloadInstaller, headers)
----- Failed function -----
function failed(file)
if term.isColor() then
term.setTextColor(colors.red)
end
print("Failed to update ".. file)
term.setTextColor(colors.white)
end
----- Udate devRant -----
if main ~= nil then
-- Don't bother removing old file since f.write() will write over it anyways.
print("Updating devRant...")
f = fs.open("devRant", "w")
f.write(main.readAll())
f.close()
else
failed("devRant")
end
----- Update json API -----
if json ~= nil then
print("Updating JSON API...")
f = fs.open("json", "w")
f.write(json.readAll())
f.close()
else
failed("json")
end
----- Update installer -----
if installer ~= nil then
print("Updating installer...")
f = fs.open("devRantInstaller", "w")
f.write(installer.readAll())
f.close()
else
failed("installer")
end