From c4b0493fdc25ce0773ab0c2bb2723bc3820f9b73 Mon Sep 17 00:00:00 2001 From: Aaron Dewes Date: Wed, 10 Apr 2024 09:56:33 +0200 Subject: [PATCH] Make initial admin password configurable via env (#311) This is useful for running Stalwart in Docker or packaging it for certain systems --- crates/common/src/manager/boot.rs | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/crates/common/src/manager/boot.rs b/crates/common/src/manager/boot.rs index 60792a27..91aa3973 100644 --- a/crates/common/src/manager/boot.rs +++ b/crates/common/src/manager/boot.rs @@ -293,11 +293,13 @@ fn quickstart(path: impl Into) { } } - let admin_pass = thread_rng() - .sample_iter(Alphanumeric) - .take(10) - .map(char::from) - .collect::(); + let admin_pass = std::env::var("STALWART_INITIAL_ADMIN_PASSWORD").unwrap_or_else(|_| { + thread_rng() + .sample_iter(Alphanumeric) + .take(10) + .map(char::from) + .collect::() + }); std::fs::write( path.join("etc").join("config.toml"),