Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions server_manager/src/core/secrets.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ pub struct Secrets {
pub gitea_db_password: Option<String>,
pub roundcube_db_password: Option<String>,
pub yourls_admin_password: Option<String>,
pub vaultwarden_admin_token: Option<String>,
}

impl Secrets {
Expand Down Expand Up @@ -65,6 +66,10 @@ impl Secrets {
secrets.yourls_admin_password = Some(generate_hex(16)?);
changed = true;
}
if secrets.vaultwarden_admin_token.is_none() {
secrets.vaultwarden_admin_token = Some(generate_hex(16)?);
changed = true;
}

if changed {
info!("Generated new secrets.");
Expand Down
31 changes: 31 additions & 0 deletions server_manager/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -88,13 +88,44 @@ async fn run_install() -> Result<()> {

if status.success() {
info!("Server Manager Stack Deployed Successfully! 🚀");
print_deployment_summary(&secrets);
} else {
error!("Docker Compose failed.");
}

Ok(())
}

fn print_deployment_summary(secrets: &secrets::Secrets) {
println!("\n=================================================================================");
println!(" DEPLOYMENT SUMMARY 🚀");
println!("=================================================================================");
println!("{:<15} | {:<25} | {:<15} | {}", "Service", "URL", "User", "Password / Info");
println!("{:<15} | {:<25} | {:<15} | {}", "-------", "---", "----", "---------------");

let print_row = |service: &str, url: &str, user: &str, pass: &str| {
println!("{:<15} | {:<25} | {:<15} | {}", service, url, user, pass);
};

// Helper to format Option<String>
let pass = |opt: &Option<String>| opt.clone().unwrap_or_else(|| "ERROR".to_string());

print_row("Nginx Proxy", "http://<IP>:81", "admin@example.com", "changeme");
print_row("Portainer", "http://<IP>:9000", "admin", "Set on first login");
print_row("Nextcloud", "https://<IP>:4443", "admin", &pass(&secrets.nextcloud_admin_password));
print_row("Vaultwarden", "http://<IP>:8001/admin", "(Token)", &pass(&secrets.vaultwarden_admin_token));
print_row("Gitea", "http://<IP>:3000", "Register", "DB pre-configured");
print_row("GLPI", "http://<IP>:8088", "glpi", "glpi (Change immediately!)");
print_row("Yourls", "http://<IP>:8003/admin", "admin", &pass(&secrets.yourls_admin_password));
print_row("Roundcube", "http://<IP>:8090", "-", "Login with Mail creds");
print_row("MailServer", "PORTS: 25, 143...", "CLI", "docker exec -ti mailserver setup ...");
print_row("Plex", "http://<IP>:32400/web", "-", "Follow Web Setup");
print_row("ArrStack", "http://<IP>:8989 (Sonarr)", "-", "No auth by default");

println!("=================================================================================\n");
println!("NOTE: Replace <IP> with your server's IP address.");
}

fn run_status() {
let hw = hardware::HardwareInfo::detect();
println!("=== System Status ===");
Expand Down
14 changes: 14 additions & 0 deletions server_manager/src/services/apps.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ impl Service for VaultwardenService {
fn name(&self) -> &'static str { "vaultwarden" }
fn image(&self) -> &'static str { "vaultwarden/server:latest" }
fn ports(&self) -> Vec<String> { vec!["8001:80".to_string()] }
fn env_vars(&self, _hw: &HardwareInfo, secrets: &Secrets) -> HashMap<String, String> {
let mut vars = HashMap::new();
vars.insert("ADMIN_TOKEN".to_string(), secrets.vaultwarden_admin_token.clone().unwrap_or_default());
vars
}
fn volumes(&self, _hw: &HardwareInfo) -> Vec<String> {
vec!["./config/vaultwarden:/data".to_string()]
}
Expand Down Expand Up @@ -64,6 +69,15 @@ impl Service for GiteaService {
fn name(&self) -> &'static str { "gitea" }
fn image(&self) -> &'static str { "gitea/gitea:latest" }
fn ports(&self) -> Vec<String> { vec!["3000:3000".to_string(), "2222:22".to_string()] }
fn env_vars(&self, _hw: &HardwareInfo, secrets: &Secrets) -> HashMap<String, String> {
let mut vars = HashMap::new();
vars.insert("GITEA__database__DB_TYPE".to_string(), "mysql".to_string());
vars.insert("GITEA__database__HOST".to_string(), "mariadb:3306".to_string());
vars.insert("GITEA__database__NAME".to_string(), "gitea".to_string());
vars.insert("GITEA__database__USER".to_string(), "gitea".to_string());
vars.insert("GITEA__database__PASSWD".to_string(), secrets.gitea_db_password.clone().unwrap_or_default());
vars
}
fn volumes(&self, _hw: &HardwareInfo) -> Vec<String> {
vec![
"./config/gitea:/data".to_string(),
Expand Down
1 change: 1 addition & 0 deletions server_manager/tests/integration_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ fn test_generate_compose_structure() {
mailserver_password: Some("mailpass".to_string()),
nextcloud_admin_password: Some("nextcloudadmin".to_string()),
roundcube_db_password: Some("roundcubepass".to_string()),
vaultwarden_admin_token: Some("token".to_string()),
};

// 2. Build Structure
Expand Down
Loading