#!/bin/sh # check-ports.sh detects and warns if required ports are already in use # or if they are configured to be the same. # Intended for lightweight Alpine containers (uses busybox netstat). # Define ports from ENV variables, applying defaults PORT_APP=${PORT:-20211} # Prefer explicit GRAPHQL_PORT, fall back to parsed override if present. if [ -n "${APP_CONF_OVERRIDE:-}" ]; then # crude parse: look for GRAPHQL_PORT in JSON-like string PORT_GQL=$(printf '%s' "${APP_CONF_OVERRIDE}" | grep -o 'GRAPHQL_PORT"*[:=]\"*[0-9]\+' | tr -cd '0-9' || true) fi PORT_GQL=${PORT_GQL:-${GRAPHQL_PORT:-20212}} # Check if ports are configured to be the same if [ "${PORT_APP}" -eq "${PORT_GQL}" ]; then cat </dev/null 2>&1; then cat <