forked from xyqyear/auto-crossbreeding
-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathinstall.lua
57 lines (49 loc) · 1.3 KB
/
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
local shell = require("shell")
local filesystem = require("filesystem")
local args = {...}
local scripts = {
"action.lua",
"database.lua",
"gps.lua",
"posUtil.lua",
"scanner.lua",
"signal.lua",
"autoStat.lua",
"autoCrossbreed.lua",
"autoSpread.lua",
"install.lua"
}
local function exists(filename)
return filesystem.exists(shell.getWorkingDirectory().."/"..filename)
end
local branch
local option
if #args == 0 then
branch = "main"
else
branch = args[1]
end
if branch == "help" then
print("Usage:\n./install or ./install [branch] [updateconfig] [repository]")
return
end
if args[2] ~= nil then
option = args[2]
end
local repo = args[3] or "https://raw.githubusercontent.com/huchenlei/auto-crossbreeding/";
for i=1, #scripts do
shell.execute(string.format("wget -f %s%s/%s", repo, branch, scripts[i]));
end
if not exists("config.lua") then
shell.execute(string.format("wget %s%s/config.lua", repo, branch));
end
if option == "updateconfig" then
if exists("config.lua") then
if exists("config.bak") then
shell.execute("rm config.bak")
end
shell.execute("mv config.lua config.bak")
print("Moved config.lua to config.bak")
end
shell.execute(string.format("wget %s%s/config.lua", repo, branch));
end