]> git.proxmox.com Git - proxmox-backup.git/blobdiff - src/lib.rs
move RRD code into proxmox-rrd crate
[proxmox-backup.git] / src / lib.rs
index 4c5e94b73b06a29bb8dc6058f8be7f8fc76eba37..98b6b98725c63aa169acfbdfb3243c0107078cca 100644 (file)
@@ -1,33 +1,60 @@
-#[macro_use]
-pub mod buildcfg;
+//! See the different modules for documentation on their usage.
+//!
+//! The [backup](backup/index.html) module contains some detailed information
+//! on the inner workings of the backup server regarding data storage.
 
-#[macro_use]
-pub mod tools;
+use std::path::PathBuf;
+
+use proxmox::tools::fs::CreateOptions;
+
+use pbs_buildcfg::configdir;
+use pbs_tools::cert::CertInfo;
+use proxmox_rrd::RRDCache;
 
 #[macro_use]
-pub mod api_schema;
+pub mod tools;
 
 #[macro_use]
 pub mod server;
 
-pub mod pxar;
-
-pub mod section_config;
-
+#[macro_use]
 pub mod backup;
 
 pub mod config;
 
-pub mod storage {
+pub mod api2;
 
-    pub mod config;
-    pub mod futures;
-}
+pub mod auth_helpers;
 
-pub mod cli;
+pub mod auth;
 
-pub mod api2;
+pub mod tape;
 
-pub mod client;
+pub mod acme;
 
-pub mod auth_helpers;
+pub mod client_helpers;
+
+/// Get the server's certificate info (from `proxy.pem`).
+pub fn cert_info() -> Result<CertInfo, anyhow::Error> {
+    CertInfo::from_path(PathBuf::from(configdir!("/proxy.pem")))
+}
+
+lazy_static::lazy_static!{
+    /// Proxmox Backup Server RRD cache instance
+    pub static ref RRD_CACHE: RRDCache = {
+        let backup_user = pbs_config::backup_user().unwrap();
+        let file_options = CreateOptions::new()
+            .owner(backup_user.uid)
+            .group(backup_user.gid);
+
+       let dir_options = CreateOptions::new()
+            .owner(backup_user.uid)
+            .group(backup_user.gid);
+
+        RRDCache::new(
+            "/var/lib/proxmox-backup/rrdb",
+            Some(file_options),
+            Some(dir_options),
+        )
+    };
+}