add confirmation prompt when installing
This commit is contained in:
parent
1cc5dc98d3
commit
ab2defa9e4
|
@ -107,7 +107,7 @@ in
|
|||
client.succeed("${pkgs.coreutils}/bin/install -Dm 600 ${../lib/ssh/privkey} /root/.ssh/id_ed25519")
|
||||
client.wait_until_succeeds("ssh -o StrictHostKeyChecking=accept-new -v root@target hostname")
|
||||
|
||||
client.succeed("clan --debug --flake ${../..} machines install test_install_machine root@target >&2")
|
||||
client.succeed("clan --debug --flake ${../..} machines install --yes test_install_machine root@target >&2")
|
||||
try:
|
||||
target.shutdown()
|
||||
except BrokenPipeError:
|
||||
|
|
|
@ -63,6 +63,7 @@ class InstallOptions:
|
|||
machine: str
|
||||
target_host: str
|
||||
kexec: str | None
|
||||
confirm: bool
|
||||
|
||||
|
||||
def install_command(args: argparse.Namespace) -> None:
|
||||
|
@ -71,10 +72,16 @@ def install_command(args: argparse.Namespace) -> None:
|
|||
machine=args.machine,
|
||||
target_host=args.target_host,
|
||||
kexec=args.kexec,
|
||||
confirm=not args.yes,
|
||||
)
|
||||
machine = Machine(opts.machine, flake=opts.flake)
|
||||
machine.target_host_address = opts.target_host
|
||||
|
||||
if opts.confirm:
|
||||
ask = input(f"Install {machine.name} to {opts.target_host}? [y/N] ")
|
||||
if ask != "y":
|
||||
return
|
||||
|
||||
install_nixos(machine, kexec=opts.kexec)
|
||||
|
||||
|
||||
|
@ -84,6 +91,12 @@ def register_install_parser(parser: argparse.ArgumentParser) -> None:
|
|||
type=str,
|
||||
help="use another kexec tarball to bootstrap NixOS",
|
||||
)
|
||||
parser.add_argument(
|
||||
"--yes",
|
||||
action="store_true",
|
||||
help="do not ask for confirmation",
|
||||
default=False,
|
||||
)
|
||||
parser.add_argument(
|
||||
"machine",
|
||||
type=str,
|
||||
|
|
Loading…
Reference in New Issue
Block a user