Make initial admin password configurable via env (#311)

This is useful for running Stalwart in Docker or packaging it for certain systems
This commit is contained in:
Aaron Dewes
2024-04-10 09:56:33 +02:00
committed by GitHub
parent a4e3b1edeb
commit c4b0493fdc

View File

@@ -293,11 +293,13 @@ fn quickstart(path: impl Into<PathBuf>) {
}
}
let admin_pass = thread_rng()
.sample_iter(Alphanumeric)
.take(10)
.map(char::from)
.collect::<String>();
let admin_pass = std::env::var("STALWART_INITIAL_ADMIN_PASSWORD").unwrap_or_else(|_| {
thread_rng()
.sample_iter(Alphanumeric)
.take(10)
.map(char::from)
.collect::<String>()
});
std::fs::write(
path.join("etc").join("config.toml"),