From e1e8aba4eead6f8216b151719f574131debced8f Mon Sep 17 00:00:00 2001 From: juewuy Date: Fri, 19 Dec 2025 22:21:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B7=B2=E6=B7=BB=E5=8A=A0=20=20=20=20=20=20?= =?UTF-8?q?=20=20scripts/libs/check=5Fport.sh?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- scripts/libs/check_port.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) create mode 100644 scripts/libs/check_port.sh diff --git a/scripts/libs/check_port.sh b/scripts/libs/check_port.sh new file mode 100644 index 00000000..76ca118d --- /dev/null +++ b/scripts/libs/check_port.sh @@ -0,0 +1,17 @@ +#!/bin/sh +# Copyright (C) Juewuy + + +if [ $1 -gt 65535 -o $1 -le 1 ]; then + echo -e "\033[31m输入错误!请输入正确的数值(1-65535)!\033[0m" + exit 1 +elif [ -n "$(echo "|$mix_port|$redir_port|$dns_port|$db_port|" | grep "|$1|")" ]; then + echo -e "\033[31m输入错误!请不要输入重复的端口!\033[0m" + exit 1 +elif [ -n "$(netstat -ntul | grep ":$1 ")" ]; then + echo -e "\033[31m当前端口已被其他进程占用,请重新输入!\033[0m" + exit 1 +else + exit 0 +fi +