mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-18 11:48:02 -04:00
Update install
This commit is contained in:
parent
27df8d2505
commit
12b56461bb
@ -4,6 +4,29 @@ local event = require("event")
|
|||||||
local unicode = require("unicode")
|
local unicode = require("unicode")
|
||||||
local shell = require("shell")
|
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 = {}
|
local candidates = {}
|
||||||
for address in component.list("filesystem") do
|
for address in component.list("filesystem") do
|
||||||
local dev = component.proxy(address)
|
local dev = component.proxy(address)
|
||||||
@ -44,21 +67,22 @@ while not choice do
|
|||||||
end
|
end
|
||||||
candidates = nil
|
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)
|
os.sleep(0.25)
|
||||||
local boot = computer.getBootAddress():sub(1, 3)
|
|
||||||
local mnt = choice.address: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
|
if not result then
|
||||||
error(reason, 0)
|
error(reason, 0)
|
||||||
end
|
end
|
||||||
choice.setLabel("OpenOS")
|
if setLabel then choice.setLabel(name) end
|
||||||
|
|
||||||
print("All done! Set as boot device and reboot now? [Y/n]")
|
if askReboot then
|
||||||
local result = io.read()
|
print("All done! " .. (setBoot and "Set as boot device and r" or "R") .. "eboot now? [Y/n]")
|
||||||
if not result or result == "" or result:sub(1, 1):lower() == "y" then
|
local result = io.read()
|
||||||
computer.setBootAddress(choice.address)
|
if not result or result == "" or result:sub(1, 1):lower() == "y" then
|
||||||
print("\nRebooting now!")
|
if setBoot then computer.setBootAddress(choice.address)end
|
||||||
computer.shutdown(true)
|
print("\nRebooting now!")
|
||||||
|
computer.shutdown(true)
|
||||||
|
end
|
||||||
end
|
end
|
||||||
print("Returning to shell.")
|
print("Returning to shell.")
|
Loading…
x
Reference in New Issue
Block a user