diff options
| author | unitexe <unitexe70@gmail.com> | 2025-07-06 10:34:10 -0500 |
|---|---|---|
| committer | unitexe <unitexe70@gmail.com> | 2025-07-06 10:34:10 -0500 |
| commit | eeaaa380eb33edf706886c42ba3443e7b0fa379d (patch) | |
| tree | d9a4c3ebf2384050e2578cf9533348f129ad60e0 /src/main.rs | |
| parent | f3352ee6f39822318649b9d268c80b7434d7757e (diff) | |
Add endpoint to manually start podman-auto-update systemd unit
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 25 |
1 files changed, 24 insertions, 1 deletions
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<DoPodmanAutoUpdateRequest>, + ) -> Result<Response<DoPodmanAutoUpdateResponse>, 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] |
