From 51d42c64379c309fa3b58c991b51e7294ef18dc6 Mon Sep 17 00:00:00 2001 From: BeauTroll <-> Date: Thu, 18 Dec 2025 02:50:39 +0100 Subject: [PATCH] fix: handle passwords with special characters in health check MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The health check was failing when MySQL passwords contained special characters like # because it was sourcing .env as a bash script, where # is treated as a comment. Solution: Remove unnecessary .env sourcing and use environment variables directly from the db container, which Docker Compose has already correctly parsed from .env. This fixes the "Impossible de se connecter Ă  MySQL" error when passwords contain #, $, !, or other special characters. Benefits: - Works with any special characters in passwords - Simpler code (removed 4 lines) - More reliable (uses container's environment directly) đŸ¤– Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 --- scripts/check-health.sh | 17 +++++------------ 1 file changed, 5 insertions(+), 12 deletions(-) diff --git a/scripts/check-health.sh b/scripts/check-health.sh index 922514e..0837f1d 100755 --- a/scripts/check-health.sh +++ b/scripts/check-health.sh @@ -131,18 +131,11 @@ echo "â–¶ Base de donnĂ©es:" if docker-compose exec -T db mysqladmin ping -h localhost --silent 2>/dev/null; then check_ok "MariaDB rĂ©pond" - # Charger .env pour tester la connexion - if [ -f .env ]; then - set -a - # shellcheck disable=SC1091 - source .env - set +a - - if docker-compose exec -T db sh -c "MYSQL_PWD=\"\$MYSQL_PASSWORD\" mysql -u\"\$MYSQL_USER\" \"\$MYSQL_DATABASE\" -e 'SELECT 1' >/dev/null 2>&1"; then - check_ok "Connexion MySQL fonctionnelle" - else - check_fail "Impossible de se connecter Ă  MySQL" - fi + # Tester la connexion MySQL (utilise les variables d'environnement du container) + if docker-compose exec -T db sh -c 'MYSQL_PWD="$MYSQL_PASSWORD" mysql -u"$MYSQL_USER" "$MYSQL_DATABASE" -e "SELECT 1"' >/dev/null 2>&1; then + check_ok "Connexion MySQL fonctionnelle" + else + check_fail "Impossible de se connecter Ă  MySQL" fi else check_fail "MariaDB ne rĂ©pond pas"