#!/bin/bash set -e echo "[$(date)] Starting HAProxy Configurator..." # Create directories if they don't exist mkdir -p /app/config/auth mkdir -p /app/config/ssl mkdir -p /etc/haproxy mkdir -p /var/log/supervisor # Create default auth.cfg if doesn't exist if [ ! -f /app/config/auth/auth.cfg ]; then cat > /app/config/auth/auth.cfg < /app/config/ssl.ini < /etc/haproxy/haproxy.cfg <<'HAPROXYCFG' global log stdout local0 maxconn 4096 defaults log global mode http option httplog option dontlognull timeout connect 5000 timeout client 50000 timeout server 50000 listen stats bind *:8404 stats enable stats uri /stats stats refresh 30s stats show-legends HAPROXYCFG echo "[$(date)] Created default haproxy.cfg" fi # Set proper permissions chmod 600 /app/config/ssl/haproxy-configurator.pem 2>/dev/null || true chmod 644 /app/config/auth/auth.cfg chmod 644 /app/config/ssl.ini chmod 644 /etc/haproxy/haproxy.cfg echo "[$(date)] Configuration ready" echo "[$(date)] Starting supervisord..." # Start supervisord exec /usr/bin/supervisord -c /etc/supervisor/conf.d/supervisord.conf