Compare commits

..

1 Commits

Author SHA1 Message Date
aki
9ac533865d fix(update-setup): Improve Authelia configuration update logic and replace placeholders
Some checks failed
/ validate-docker-compose (push) Has been cancelled
2025-04-26 20:27:19 +08:00

View File

@ -296,38 +296,36 @@ update_authelia_config() {
existing_notifier="$existing_notifier" \ existing_notifier="$existing_notifier" \
yq e -i '.notifier = strenv(existing_notifier)' "$TEMP_CONFIG" yq e -i '.notifier = strenv(existing_notifier)' "$TEMP_CONFIG"
fi fi
fi fi
# Update domain settings from .env # Update domain settings from .env
echo -e "${BLUE}Applying Tailscale domain settings...${NC}" echo -e "${BLUE}Applying Tailscale domain settings...${NC}"
if command -v yq &> /dev/null; then # Replace placeholder full hostname
# Replace placeholder full hostname yq e -i "walk(if type == \"string\" and . == \"tailscale-nas.your-tailnet.ts.net\" then \"${FULL_HOSTNAME}\" else . end)" "$TEMP_CONFIG"
yq e -i "walk(if type == \"string\" and . == \"tailscale-nas.your-tailnet.ts.net\" then \"${FULL_HOSTNAME}\" else . end)" "$TEMP_CONFIG"
# Replace placeholder tailnet domain # Replace placeholder tailnet domain
yq e -i "walk(if type == \"string\" and . == \"your-tailnet.ts.net\" then \"${TAILNET_DOMAIN}\" else . end)" "$TEMP_CONFIG" yq e -i "walk(if type == \"string\" and . == \"your-tailnet.ts.net\" then \"${TAILNET_DOMAIN}\" else . end)" "$TEMP_CONFIG"
# Move temp file to final location # Move temp file to final location
mv "$TEMP_CONFIG" "$AUTHELIA_CONFIG" mv "$TEMP_CONFIG" "$AUTHELIA_CONFIG"
echo -e "${GREEN}Authelia configuration updated successfully!${NC}" echo -e "${GREEN}Authelia configuration updated successfully!${NC}"
else else
echo -e "${YELLOW}Warning: 'yq' is not installed. Using sed to update configuration.${NC}" echo -e "${YELLOW}Warning: 'yq' is not installed. Using sed to update configuration.${NC}"
echo -e "${YELLOW}This is less reliable and may not preserve all settings.${NC}" echo -e "${YELLOW}This is less reliable and may not preserve all settings.${NC}"
# Create a new file from the example # Create a new file from the example
cp "$AUTHELIA_CONFIG_EXAMPLE" "$AUTHELIA_CONFIG.new" cp "$AUTHELIA_CONFIG_EXAMPLE" "$AUTHELIA_CONFIG.new"
# Replace placeholders manually # Replace placeholders manually
sed -i "s|tailscale-nas\.your-tailnet\.ts\.net|${FULL_HOSTNAME}|g" "$AUTHELIA_CONFIG.new" sed -i "s|tailscale-nas\.your-tailnet\.ts\.net|${FULL_HOSTNAME}|g" "$AUTHELIA_CONFIG.new"
sed -i "s|your-tailnet\.ts\.net|${TAILNET_DOMAIN}|g" "$AUTHELIA_CONFIG.new" sed -i "s|your-tailnet\.ts\.net|${TAILNET_DOMAIN}|g" "$AUTHELIA_CONFIG.new"
# Move the new file to the final location # Move the new file to the final location
mv "$AUTHELIA_CONFIG.new" "$AUTHELIA_CONFIG" mv "$AUTHELIA_CONFIG.new" "$AUTHELIA_CONFIG"
echo -e "${YELLOW}Authelia configuration updated with sed.${NC}" echo -e "${YELLOW}Authelia configuration updated with sed.${NC}"
fi fi
echo -e "${GREEN}Authelia configuration update completed.${NC}" echo -e "${GREEN}Authelia configuration update completed.${NC}"
@ -335,7 +333,6 @@ update_authelia_config() {
echo -e "${CYAN} docker compose restart authelia${NC}" echo -e "${CYAN} docker compose restart authelia${NC}"
} }
################################################## ##################################################
# PART 3: Update service configurations # PART 3: Update service configurations
################################################## ##################################################