From 186f307d1a299e7cc9d60aa1783e6bb2579e81ac Mon Sep 17 00:00:00 2001 From: mack-a <57424792+mack-a@users.noreply.github.com> Date: Thu, 27 Jul 2023 13:52:27 +0800 Subject: [PATCH] =?UTF-8?q?feat(=E8=84=9A=E6=9C=AC):=20=E4=BF=AE=E6=94=B9?= =?UTF-8?q?=E4=BD=BF=E7=94=A8aapanel=E5=BC=82=E5=B8=B8=E6=8A=A5=E9=94=99?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E3=80=81=E4=BF=AE=E6=94=B9iptables=E6=97=A0?= =?UTF-8?q?=E6=B3=95=E5=85=81=E8=AE=B8UDP=E9=80=9A=E8=A1=8C=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- install.sh | 86 +++++++++++++++++++++++++++++------------------------- 1 file changed, 46 insertions(+), 40 deletions(-) diff --git a/install.sh b/install.sh index 88fc1d0..ca81c5e 100644 --- a/install.sh +++ b/install.sh @@ -406,30 +406,35 @@ checkBTPanel() { if [[ -n $(pgrep -f "BT-Panel") ]]; then # 读取域名 if [[ -d '/www/server/panel/vhost/cert/' && -n $(find /www/server/panel/vhost/cert/*/fullchain.pem) ]]; then + if [[ -z "${currentHost}" ]]; then + echoContent skyBlue "\n读取宝塔配置\n" - echoContent skyBlue "\n读取宝塔配置\n" + find /www/server/panel/vhost/cert/*/fullchain.pem | awk -F "[/]" '{print $7}' | awk '{print NR""":"$0}' - find /www/server/panel/vhost/cert/*/fullchain.pem | awk -F "[/]" '{print $7}' | awk '{print NR""":"$0}' + read -r -p "请输入编号选择:" selectBTDomain + else + selectBTDomain=$(find /www/server/panel/vhost/cert/*/fullchain.pem | awk -F "[/]" '{print $7}' | awk '{print NR""":"$0}' | grep "${currentHost}" | cut -d ":" -f 1) + fi - read -r -p "请输入编号选择:" selectBTDomain if [[ -n "${selectBTDomain}" ]]; then btDomain=$(find /www/server/panel/vhost/cert/*/fullchain.pem | awk -F "[/]" '{print $7}' | awk '{print NR""":"$0}' | grep "${selectBTDomain}:" | cut -d ":" -f 2) + if [[ -z "${btDomain}" ]]; then echoContent red " ---> 选择错误,请重新选择" checkBTPanel else domain=${btDomain} - ln -s "/www/server/panel/vhost/cert/${btDomain}/fullchain.pem" "/etc/v2ray-agent/tls/${btDomain}.crt" - ln -s "/www/server/panel/vhost/cert/${btDomain}/privkey.pem" "/etc/v2ray-agent/tls/${btDomain}.key" + if [[ ! -f "/etc/v2ray-agent/tls/${btDomain}.crt" && ! -f "/etc/v2ray-agent/tls/${btDomain}.key" ]]; then + ln -s "/www/server/panel/vhost/cert/${btDomain}/fullchain.pem" "/etc/v2ray-agent/tls/${btDomain}.crt" + ln -s "/www/server/panel/vhost/cert/${btDomain}/privkey.pem" "/etc/v2ray-agent/tls/${btDomain}.key" + fi nginxStaticPath="/www/wwwroot/${btDomain}/" if [[ -f "/www/wwwroot/${btDomain}/.user.ini" ]]; then chattr -i "/www/wwwroot/${btDomain}/.user.ini" fi - nginxConfigPath="/www/server/panel/vhost/nginx/" fi - else echoContent red " ---> 选择错误,请重新选择" checkBTPanel @@ -457,9 +462,9 @@ allowPort() { # 如果防火墙启动状态则添加相应的开放端口 if systemctl status netfilter-persistent 2>/dev/null | grep -q "active (exited)"; then local updateFirewalldStatus= - if ! iptables -L | grep -q "$1(mack-a)"; then + if ! iptables -L | grep -q "$1/${type}(mack-a)"; then updateFirewalldStatus=true - iptables -I INPUT -p ${type} --dport "$1" -m comment --comment "allow $1(mack-a)" -j ACCEPT + iptables -I INPUT -p ${type} --dport "$1" -m comment --comment "allow $1/${type}(mack-a)" -j ACCEPT fi if echo "${updateFirewalldStatus}" | grep -q "true"; then @@ -539,7 +544,7 @@ readHysteriaConfig() { # 读取Tuic配置 readTuicConfig() { if [[ -n "${tuicConfigPath}" ]]; then - tuicPort=$(jq -r .server <"${tuicConfigPath}config.json" | awk -F "[\]][:]" '{print $2}') + tuicPort=$(jq -r .server <"${tuicConfigPath}config.json" | cut -d ':' -f 4) tuicAlgorithm=$(jq -r .congestion_control <"${tuicConfigPath}config.json") fi } @@ -567,34 +572,6 @@ readConfigHostPathUUID() { currentHost= currentPort= currentAdd= - # 读取path - if [[ -n "${configPath}" && -n "${frontingType}" ]]; then - local fallback - fallback=$(jq -r -c '.inbounds[0].settings.fallbacks[]|select(.path)' ${configPath}${frontingType}.json | head -1) - - local path - path=$(echo "${fallback}" | jq -r .path | awk -F "[/]" '{print $2}') - - if [[ $(echo "${fallback}" | jq -r .dest) == 31297 ]]; then - currentPath=$(echo "${path}" | awk -F "[w][s]" '{print $1}') - elif [[ $(echo "${fallback}" | jq -r .dest) == 31299 ]]; then - currentPath=$(echo "${path}" | awk -F "[v][w][s]" '{print $1}') - fi - - # 尝试读取alpn h2 Path - if [[ -z "${currentPath}" ]]; then - dest=$(jq -r -c '.inbounds[0].settings.fallbacks[]|select(.alpn)|.dest' ${configPath}${frontingType}.json | head -1) - if [[ "${dest}" == "31302" || "${dest}" == "31304" ]]; then - - if grep -q "trojangrpc {" <${nginxConfigPath}alone.conf; then - currentPath=$(grep "trojangrpc {" <${nginxConfigPath}alone.conf | awk -F "[/]" '{print $2}' | awk -F "[t][r][o][j][a][n]" '{print $1}') - elif grep -q "grpc {" <${nginxConfigPath}alone.conf; then - currentPath=$(grep "grpc {" <${nginxConfigPath}alone.conf | head -1 | awk -F "[/]" '{print $2}' | awk -F "[g][r][p][c]" '{print $1}') - fi - fi - fi - - fi if [[ "${coreInstallType}" == "1" ]]; then @@ -636,6 +613,35 @@ readConfigHostPathUUID() { currentUUID=$(jq -r .inbounds[0].settings.clients[0].id ${configPath}${frontingType}.json) currentPort=$(jq .inbounds[0].port ${configPath}${frontingType}.json) fi + + # 读取path + if [[ -n "${configPath}" && -n "${frontingType}" ]]; then + local fallback + fallback=$(jq -r -c '.inbounds[0].settings.fallbacks[]|select(.path)' ${configPath}${frontingType}.json | head -1) + + local path + path=$(echo "${fallback}" | jq -r .path | awk -F "[/]" '{print $2}') + + if [[ $(echo "${fallback}" | jq -r .dest) == 31297 ]]; then + currentPath=$(echo "${path}" | awk -F "[w][s]" '{print $1}') + elif [[ $(echo "${fallback}" | jq -r .dest) == 31299 ]]; then + currentPath=$(echo "${path}" | awk -F "[v][w][s]" '{print $1}') + fi + + # 尝试读取alpn h2 Path + if [[ -z "${currentPath}" ]]; then + dest=$(jq -r -c '.inbounds[0].settings.fallbacks[]|select(.alpn)|.dest' ${configPath}${frontingType}.json | head -1) + if [[ "${dest}" == "31302" || "${dest}" == "31304" ]]; then + checkBTPanel + if grep -q "trojangrpc {" <${nginxConfigPath}alone.conf; then + currentPath=$(grep "trojangrpc {" <${nginxConfigPath}alone.conf | awk -F "[/]" '{print $2}' | awk -F "[t][r][o][j][a][n]" '{print $1}') + elif grep -q "grpc {" <${nginxConfigPath}alone.conf; then + currentPath=$(grep "grpc {" <${nginxConfigPath}alone.conf | head -1 | awk -F "[/]" '{print $2}' | awk -F "[g][r][p][c]" '{print $1}') + fi + fi + fi + + fi } # 状态展示 @@ -7870,7 +7876,7 @@ menu() { cd "$HOME" || exit echoContent red "\n==============================================================" echoContent green "作者:mack-a" - echoContent green "当前版本:v2.10.3" + echoContent green "当前版本:v2.10.4" echoContent green "Github:https://github.com/mack-a/v2ray-agent" echoContent green "描述:八合一共存脚本\c" showInstallStatus @@ -7879,7 +7885,7 @@ menu() { echoContent red " " echoContent green "推广请联系TG:@mackaff\n" echoContent green "VPS选购攻略:https://www.v2ray-agent.com/archives/1679975663984" - echoContent green "RN低价套餐,年付最低10美元:https://www.v2ray-agent.com/archives/racknerdtao-can-zheng-li-nian-fu-10mei-yuan" + echoContent green "年付10美金低价VPS AS4837:https://www.v2ray-agent.com/archives/racknerdtao-can-zheng-li-nian-fu-10mei-yuan" echoContent red "==============================================================" if [[ -n "${coreInstallType}" ]]; then echoContent yellow "1.重新安装"