From eeaaa380eb33edf706886c42ba3443e7b0fa379d Mon Sep 17 00:00:00 2001 From: unitexe Date: Sun, 6 Jul 2025 10:34:10 -0500 Subject: Add endpoint to manually start podman-auto-update systemd unit --- src/main.rs | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) (limited to 'src') diff --git a/src/main.rs b/src/main.rs index 39c010d..c19bc76 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,11 +1,13 @@ use tonic::{transport::Server, Request, Response, Status}; use skopos::ormos_server::{Ormos, OrmosServer}; -use skopos::{ListUsbDevicesRequest, ListUsbDevicesResponse, UsbDevice, MountUsbDeviceRequest, MountUsbDeviceResponse, UnmountUsbDeviceRequest, UnmountUsbDeviceResponse, ListImageArchivesRequest, ListImageArchivesResponse, ImageArchive, LoadImageArchiveRequest, LoadImageArchiveResponse, InspectImageArchiveRequest, InspectImageArchiveResponse}; +use skopos::{ListUsbDevicesRequest, ListUsbDevicesResponse, UsbDevice, MountUsbDeviceRequest, MountUsbDeviceResponse, UnmountUsbDeviceRequest, UnmountUsbDeviceResponse, ListImageArchivesRequest, ListImageArchivesResponse, ImageArchive, LoadImageArchiveRequest, LoadImageArchiveResponse, InspectImageArchiveRequest, InspectImageArchiveResponse, DoPodmanAutoUpdateRequest, DoPodmanAutoUpdateResponse}; use std::io; use std::fs; use std::process::Command; use std::path::Path; use sha2::{Sha256, Digest}; +use zbus_systemd::systemd1::ManagerProxy; +use zbus::Connection; pub mod skopos { tonic::include_proto!("unit.containers.v0"); @@ -366,6 +368,27 @@ impl Ormos for MyOrmos { } } } + + async fn do_podman_auto_update( + &self, + _request: Request, + ) -> Result, Status> { + let connection = Connection::system().await + .map_err(|e| Status::internal(format!("Failed to connect to system bus: {}", e)))?; + + let manager = ManagerProxy::new(&connection).await + .map_err(|e| Status::internal(format!("Failed to create manager proxy: {}", e)))?; + + let _job_path = manager + .start_unit("podman-auto-update.service".to_string(), "replace".to_string()) + .await + .map_err(|e| Status::internal(format!("Failed to start podman-auto-update service: {}", e)))?; + + let response = DoPodmanAutoUpdateResponse { + is_success: true, + }; + Ok(Response::new(response)) + } } #[tokio::main] -- cgit v1.2.3