diff --git a/proxmox-acme-api/src/init.rs b/proxmox-acme-api/src/init.rs new file mode 100644 index 00000000..8c55c94a --- /dev/null +++ b/proxmox-acme-api/src/init.rs @@ -0,0 +1,44 @@ +use std::path::{Path, PathBuf}; + +struct AcmeApiConfig { + acme_config_dir: PathBuf, + acme_account_dir: PathBuf, +} + +static mut ACME_ACME_CONFIG: Option = None; + +/// Initialize the global product configuration. +pub fn init>(acme_config_dir: P) { + let acme_config_dir = acme_config_dir.as_ref().to_owned(); + + unsafe { + ACME_ACME_CONFIG = Some(AcmeApiConfig { + acme_account_dir: acme_config_dir.join("accounts"), + acme_config_dir, + }); + } +} + +fn acme_api_config() -> &'static AcmeApiConfig { + unsafe { + ACME_ACME_CONFIG + .as_ref() + .expect("ProxmoxProductConfig is not initialized!") + } +} + +pub(crate) fn acme_config_dir() -> &'static Path { + acme_api_config().acme_config_dir.as_path() +} + +pub(crate) fn acme_account_dir() -> &'static Path { + acme_api_config().acme_account_dir.as_path() +} + +pub(crate) fn plugin_cfg_filename() -> PathBuf { + acme_config_dir().join("plugins.cfg") +} + +pub(crate) fn plugin_cfg_lockfile() -> PathBuf { + acme_config_dir().join("plugins.lck") +} \ No newline at end of file