From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id A37336C67B for ; Thu, 23 Sep 2021 12:14:03 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 9912723E2C for ; Thu, 23 Sep 2021 12:13:33 +0200 (CEST) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id 2045723E23 for ; Thu, 23 Sep 2021 12:13:33 +0200 (CEST) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id E01F844A84; Thu, 23 Sep 2021 12:13:32 +0200 (CEST) From: Dietmar Maurer To: pbs-devel@lists.proxmox.com Date: Thu, 23 Sep 2021 12:13:28 +0200 Message-Id: <20210923101329.950146-5-dietmar@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20210923101329.950146-1-dietmar@proxmox.com> References: <20210923101329.950146-1-dietmar@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.583 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pbs-devel] [PATCH proxmox-backup 5/6] proxmox-daily-update: setup worker and command socket X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 23 Sep 2021 10:14:03 -0000 --- src/bin/proxmox-daily-update.rs | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/src/bin/proxmox-daily-update.rs b/src/bin/proxmox-daily-update.rs index 09a768b1..2a04a559 100644 --- a/src/bin/proxmox-daily-update.rs +++ b/src/bin/proxmox-daily-update.rs @@ -1,7 +1,8 @@ use anyhow::Error; -use serde_json::{json, Value}; +use serde_json::json; use proxmox::api::{cli::*, RpcEnvironment, ApiHandler}; +use proxmox::tools::fs::CreateOptions; use proxmox_backup::api2; use proxmox_backup::tools::subscription; @@ -22,7 +23,7 @@ async fn wait_for_local_worker(upid_str: &str) -> Result<(), Error> { /// Daily update async fn do_update( rpcenv: &mut dyn RpcEnvironment, -) -> Result { +) -> Result<(), Error> { let param = json!({}); let method = &api2::node::subscription::API_METHOD_CHECK_SUBSCRIPTION; @@ -59,7 +60,7 @@ async fn do_update( // TODO: cleanup tasks like in PVE? - Ok(Value::Null) + Ok(()) } async fn check_acme_certificates(rpcenv: &mut dyn RpcEnvironment) -> Result<(), Error> { @@ -85,13 +86,25 @@ async fn check_acme_certificates(rpcenv: &mut dyn RpcEnvironment) -> Result<(), Ok(()) } +async fn run(rpcenv: &mut dyn RpcEnvironment) -> Result<(), Error> { + let backup_user = pbs_config::backup_user()?; + let file_opts = CreateOptions::new().owner(backup_user.uid).group(backup_user.gid); + proxmox_rest_server::init_worker_tasks(pbs_buildcfg::PROXMOX_BACKUP_LOG_DIR_M!().into(), file_opts.clone())?; + + let mut commando_sock = proxmox_rest_server::CommandoSocket::new(proxmox_rest_server::our_ctrl_sock(), backup_user.gid); + proxmox_rest_server::register_task_control_commands(&mut commando_sock)?; + commando_sock.spawn()?; + + do_update(rpcenv).await +} + fn main() { proxmox_backup::tools::setup_safe_path_env(); let mut rpcenv = CliEnvironment::new(); rpcenv.set_auth_id(Some(String::from("root@pam"))); - if let Err(err) = pbs_runtime::main(do_update(&mut rpcenv)) { + if let Err(err) = pbs_runtime::main(run(&mut rpcenv)) { eprintln!("error during update: {}", err); std::process::exit(1); } -- 2.30.2