From 16681b9f3311be130fbbecbce26f5072eefe4385 Mon Sep 17 00:00:00 2001 From: Colin Walters Date: Tue, 20 Aug 2024 19:39:21 -0400 Subject: [PATCH] cli: Add `switch --apply` No reason not to have this. Closes: https://github.com/containers/bootc/issues/770 Signed-off-by: Colin Walters --- lib/src/cli.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/src/cli.rs b/lib/src/cli.rs index 6d0c2fe1a..ead29c97f 100644 --- a/lib/src/cli.rs +++ b/lib/src/cli.rs @@ -59,6 +59,14 @@ pub(crate) struct SwitchOpts { #[clap(long)] pub(crate) quiet: bool, + /// Restart or reboot into the new target image. + /// + /// Currently, this option always reboots. In the future this command + /// will detect the case where no kernel changes are queued, and perform + /// a userspace-only restart. + #[clap(long)] + pub(crate) apply: bool, + /// The transport; e.g. oci, oci-archive, containers-storage. Defaults to `registry`. #[clap(long, default_value = "registry")] pub(crate) transport: String, @@ -697,6 +705,10 @@ async fn switch(opts: SwitchOpts) -> Result<()> { let stateroot = booted_deployment.osname(); crate::deploy::stage(sysroot, &stateroot, &fetched, &new_spec).await?; + if opts.apply { + crate::reboot::reboot()?; + } + Ok(()) }