mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-17 19:25:20 -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 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.")
|
||||
print("Returning to shell.")
|
||||
|
Loading…
x
Reference in New Issue
Block a user