feat(脚本): 兼容宝塔

pull/534/merge
mack-a 2021-11-10 14:21:05 +08:00
parent 10cfccb31f
commit d34ce87d86
1 changed files with 49 additions and 23 deletions

View File

@ -181,6 +181,12 @@ initVar() {
# tls安装失败后尝试的次数 # tls安装失败后尝试的次数
installTLSCount= installTLSCount=
# BTPanel状态
BTPanelStatus=
# nginx配置文件路径
nginxConfigPath=${nginxConfigPath}
} }
# 检测安装方式 # 检测安装方式
@ -250,6 +256,13 @@ readInstallProtocolType() {
done < <(find ${configPath} -name "*inbounds.json" | awk -F "[.]" '{print $1}') done < <(find ${configPath} -name "*inbounds.json" | awk -F "[.]" '{print $1}')
} }
# 检查是否安装宝塔
checkBTPanel() {
if pgrep -f "BT-Panel"; then
nginxConfigPath=/www/server/panel/vhost/nginx/
BTPanelStatus=true
fi
}
# 读取当前alpn的顺序 # 读取当前alpn的顺序
readInstallAlpn() { readInstallAlpn() {
if [[ -n ${currentInstallProtocolType} ]]; then if [[ -n ${currentInstallProtocolType} ]]; then
@ -476,6 +489,7 @@ readInstallType
readInstallProtocolType readInstallProtocolType
readConfigHostPathUUID readConfigHostPathUUID
readInstallAlpn readInstallAlpn
checkBTPanel
# ------------------------------------------------------------- # -------------------------------------------------------------
@ -747,8 +761,8 @@ initTLSNginxConfig() {
initTLSNginxConfig initTLSNginxConfig
else else
# 修改配置 # 修改配置
touch /etc/nginx/conf.d/alone.conf touch ${nginxConfigPath}alone.conf
cat <<EOF >/etc/nginx/conf.d/alone.conf cat <<EOF >${nginxConfigPath}alone.conf
server { server {
listen 80; listen 80;
listen [::]:80; listen [::]:80;
@ -779,7 +793,18 @@ EOF
# 修改nginx重定向配置 # 修改nginx重定向配置
updateRedirectNginxConf() { updateRedirectNginxConf() {
cat <<EOF >/etc/nginx/conf.d/alone.conf if [[ ${BTPanelStatus} = "true" ]];then
cat <<EOF >${nginxConfigPath}alone.conf
server {
listen 127.0.0.1:31300;
server_name _;
return 403;
}
EOF
else
cat <<EOF >${nginxConfigPath}alone.conf
server { server {
listen 80; listen 80;
listen [::]:80; listen [::]:80;
@ -793,10 +818,11 @@ server {
return 403; return 403;
} }
EOF EOF
fi
if echo "${selectCustomInstallType}" | grep -q 2 && echo "${selectCustomInstallType}" | grep -q 5 || [[ -z "${selectCustomInstallType}" ]]; then if echo "${selectCustomInstallType}" | grep -q 2 && echo "${selectCustomInstallType}" | grep -q 5 || [[ -z "${selectCustomInstallType}" ]]; then
cat <<EOF >>/etc/nginx/conf.d/alone.conf cat <<EOF >>${nginxConfigPath}alone.conf
server { server {
listen 127.0.0.1:31302 http2; listen 127.0.0.1:31302 http2;
server_name ${domain}; server_name ${domain};
@ -832,7 +858,7 @@ server {
} }
EOF EOF
elif echo "${selectCustomInstallType}" | grep -q 5 || [[ -z "${selectCustomInstallType}" ]]; then elif echo "${selectCustomInstallType}" | grep -q 5 || [[ -z "${selectCustomInstallType}" ]]; then
cat <<EOF >>/etc/nginx/conf.d/alone.conf cat <<EOF >>${nginxConfigPath}alone.conf
server { server {
listen 127.0.0.1:31302 http2; listen 127.0.0.1:31302 http2;
server_name ${domain}; server_name ${domain};
@ -857,7 +883,7 @@ EOF
elif echo "${selectCustomInstallType}" | grep -q 2 || [[ -z "${selectCustomInstallType}" ]]; then elif echo "${selectCustomInstallType}" | grep -q 2 || [[ -z "${selectCustomInstallType}" ]]; then
cat <<EOF >>/etc/nginx/conf.d/alone.conf cat <<EOF >>${nginxConfigPath}alone.conf
server { server {
listen 127.0.0.1:31302 http2; listen 127.0.0.1:31302 http2;
server_name ${domain}; server_name ${domain};
@ -881,7 +907,7 @@ server {
EOF EOF
else else
cat <<EOF >>/etc/nginx/conf.d/alone.conf cat <<EOF >>${nginxConfigPath}alone.conf
server { server {
listen 127.0.0.1:31302 http2; listen 127.0.0.1:31302 http2;
server_name ${domain}; server_name ${domain};
@ -896,7 +922,7 @@ server {
EOF EOF
fi fi
cat <<EOF >>/etc/nginx/conf.d/alone.conf cat <<EOF >>${nginxConfigPath}alone.conf
server { server {
listen 127.0.0.1:31300; listen 127.0.0.1:31300;
server_name ${domain}; server_name ${domain};
@ -1001,7 +1027,7 @@ installTLS() {
initNginxConfig() { initNginxConfig() {
echoContent skyBlue "\n进度 $1/${totalProgress} : 配置Nginx" echoContent skyBlue "\n进度 $1/${totalProgress} : 配置Nginx"
cat <<EOF >/etc/nginx/conf.d/alone.conf cat <<EOF >${nginxConfigPath}alone.conf
server { server {
listen 80; listen 80;
listen [::]:80; listen [::]:80;
@ -2848,7 +2874,7 @@ unInstall() {
fi fi
rm -rf /etc/v2ray-agent rm -rf /etc/v2ray-agent
rm -rf /etc/nginx/conf.d/alone.conf rm -rf ${nginxConfigPath}alone.conf
rm -rf /usr/bin/vasma rm -rf /usr/bin/vasma
rm -rf /usr/sbin/vasma rm -rf /usr/sbin/vasma
echoContent green " ---> 卸载快捷方式完成" echoContent green " ---> 卸载快捷方式完成"
@ -4275,7 +4301,7 @@ menu() {
cd "$HOME" || exit cd "$HOME" || exit
echoContent red "\n==============================================================" echoContent red "\n=============================================================="
echoContent green "作者mack-a" echoContent green "作者mack-a"
echoContent green "当前版本v2.5.38" echoContent green "当前版本v2.5.39"
echoContent green "Githubhttps://github.com/mack-a/v2ray-agent" echoContent green "Githubhttps://github.com/mack-a/v2ray-agent"
echoContent green "描述:八合一共存脚本\c" echoContent green "描述:八合一共存脚本\c"
showInstallStatus showInstallStatus