Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions rust/agama-autoinstall/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@
// To contact SUSE LLC about this file by physical or electronic mail, you may
// find current contact information at www.suse.com.

use std::{process::exit, str::FromStr, time::Duration};
use std::{process::exit, time::Duration};

use agama_autoinstall::{ConfigAutoLoader, ScriptsRunner};
use agama_lib::{auth::AuthToken, http::BaseHTTPClient, manager::ManagerHTTPClient};
use agama_utils::{
api::{status::Stage, FinishMethod},
kernel_cmdline::KernelCmdline,
};
use agama_utils::{api::status::Stage, kernel_cmdline::KernelCmdline};
use anyhow::anyhow;
use tokio::time::sleep;

Expand Down Expand Up @@ -96,12 +93,7 @@ async fn main() -> anyhow::Result<()> {
}
}

let method = args
.get("inst.finish")
.first()
.and_then(|m| FinishMethod::from_str(m).ok())
.unwrap_or_default();
manager_client.finish(method).await?;
manager_client.finish(None).await?;

Ok(())
}
5 changes: 3 additions & 2 deletions rust/agama-cli/src/commands.rs
Original file line number Diff line number Diff line change
Expand Up @@ -111,12 +111,13 @@ pub enum Commands {
///
/// stop - do not reboot and the Agama backend continues running.
///
/// reboot - reboot into the installed system.
/// reboot - reboot into the installed system. This value is the
/// default. It can be overriden by setting the inst.finish
/// kernel command-line argument.
///
/// halt - halt the installed machine.
///
/// poweroff - power off the installed machine.
#[clap(default_value = "reboot")]
method: Option<FinishMethod>,
},

Expand Down
3 changes: 1 addition & 2 deletions rust/agama-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ async fn install(http_client: BaseHTTPClient, monitor: MonitorClient) -> anyhow:
async fn finish(
manager: ManagerHTTPClient,
monitor: MonitorClient,
method: FinishMethod,
method: Option<FinishMethod>,
) -> anyhow::Result<()> {
wait_until_idle(monitor.clone()).await?;

Expand Down Expand Up @@ -299,7 +299,6 @@ pub async fn run_command(cli: Cli) -> anyhow::Result<()> {
let (client, monitor) = build_clients(api_url, cli.opts.insecure).await?;
let manager = ManagerHTTPClient::new(client.clone());
let _ = wait_until_idle(monitor.clone()).await;
let method = method.unwrap_or_default();
finish(manager, monitor, method).await?;
}
Commands::Questions(subcommand) => {
Expand Down
2 changes: 1 addition & 1 deletion rust/agama-lib/src/manager/http_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ impl ManagerHTTPClient {
/// Finishes the installation.
///
/// * `method`: halt, reboot, stop or poweroff the system.
pub async fn finish(&self, method: FinishMethod) -> Result<(), ManagerHTTPClientError> {
pub async fn finish(&self, method: Option<FinishMethod>) -> Result<(), ManagerHTTPClientError> {
let action = api::Action::Finish(method);
self.client.post_void("/v2/action", &action).await?;
Ok(())
Expand Down
23 changes: 17 additions & 6 deletions rust/agama-manager/src/service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,17 @@ use agama_utils::{
Action, Config, Event, FinishMethod, Issue, IssueMap, Proposal, Scope, Status, SystemInfo,
},
arch::Arch,
issue, licenses,
issue,
kernel_cmdline::KernelCmdline,
licenses,
products::{self, ProductSpec},
progress, question,
};
use async_trait::async_trait;
use merge::Merge;
use network::NetworkSystemClient;
use serde_json::Value;
use std::{collections::HashMap, process::Command, sync::Arc};
use std::{collections::HashMap, process::Command, str::FromStr, sync::Arc};
use tokio::sync::{broadcast, RwLock};

#[derive(Debug, thiserror::Error)]
Expand Down Expand Up @@ -884,16 +886,26 @@ impl MessageHandler<users::message::CheckPassword> for Service {

/// Implements the finish action.
struct FinishAction {
method: FinishMethod,
method: Option<FinishMethod>,
}

impl FinishAction {
pub fn new(method: FinishMethod) -> Self {
pub fn new(method: Option<FinishMethod>) -> Self {
Self { method }
}

pub fn run(self) {
let option = match self.method {
let method = self.method.unwrap_or_else(|| {
let inst_finish_method = KernelCmdline::parse()
.ok()
.and_then(|a| a.get_last("inst.finish"))
.and_then(|m| FinishMethod::from_str(&m).ok());
inst_finish_method.unwrap_or_default()
});

tracing::info!("Finishing the installation process ({})", method);

let option = match method {
FinishMethod::Halt => Some("-H"),
FinishMethod::Reboot => Some("-r"),
FinishMethod::Poweroff => Some("-P"),
Expand All @@ -904,7 +916,6 @@ impl FinishAction {
if let Some(switch) = option {
command.arg(switch);
} else {
tracing::info!("Stopped as requested");
return;
}

Expand Down
10 changes: 5 additions & 5 deletions rust/agama-utils/src/api/action.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub enum Action {
#[serde(rename = "install")]
Install,
#[serde(rename = "finish")]
Finish(FinishMethod),
Finish(Option<FinishMethod>),
}

/// Finish method
Expand All @@ -58,13 +58,13 @@ pub enum Action {
#[strum(serialize_all = "camelCase")]
#[serde(rename_all = "camelCase")]
pub enum FinishMethod {
// Halt the system
/// Halt the system
Halt,
// Reboots the system
/// Reboots the system
#[default]
Reboot,
// Do nothing at the end of the installation
/// Do nothing at the end of the installation
Stop,
// Poweroff the system
/// Poweroff the system
Poweroff,
}
5 changes: 5 additions & 0 deletions rust/package/agama.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
-------------------------------------------------------------------
Fri Mar 6 10:28:09 UTC 2026 - Imobach Gonzalez Sosa <igonzalezsosa@suse.com>

- Honor inst.finish in interactive installation (jsc#PED-15031).

-------------------------------------------------------------------
Thu Mar 5 15:27:13 UTC 2026 - Imobach Gonzalez Sosa <igonzalezsosa@suse.com>

Expand Down
Loading