forked from Forte40/openbee
-
Notifications
You must be signed in to change notification settings - Fork 0
/
openbee-install.lua
71 lines (67 loc) · 1.58 KB
/
openbee-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
--http://pastebin.com/Nq5jEJfM
if not http then
print("No access to web")
return
end
local branch = "master"
local files = {
{
name = "openbee-install",
url = "https://raw.github.com/Forte40/openbee/"..branch.."/openbee-install.lua"
},
{
name = "openbee",
url = "https://raw.github.com/Forte40/openbee/"..branch.."/openbee.lua"
},
{
name = "matron",
url = "https://raw.github.com/Forte40/openbee/"..branch.."/matron.lua"
}
}
for _, file in ipairs(files) do
local path
if file.folder then
if not fs.exists(file.folder) then
fs.makeDir(file.folder)
end
path = fs.combine(file.folder, file.name)
else
path = file.name
end
local currText = ""
if fs.exists(path) then
local f = fs.open(path, "r")
currText = f.readAll()
f.close()
io.write("update ")
else
io.write("install ")
end
io.write("'"..file.name.."'"..string.rep(" ", math.max(0, 8 - #file.name)))
if file.folder then
io.write(" in '"..file.folder.."'"..string.rep(".", math.max(0, 8 - #file.folder)).."...")
else
io.write(" .............")
end
local request = http.get(file.url)
if request then
local response = request.getResponseCode()
if response == 200 then
local newText = request.readAll()
if newText == currText then
print("skip")
else
local f = fs.open(path, "w")
f.write(newText)
f.close()
print("done")
end
else
print(" bad HTTP response code " .. response)
end
else
print(" no request handle")
end
os.sleep(0.1)
end
print("Finished")