frustrating
Build and Push Docker Images / build-and-push (push) Successful in 24s

This commit is contained in:
2025-10-22 21:56:58 +02:00
parent 99de6de842
commit 5bd6da6a6c
2 changed files with 38 additions and 9 deletions
+37 -8
View File
@@ -92,6 +92,7 @@ CONFIG_FILE="/etc/teleport.yaml"
# Edit the teleport.yaml file to update the nodename
sed -i "s/^ nodename:.*/ nodename: $HOSTNAME/" "$CONFIG_FILE"
# Function to add labels to teleport.yaml
# Function to add labels to teleport.yaml
add_teleport_labels() {
if [ -n "$TELEPORT_LABELS" ]; then
@@ -103,14 +104,12 @@ add_teleport_labels() {
return 1
fi
# Remove any existing labels section
sed -i '/^ labels:/,/^[^[:space:]]/ { /^ labels:/d; /^[^[:space:]]/!d; }' "$CONFIG_FILE"
# Create a backup
cp "$CONFIG_FILE" "$CONFIG_FILE.backup"
# 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_line}a\\ labels:" "$CONFIG_FILE"
# Build the new ssh_service section
NEW_SSH_SECTION="ssh_service:"
NEW_SSH_SECTION="$NEW_SSH_SECTION"$'\n'" labels:"
# Parse TELEPORT_LABELS and add each label
IFS=',' read -ra LABELS <<< "$TELEPORT_LABELS"
@@ -124,7 +123,7 @@ add_teleport_labels() {
value=$(echo "$label" | cut -d':' -f2- | xargs)
if [ -n "$key" ] && [ -n "$value" ]; then
echo " $key: $value" >> "$CONFIG_FILE"
NEW_SSH_SECTION="$NEW_SSH_SECTION"$'\n'" $key: $value"
echo "Added label: $key = $value"
else
echo "Warning: Invalid label format '$label'. Expected format: key:value"
@@ -134,6 +133,36 @@ add_teleport_labels() {
fi
done
NEW_SSH_SECTION="$NEW_SSH_SECTION"$'\n'" enabled: \"yes\""
# Replace the ssh_service section
awk -v new_section="$NEW_SSH_SECTION" '
BEGIN {
in_ssh_service = 0
section_replaced = 0
}
/^ssh_service:/ {
in_ssh_service = 1
if (!section_replaced) {
print new_section
section_replaced = 1
}
next
}
in_ssh_service && /^[a-zA-Z_][a-zA-Z0-9_]*:/ {
in_ssh_service = 0
}
in_ssh_service {
next
}
{
print $0
}
' "$CONFIG_FILE" > "$CONFIG_FILE.tmp"
# Replace the original file
mv "$CONFIG_FILE.tmp" "$CONFIG_FILE"
echo "Teleport labels added successfully"
else
echo "No TELEPORT_LABELS environment variable set, skipping label configuration"
+1 -1
View File
@@ -1 +1 @@
4.0
4.1