-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathinstaller
61 lines (52 loc) · 1.98 KB
/
installer
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
local targetDir = "/"
local url = "https://raw.githubusercontent.com/ninnghazad/SWARM/master/"
--
term.clear()
term.setCursorPos(1,1)
print("SWARM installer\n")
local files = {
["drone"] = {"drone","swarm","debug","map","heap","swarm_drone","swarm_config_drone"},
["mapserver"] = {"mapserver","swarm","debug","map","heap","swarm_mapserver","swarm_config_mapserver"},
["jobserver"] = {"jobserver","swarm","debug","map","heap","swarm_jobserver","swarm_config_jobserver"},
["infoserver"] = {"infoserver","swarm","debug","map","heap","swarm_infoserver","swarm_config_infoserver"},
["tools"] = {"swarm_pmon","swarm_ploc","swarm_status","swarm_reboot","swarm_hardreboot","swarm_shutdown","job"}
}
local infos = {
["drone"] = "Installer finished, place drone in homePos an boot it. Then change the config, if you want, and reboot it again.",
["mapserver"] = "Installer finished, type startup to start mapserver.",
["jobserver"] = "Installer finished, type startup to start jobserver.",
["infoserver"] = "Installer finished, type startup to start infoserver.",
["tools"] = "Installer finished, type ls to see installed tools."
}
local mode = {...}
if mode == nil or #mode ~= 1 or files[mode[1]] == nil then
print("Please specifiy a package to install\nas only argument: ")
for k,v in pairs(files) do
print("\t"..k)
end
return
end
mode = mode[1]
print("Will download and install "..mode)
for i,fn in pairs(files[mode]) do
r = http.get(url..fn)
if r then
r = r.readAll()
f = io.open("./"..fn,"w")
f:write(r)
f:close()
print("Downloaded successfully: "..fn)
else
print("Could not download "..url..fn)
os.exit(true)
end
end
os.loadAPI("swarm")
swarm.installFiles(files)
swarm.replaceFile("swarm_"..mode,targetDir.."/startup")
swarm.replaceFile("swarm_config_"..mode,targetDir.."/"..swarm.configFileName)
os.setComputerLabel(mode.." "..os.getComputerID())
print("")
print(infos[mode])
print("Don't forget to 'edit "..swarm.configFileName.."'!")
print("To update type 'installer "..mode.."' again.")