From 1ed4f15085052994d0b62eeeff26e6112ab84f1d 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 --- lib/src/cli.rs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/lib/src/cli.rs b/lib/src/cli.rs index 6d0c2fe1..21bc1373 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, conflicts_with = "check")] + 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(()) }