fix: implement actual system reboot via shutdown/systemctl commands
All checks were successful
CI/CD Pipeline / Code Format (push) Successful in 2s
CI/CD Pipeline / Clippy Lints (push) Successful in 40s
CI/CD Pipeline / Unit Tests (push) Successful in 1m27s
CI/CD Pipeline / Security Audit (push) Successful in 4s
CI/CD Pipeline / Build Arch Package (push) Successful in 1m56s
CI/CD Pipeline / Build Debian Package (Ubuntu 22.04) (push) Successful in 2m32s
CI/CD Pipeline / Build Alpine Package (push) Successful in 3m25s
CI/CD Pipeline / Build RPM Package (push) Successful in 3m44s
CI/CD Pipeline / Build Debian Package (push) Successful in 3m0s
All checks were successful
CI/CD Pipeline / Code Format (push) Successful in 2s
CI/CD Pipeline / Clippy Lints (push) Successful in 40s
CI/CD Pipeline / Unit Tests (push) Successful in 1m27s
CI/CD Pipeline / Security Audit (push) Successful in 4s
CI/CD Pipeline / Build Arch Package (push) Successful in 1m56s
CI/CD Pipeline / Build Debian Package (Ubuntu 22.04) (push) Successful in 2m32s
CI/CD Pipeline / Build Alpine Package (push) Successful in 3m25s
CI/CD Pipeline / Build RPM Package (push) Successful in 3m44s
CI/CD Pipeline / Build Debian Package (push) Successful in 3m0s
- Fix reboot_system() to use shutdown -r +N for delayed reboots - Fix patches handler to call reboot_system() instead of just logging - Add CAP_SYS_BOOT capability to systemd service for LXC reboot support - Remove unused warn import from packages/mod.rs - Bump version to 0.3.1
This commit is contained in:
@ -139,7 +139,22 @@ pub async fn apply_patches(
|
||||
),
|
||||
)
|
||||
.await;
|
||||
// In production, would trigger actual reboot via system handler
|
||||
// Trigger actual reboot via system handler
|
||||
match backend_clone.reboot_system(request.reboot_delay_seconds) {
|
||||
Ok(_) => {
|
||||
let _ = job_manager_clone
|
||||
.add_job_log(
|
||||
&job_id_clone,
|
||||
"Reboot command executed".to_string(),
|
||||
)
|
||||
.await;
|
||||
}
|
||||
Err(e) => {
|
||||
let _ = job_manager_clone
|
||||
.add_job_log(&job_id_clone, format!("Reboot failed: {}", e))
|
||||
.await;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
|
||||
@ -6,7 +6,7 @@
|
||||
use anyhow::{Context, Result};
|
||||
use serde::{Deserialize, Serialize};
|
||||
use std::process::Command;
|
||||
use tracing::{info, warn};
|
||||
use tracing::info;
|
||||
|
||||
/// Package status
|
||||
#[derive(Debug, Clone, Serialize, Deserialize, PartialEq)]
|
||||
@ -466,17 +466,27 @@ impl PackageManagerBackend for AptBackend {
|
||||
|
||||
fn reboot_system(&self, delay_seconds: u64) -> Result<()> {
|
||||
if delay_seconds > 0 {
|
||||
info!("Scheduling reboot in {} seconds", delay_seconds);
|
||||
// In production, would use systemd shutdown scheduler
|
||||
warn!("Delayed reboot not fully implemented - would use systemd in production");
|
||||
// Use shutdown command for delayed reboot (converts seconds to minutes, minimum 1)
|
||||
let delay_minutes = std::cmp::max(1u64, delay_seconds.div_ceil(60));
|
||||
info!(
|
||||
"Scheduling system reboot in {} minutes (requested {} seconds)",
|
||||
delay_minutes, delay_seconds
|
||||
);
|
||||
Command::new("shutdown")
|
||||
.args(["-r", &format!("+{}", delay_minutes)])
|
||||
.status()
|
||||
.context("Failed to schedule delayed reboot")?;
|
||||
info!("System reboot scheduled in {} minutes", delay_minutes);
|
||||
} else {
|
||||
// Immediate reboot using systemctl
|
||||
info!("Initiating immediate system reboot");
|
||||
Command::new("systemctl")
|
||||
.arg("reboot")
|
||||
.status()
|
||||
.context("Failed to execute reboot command")?;
|
||||
info!("System reboot initiated");
|
||||
}
|
||||
|
||||
Command::new("systemctl")
|
||||
.arg("reboot")
|
||||
.status()
|
||||
.context("Failed to execute reboot command")?;
|
||||
|
||||
info!("System reboot initiated");
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user