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
30 changes: 28 additions & 2 deletions rust/agama-autoinstall/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,16 @@
// To contact SUSE LLC about this file by physical or electronic mail, you may
// find current contact information at www.suse.com.

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

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

const API_URL: &str = "http://localhost/api";

Expand Down Expand Up @@ -68,8 +72,30 @@ async fn main() -> anyhow::Result<()> {
}
}

// wait till config is properly set.
loop {
sleep(Duration::from_secs(1)).await;
let status = manager_client.status().await?;
if status.progresses.is_empty() {
break;
}
}

manager_client.install().await?;

// wait till install is done.
loop {
sleep(Duration::from_secs(1)).await;
let status = manager_client.status().await?;
if status.stage == Stage::Finished {
break;
}
if status.stage == Stage::Failed {
eprintln!("Installation failed");
exit(1);
}
}

let method = args
.get("inst.finish")
.first()
Expand Down
2 changes: 0 additions & 2 deletions rust/agama-cli/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ pub enum CliError {
Validation,
#[error("Could not start the installation")]
Installation,
#[error("The installation has not finished correctly")]
NotFinished,
#[error("Could not read the password")]
InteractivePassword(#[source] InquireError),
#[error("Could not read the password from the standard input")]
Expand Down
11 changes: 4 additions & 7 deletions rust/agama-cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ use agama_lib::{
monitor::{Monitor, MonitorClient},
};
use agama_transfer::Transfer;
use agama_utils::api::{self, status::Stage, FinishMethod, IssueWithScope};
use agama_utils::api::{status::Stage, FinishMethod, IssueWithScope};
use anyhow::Context;
use clap::{Args, Parser};
use fluent_uri::UriRef;
Expand Down Expand Up @@ -121,8 +121,8 @@ async fn install(http_client: BaseHTTPClient, monitor: MonitorClient) -> anyhow:
return Err(CliError::Validation)?;
}

let action = api::Action::Install;
http_client.post_void("/v2/action", &action).await?;
let manager = ManagerHTTPClient::new(http_client);
manager.install().await?;

// wait a bit before start monitoring
sleep(Duration::from_secs(1)).await;
Expand All @@ -145,10 +145,7 @@ async fn finish(
) -> anyhow::Result<()> {
wait_until_idle(monitor.clone()).await?;

if !manager.finish(method).await? {
eprintln!("Cannot finish the installation ({method})");
return Err(CliError::NotFinished)?;
}
manager.finish(method).await?;
Ok(())
}

Expand Down
20 changes: 10 additions & 10 deletions rust/agama-lib/src/manager/http_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@
use crate::{
http::{BaseHTTPClient, BaseHTTPClientError},
logs::LogsLists,
manager::InstallerStatus,
};
use agama_utils::api::{self, Status};
use reqwest::header::CONTENT_ENCODING;
use std::path::{Path, PathBuf};
use std::{fs, io::Cursor, os::unix::fs::OpenOptionsExt};
Expand Down Expand Up @@ -61,15 +61,18 @@ impl ManagerHTTPClient {

/// Starts the installation.
pub async fn install(&self) -> Result<(), ManagerHTTPClientError> {
Ok(self.client.post_void("/manager/install", &()).await?)
let action = api::Action::Install;
self.client.post_void("/v2/action", &action).await?;
Ok(())
}

/// Finishes the installation.
///
/// * `method`: halt, reboot, stop or poweroff the system.
pub async fn finish(&self, method: FinishMethod) -> Result<bool, ManagerHTTPClientError> {
let method = Some(method);
Ok(self.client.post("/manager/finish", &method).await?)
pub async fn finish(&self, method: FinishMethod) -> Result<(), ManagerHTTPClientError> {
let action = api::Action::Finish(method);
self.client.post_void("/v2/action", &action).await?;
Ok(())
}

/// Downloads package of logs from the backend
Expand Down Expand Up @@ -123,11 +126,8 @@ impl ManagerHTTPClient {
}

/// Returns the installer status.
pub async fn status(&self) -> Result<InstallerStatus, ManagerHTTPClientError> {
let status = self
.client
.get::<InstallerStatus>("/manager/installer")
.await?;
pub async fn status(&self) -> Result<Status, ManagerHTTPClientError> {
let status = self.client.get::<Status>("/v2/status").await?;
Ok(status)
}
}
7 changes: 7 additions & 0 deletions rust/package/agama.changes
Original file line number Diff line number Diff line change
@@ -1,3 +1,10 @@
-------------------------------------------------------------------
Fri Jan 16 15:01:32 UTC 2026 - Josef Reidinger <jreidinger@suse.com>

- Fix unattended installation
- Add first user to wheel group
- Implement using inst.install_url instead of Product repositories

-------------------------------------------------------------------
Wed Jan 14 23:27:16 UTC 2026 - Imobach Gonzalez Sosa <igonzalezsosa@suse.com>

Expand Down
Loading