dragon/setup.lua

41 lines
1.2 KiB
Lua
Raw Normal View History

2018-04-29 14:42:08 +00:00
local argv = {...}
2018-04-29 14:32:49 +00:00
local root = "https://osmarks.ml/git/osmarks/dragon/raw/branch/master/"
2018-04-29 19:55:16 +00:00
local function download(url, file)
local contents = http.get(url).readAll()
2018-04-29 14:32:49 +00:00
local f = fs.open(file, "w")
f.write(contents)
f.close()
end
2018-04-29 19:55:16 +00:00
local files = { "client.lua", "server.lua", "util.lua", "setup.lua", "crafter.lua", "patterns.lua" }
2018-04-29 14:32:49 +00:00
for _, f in pairs(files) do
2018-04-29 19:55:16 +00:00
download(root .. f, f)
2018-04-29 14:32:49 +00:00
print("Downloaded", f)
end
2018-04-29 19:55:16 +00:00
-- Download functional Lua library
2018-04-30 18:58:12 +00:00
download("https://raw.githubusercontent.com/Yonaba/Moses/master/moses_min.lua", "moses.lua")
2018-04-29 19:55:16 +00:00
print "Downloaded Moses library"
2018-04-29 14:32:49 +00:00
print "Files downloaded. Either client.lua or server.lua should be run on startup."
2018-04-29 14:42:08 +00:00
if argv[1] == "update" then os.reboot() end
2018-04-29 14:32:49 +00:00
print "Opening config editor..."
shell.run "edit conf"
2018-04-29 14:36:36 +00:00
pcall(fs.move, "conf.lua", "conf") -- edit is really stupid, so un-.lua output file
local ty
repeat
2018-04-29 19:55:16 +00:00
print "Would you like this node set up as a server, crafter or client?"
2018-04-29 14:36:36 +00:00
ty = read()
2018-04-29 19:55:16 +00:00
until ty == "server" or ty == "client" or ty == "crafter"
2018-04-29 14:36:36 +00:00
local f = fs.open("startup", "w")
f.write("shell.run '" .. ty .. "'")
f.close()
2018-04-29 14:37:53 +00:00
os.setComputerLabel "Dragon Node"
2018-04-29 14:37:46 +00:00
2018-04-29 14:36:36 +00:00
print "Done! Reboot or run startup."