From 12b56461bb13e3c829b885c6eb053a6bf46ba7eb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=C5=81ukasz=20Magiera?= Date: Sat, 15 Nov 2014 20:58:57 +0000 Subject: [PATCH] Update install --- .../opencomputers/loot/OpenOS/bin/install.lua | 46 ++++++++++++++----- 1 file changed, 35 insertions(+), 11 deletions(-) diff --git a/src/main/resources/assets/opencomputers/loot/OpenOS/bin/install.lua b/src/main/resources/assets/opencomputers/loot/OpenOS/bin/install.lua index 48fa32a75..91773118d 100644 --- a/src/main/resources/assets/opencomputers/loot/OpenOS/bin/install.lua +++ b/src/main/resources/assets/opencomputers/loot/OpenOS/bin/install.lua @@ -4,6 +4,29 @@ local event = require("event") local unicode = require("unicode") local shell = require("shell") +local args = {...} + +local name = "OpenOS" +local postInstallLabel = "OpenOS" +local origin = computer.getBootAddress():sub(1, 3) +local setLabel = true +local setBoot = true +local askReboot = true + +for _, arg in ipairs(args) do + if arg:match("^--name=") then + name = arg:match("=(.+)") or "OpenOS" + elseif arg:match("^--from=") then + origin = arg:match("=(.+)") and arg:match("=(.+)"):sub(1, 3) or computer.getBootAddress():sub(1, 3) + elseif arg:match("^--nolabelset") then + setLabel = false + elseif arg:match("^--noboot") then + setBoot = false + elseif arg:match("^--noreboot") then + askReboot = false + end +end + local candidates = {} for address in component.list("filesystem") do local dev = component.proxy(address) @@ -44,21 +67,22 @@ while not choice do end candidates = nil -print("Installing OpenOS to device " .. (choice.getLabel() or choice.address)) +print("Installing " .. name .." to device " .. (choice.getLabel() or choice.address)) os.sleep(0.25) -local boot = computer.getBootAddress():sub(1, 3) local mnt = choice.address:sub(1, 3) -local result, reason = os.execute("/bin/cp -vr /mnt/" .. boot .. "/* /mnt/" .. mnt .. "/") +local result, reason = os.execute("/bin/cp -vr /mnt/" .. origin .. "/* /mnt/" .. mnt .. "/") if not result then error(reason, 0) end -choice.setLabel("OpenOS") +if setLabel then choice.setLabel(name) end -print("All done! Set as boot device and reboot now? [Y/n]") -local result = io.read() -if not result or result == "" or result:sub(1, 1):lower() == "y" then - computer.setBootAddress(choice.address) - print("\nRebooting now!") - computer.shutdown(true) +if askReboot then + print("All done! " .. (setBoot and "Set as boot device and r" or "R") .. "eboot now? [Y/n]") + local result = io.read() + if not result or result == "" or result:sub(1, 1):lower() == "y" then + if setBoot then computer.setBootAddress(choice.address)end + print("\nRebooting now!") + computer.shutdown(true) + end end -print("Returning to shell.") \ No newline at end of file +print("Returning to shell.")