diff --git a/config.sh b/config.sh index e7c438d..f6722bd 100755 --- a/config.sh +++ b/config.sh @@ -366,26 +366,54 @@ update_services_yaml() { cp "$SERVICES_YAML" "$backup_file" echo "Created backup of services.yaml at $backup_file" - # Update all href values with the new domain - # Replace any existing domain patterns with the new domain - sed -i "s|href: \"https://code\.[^\"]*\"|href: \"https://code.$new_domain\"|g" "$SERVICES_YAML" - sed -i "s|href: \"https://listmonk\.[^\"]*\"|href: \"https://listmonk.$new_domain\"|g" "$SERVICES_YAML" - sed -i "s|href: \"https://db\.[^\"]*\"|href: \"https://db.$new_domain\"|g" "$SERVICES_YAML" - sed -i "s|href: \"https://map\.[^\"]*\"|href: \"https://map.$new_domain\"|g" "$SERVICES_YAML" - sed -i "s|href: \"https://docs\.[^\"]*\"|href: \"https://docs.$new_domain\"|g" "$SERVICES_YAML" - sed -i "s|href: \"https://n8n\.[^\"]*\"|href: \"https://n8n.$new_domain\"|g" "$SERVICES_YAML" - sed -i "s|href: \"https://git\.[^\"]*\"|href: \"https://git.$new_domain\"|g" "$SERVICES_YAML" - sed -i "s|href: \"https://qr\.[^\"]*\"|href: \"https://qr.$new_domain\"|g" "$SERVICES_YAML" + # Define service name to subdomain mapping + # This approach is URL-agnostic - it doesn't matter what the current URLs are + declare -A service_mappings=( + ["Code Server"]="code.$new_domain" + ["Listmonk"]="listmonk.$new_domain" + ["NocoDB"]="db.$new_domain" + ["Map Server"]="map.$new_domain" + ["Main Site"]="$new_domain" + ["MkDocs (Live)"]="docs.$new_domain" + ["Mini QR"]="qr.$new_domain" + ["n8n"]="n8n.$new_domain" + ["Gitea"]="git.$new_domain" + ) - # Update the main site href (matches pattern without subdomain) - sed -i "s|href: \"https://[a-zA-Z0-9.-]*\.\(org\|com\|net\|edu\)\"|href: \"https://$new_domain\"|g" "$SERVICES_YAML" + # Process each service mapping + for service_name in "${!service_mappings[@]}"; do + local target_url="https://${service_mappings[$service_name]}" + + # Use awk to find and update the href for each specific service + # This finds the service by name and updates its href regardless of current URL + awk -v service="$service_name" -v new_url="$target_url" ' + BEGIN { in_service = 0 } + + # Check if we found the service name + /- [^:]+:/ { + if ($0 ~ ("- " service ":")) { + in_service = 1 + } else { + in_service = 0 + } + } + + # If we are in the target service and find href line, update it + in_service && /href:/ { + gsub(/href: "[^"]*"/, "href: \"" new_url "\"") + } + + # Print the line (modified or not) + { print } + ' "$SERVICES_YAML" > "${SERVICES_YAML}.tmp" + + # Replace the original file with the updated version + mv "${SERVICES_YAML}.tmp" "$SERVICES_YAML" + + echo " ✓ Updated $service_name -> $target_url" + done - # Also update any remaining domain references that might exist - sed -i "s|cmlite\.org|$new_domain|g" "$SERVICES_YAML" - sed -i "s|changeme\.org|$new_domain|g" "$SERVICES_YAML" - sed -i "s|albertademocracytaskforce\.org|$new_domain|g" "$SERVICES_YAML" - - echo "✅ Updated service URLs in services.yaml to use domain: $new_domain" + echo "✅ All service URLs updated to use domain: $new_domain" return 0 } diff --git a/configs/homepage/services.yaml b/configs/homepage/services.yaml index b7cb62c..d30db17 100644 --- a/configs/homepage/services.yaml +++ b/configs/homepage/services.yaml @@ -31,7 +31,7 @@ - Content & Documentation: - Main Site: icon: mdi-web - href: "https://bnkserve.org" + href: "https://cmlite.org" description: CM-lite campaign website container: mkdocs-site-server-changemaker @@ -71,4 +71,4 @@ icon: mdi-git href: "https://git.cmlite.org" description: Git repository hosting - container: gitea_changemaker \ No newline at end of file + container: gitea_changemaker