Check all published ports before deployment
This commit is contained in:
+8
-3
@@ -90,17 +90,22 @@ command -v ss >/dev/null 2>&1 || die "The 'ss' utility is required (package: ipr
|
||||
command -v curl >/dev/null 2>&1 || die "The 'curl' utility is required. Nothing was changed."
|
||||
command -v getent >/dev/null 2>&1 || die "The 'getent' utility is required (package: libc-bin). Nothing was changed."
|
||||
|
||||
port_busy() { ss -H -ltn "sport = :$1" 2>/dev/null | grep -q .; }
|
||||
tcp_port_busy() { ss -H -ltn "sport = :$1" 2>/dev/null | grep -q .; }
|
||||
udp_port_busy() { ss -H -lun "sport = :$1" 2>/dev/null | grep -q .; }
|
||||
our_stack_running() {
|
||||
command -v docker >/dev/null 2>&1 &&
|
||||
docker ps --filter "label=com.docker.compose.project=$PROJECT_NAME" --format '{{.ID}}' | grep -q .
|
||||
}
|
||||
for port in 80 443; do
|
||||
if port_busy "$port" && ! our_stack_running; then
|
||||
for port in 80 443 3000; do
|
||||
if tcp_port_busy "$port" && ! our_stack_running; then
|
||||
ss -ltnp "sport = :$port" >&2 || true
|
||||
die "TCP port $port is already occupied by another service. Nothing was changed. Integrate with the existing reverse proxy instead of forcing takeover."
|
||||
fi
|
||||
done
|
||||
if udp_port_busy 443 && ! our_stack_running; then
|
||||
ss -lunp 'sport = :443' >&2 || true
|
||||
die "UDP port 443 is already occupied by another service. Nothing was changed."
|
||||
fi
|
||||
|
||||
PUBLIC_IP="$(curl -4fsS --max-time 6 https://api.ipify.org 2>/dev/null || true)"
|
||||
for domain in "$DOH_DOMAIN" "$ADMIN_DOMAIN"; do
|
||||
|
||||
Reference in New Issue
Block a user