From 99de6de84236427d8be6596bbb18cf6545487d3b Mon Sep 17 00:00:00 2001 From: Bram Date: Wed, 22 Oct 2025 21:52:28 +0200 Subject: [PATCH] replace teleport labels --- Dockers/remote-laravel-container/entrypoint.sh | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/Dockers/remote-laravel-container/entrypoint.sh b/Dockers/remote-laravel-container/entrypoint.sh index 590b3e5..cd837b9 100644 --- a/Dockers/remote-laravel-container/entrypoint.sh +++ b/Dockers/remote-laravel-container/entrypoint.sh @@ -103,15 +103,14 @@ add_teleport_labels() { return 1 fi - # Check if labels section already exists under ssh_service - if grep -q " labels:" "$CONFIG_FILE"; then - echo "Labels section already exists, updating..." - # Remove existing labels section - sed -i '/^ labels:/,/^[^ ]/ { /^ labels:/d; /^[^ ]/!d; }' "$CONFIG_FILE" - fi + # Remove any existing labels section + sed -i '/^ labels:/,/^[^[:space:]]/ { /^ labels:/d; /^[^[:space:]]/!d; }' "$CONFIG_FILE" + + # Find the line number of ssh_service and add labels after it + ssh_line=$(grep -n "^ssh_service:" "$CONFIG_FILE" | cut -d: -f1) # Add labels section after ssh_service - sed -i '/^ssh_service:/a\ labels:' "$CONFIG_FILE" + sed -i "${ssh_line}a\\ labels:" "$CONFIG_FILE" # Parse TELEPORT_LABELS and add each label IFS=',' read -ra LABELS <<< "$TELEPORT_LABELS"