diff --git a/src/main/resources/assets/opencomputers/loot/OPPM/oppm.lua b/src/main/resources/assets/opencomputers/loot/OPPM/oppm.lua index 2ce909a23..f83a5b5bc 100644 --- a/src/main/resources/assets/opencomputers/loot/OPPM/oppm.lua +++ b/src/main/resources/assets/opencomputers/loot/OPPM/oppm.lua @@ -480,18 +480,82 @@ local function updatePackage(pack) end end -if args[1] == "list" then - local packs = listPackages(args[2]) - printPackages(packs) -elseif args[1] == "info" then - provideInfo(args[2]) -elseif args[1] == "install" then - installPackage(args[2],args[3],false) -elseif args[1] == "update" then - updatePackage(args[2]) -elseif args[1] == "uninstall" then - uninstallPackage(args[2]) -else - printUsage() +if options.iKnowWhatIAmDoing then + if args[1] == "list" then + local packs = listPackages(args[2]) + printPackages(packs) + elseif args[1] == "info" then + provideInfo(args[2]) + elseif args[1] == "install" then + installPackage(args[2],args[3],false) + elseif args[1] == "update" then + updatePackage(args[2]) + elseif args[1] == "uninstall" then + uninstallPackage(args[2]) + else + printUsage() + return + end return end + +--Very much not stolen from Sangar's install.lua + +local computer = require("computer") +local unicode = require("unicode") + +local candidates = {} +for address in component.list("filesystem") do + local dev = component.proxy(address) + if not dev.isReadOnly() and dev.address ~= computer.tmpAddress() then + table.insert(candidates, dev) + end +end + +if #candidates == 0 then + print("No writable disks found, aborting.") + return +end + +for i = 1, #candidates do + local label = candidates[i].getLabel() + if label then + label = label .. " (" .. candidates[i].address:sub(1, 8) .. "...)" + else + label = candidates[i].address + end + print(i .. ") " .. label) +end + +print("To select the device to install to, please enter a number between 1 and " .. #candidates .. ".") +print("Press 'q' to cancel the installation.") +local choice +while not choice do + result = io.read() + if result:sub(1, 1):lower() == "q" then + return + end + local number = tonumber(result) + if number and number > 0 and number <= #candidates then + choice = candidates[number] + else + print("Invalid input, please try again.") + end +end +candidates = nil + +print("Installing OpenOS to device " .. (choice.getLabel() or choice.address)) +os.sleep(0.25) +local mnt = choice.address:sub(1, 3) +local result, reason = shell.execute("oppm", nil, "install", "-f", "oppm", "/mnt/" .. mnt .. "/usr/", "--iKnowWhatIAmDoing") +if not result then + error(reason, 0) +end + +print("All done! Reboot now? [Y/n]") +local result = io.read() +if not result or result == "" or result:sub(1, 1):lower() == "y" then + print("\nRebooting now!") + computer.shutdown(true) +end +print("Returning to shell.")