#!/usr/bin/env bash

set -Eeuo pipefail

systemctl is-active --quiet haproxy.service
/usr/local/haproxy/sbin/haproxy -c -f /etc/haproxy/haproxy.cfg >/dev/null 2>&1
listeners=$(ss -H -lnt | awk '{print $4}')
for port in 3306 3308 6379 6387; do
    grep -Eq "(^|:)$port$" <<<"$listeners"
done
