Check all published ports before deployment

This commit is contained in:
AlexChard
2026-08-29 19:24:53 +04:00
parent d97726aa91
commit 2b373661d6
2 changed files with 10 additions and 5 deletions
+2 -2
View File
@@ -44,7 +44,7 @@ curl -fsSL https://git.chardb.ru/VPS/adguard-doh-installer/raw/branch/main/insta
1. проверяет синтаксис доменов; 1. проверяет синтаксис доменов;
2. проверяет их A-записи и публичный IP VPS; 2. проверяет их A-записи и публичный IP VPS;
3. обнаруживает уже работающий AdGuard Home; 3. обнаруживает уже работающий AdGuard Home;
4. проверяет занятость TCP-портов `80` и `443`; 4. проверяет занятость TCP-портов `80`, `443`, `3000` и UDP-порта `443`;
5. отказывается захватывать чужой Nginx/Caddy/Apache; 5. отказывается захватывать чужой Nginx/Caddy/Apache;
6. не принимает непустую чужую директорию без явного `--adopt-existing`; 6. не принимает непустую чужую директорию без явного `--adopt-existing`;
7. сохраняет резервные копии управляемых файлов при повторном запуске; 7. сохраняет резервные копии управляемых файлов при повторном запуске;
@@ -92,7 +92,7 @@ sudo bash verify.sh
- Debian/Ubuntu для автоматической установки Docker; - Debian/Ubuntu для автоматической установки Docker;
- root/sudo; - root/sudo;
- свободные TCP `80` и `443`; - свободные TCP `80`, `443`, `3000` и UDP `443`;
- домены с A-записями на VPS; - домены с A-записями на VPS;
- существующий reverse proxy намеренно не перенастраивается автоматически. - существующий reverse proxy намеренно не перенастраивается автоматически.
+8 -3
View File
@@ -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 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." 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() { our_stack_running() {
command -v docker >/dev/null 2>&1 && command -v docker >/dev/null 2>&1 &&
docker ps --filter "label=com.docker.compose.project=$PROJECT_NAME" --format '{{.ID}}' | grep -q . docker ps --filter "label=com.docker.compose.project=$PROJECT_NAME" --format '{{.ID}}' | grep -q .
} }
for port in 80 443; do for port in 80 443 3000; do
if port_busy "$port" && ! our_stack_running; then if tcp_port_busy "$port" && ! our_stack_running; then
ss -ltnp "sport = :$port" >&2 || true 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." die "TCP port $port is already occupied by another service. Nothing was changed. Integrate with the existing reverse proxy instead of forcing takeover."
fi fi
done 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)" PUBLIC_IP="$(curl -4fsS --max-time 6 https://api.ipify.org 2>/dev/null || true)"
for domain in "$DOH_DOMAIN" "$ADMIN_DOMAIN"; do for domain in "$DOH_DOMAIN" "$ADMIN_DOMAIN"; do