#!/usr/bin/env bash set -euo pipefail F="/opt/hx-ki/com2-stack/docker-compose.yml" [ -f "$F" ] || { echo "FEHLT: $F"; exit 1; } echo "=== PATCH mautic: depends_on mariadb -> hxki-mariadb ===" cp -a "$F" "${F}.bak.$(date +%Y%m%d-%H%M%S)" awk ' function indent(s){ match(s,/^[ ]*/); return RLENGTH } BEGIN{ in_mautic=0; in_dep=0; } { line=$0; ind=indent(line); # Enter/leave mautic service block (2-space key: " mautic:") if (line ~ /^[ ]{2}mautic:[ ]*$/) { in_mautic=1; in_dep=0; print line; next; } if (in_mautic && ind==2 && line ~ /^[ ]{2}[A-Za-z0-9_.-]+:[ ]*$/ && line !~ /^[ ]{2}mautic:[ ]*$/) { in_mautic=0; in_dep=0; } # Enter depends_on inside mautic if (in_mautic && line ~ /^[ ]{4}depends_on:[ ]*$/) { in_dep=1; print line; next; } # Leave depends_on when indentation goes back to 4 or 2 (new key) if (in_dep && ind<=4 && line ~ /^[ ]{4}[A-Za-z0-9_.-]+:/) { in_dep=0; } # Patch mapping-form inside depends_on: " mariadb:" -> " hxki-mariadb:" if (in_dep && line ~ /^[ ]+mariadb:[ ]*$/) { sub(/mariadb:/,"hxki-mariadb:", line); print line; next; } # Patch list-form inside depends_on: " - mariadb" -> " - hxki-mariadb" if (in_dep && line ~ /^[ ]*-[ ]*mariadb[ ]*$/) { sub(/-[ ]*mariadb/,"- hxki-mariadb", line); print line; next; } print line; } ' "$F" > "${F}.tmp" && mv "${F}.tmp" "$F" echo echo "[CHECK] verbleibende depends_on/mariadb Fundstellen:" grep -nE 'depends_on:|^[[:space:]]+mariadb:[[:space:]]*$|-[[:space:]]*mariadb[[:space:]]*$' "$F" || true echo echo "[VALIDATE] docker compose config:" docker compose -f "$F" config >/dev/null echo "OK: Compose ist valide."