fix: handle passwords with special characters in health check

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 <noreply@anthropic.com>
This commit is contained in:
BeauTroll
2025-12-18 02:50:39 +01:00
parent bd1e2dca27
commit 51d42c6437

View File

@@ -131,18 +131,11 @@ echo "▶ Base de données:"
if docker-compose exec -T db mysqladmin ping -h localhost --silent 2>/dev/null; then if docker-compose exec -T db mysqladmin ping -h localhost --silent 2>/dev/null; then
check_ok "MariaDB répond" check_ok "MariaDB répond"
# Charger .env pour tester la connexion # Tester la connexion MySQL (utilise les variables d'environnement du container)
if [ -f .env ]; then 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
set -a check_ok "Connexion MySQL fonctionnelle"
# shellcheck disable=SC1091 else
source .env check_fail "Impossible de se connecter à MySQL"
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
fi fi
else else
check_fail "MariaDB ne répond pas" check_fail "MariaDB ne répond pas"