This commit is contained in:
@@ -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"
|
||||
|
||||
Reference in New Issue
Block a user