refactor: better install script
This commit is contained in:
parent
7dc979f8c4
commit
27afb3eade
45
install.lua
45
install.lua
@ -1,9 +1,13 @@
|
||||
local LIST_FILES = {
|
||||
'miner.lua',
|
||||
'simple-harvester.lua',
|
||||
'inferium-upgrader.lua'
|
||||
};
|
||||
|
||||
local LIST_LIBS_FILES = {
|
||||
'libs/turtle-utils.lua',
|
||||
'libs/robot.lua'
|
||||
};
|
||||
}
|
||||
|
||||
local LIST_CONFIG_FILES = {
|
||||
'startup.lua',
|
||||
@ -13,21 +17,38 @@ local LIST_CONFIG_FILES = {
|
||||
|
||||
local REPO_PREFIX = 'https://git.trapcloud.fr/guillaumearm/minecraft-cc-tools/raw/branch/master/'
|
||||
|
||||
local previousDir = shell.dir()
|
||||
|
||||
fs.makeDir('/libs')
|
||||
fs.makeDir('/config')
|
||||
|
||||
for _, filePath in pairs(LIST_FILES) do
|
||||
fs.delete(filePath)
|
||||
shell.execute('wget', REPO_PREFIX .. filePath, filePath)
|
||||
local prepareDirs = function()
|
||||
fs.makeDir('/libs')
|
||||
fs.makeDir('/config')
|
||||
end
|
||||
|
||||
-- do not override existing config files
|
||||
for _, filePath in pairs(LIST_CONFIG_FILES) do
|
||||
if not fs.exists(filePath) then
|
||||
local installFiles = function(list)
|
||||
for _, filePath in pairs(list) do
|
||||
fs.delete(filePath)
|
||||
shell.execute('wget', REPO_PREFIX .. filePath, filePath)
|
||||
end
|
||||
end
|
||||
|
||||
shell.setDir(previousDir)
|
||||
local installConfig = function()
|
||||
-- do not override existing config files
|
||||
for _, filePath in pairs(LIST_CONFIG_FILES) do
|
||||
if not fs.exists(filePath) then
|
||||
shell.execute('wget', REPO_PREFIX .. filePath, filePath)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function mainSetup = function()
|
||||
local previousDir = shell.dir()
|
||||
|
||||
prepareDirs()
|
||||
installFiles(LIST_LIBS_FILES)
|
||||
installFiles(LIST_FILES)
|
||||
installConfig()
|
||||
|
||||
shell.setDir(previousDir)
|
||||
end
|
||||
|
||||
mainSetup()
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user