feat(脚本): 添加xray-core、兼容三个核心的配置文件,实现可互相读取、重构逻辑代码

pull/534/merge
mack-a 2020-11-26 16:43:05 +08:00
parent ca87483f3e
commit 63d0815e96
1 changed files with 182 additions and 165 deletions

View File

@ -48,11 +48,6 @@ initVar(){
# 安装总进度 # 安装总进度
totalProgress=1 totalProgress=1
# UUID
uuid=
uuidDirect=
newUUID=
newDirectUUID=
# 1.xray-core安装 # 1.xray-core安装
# 2.v2ray-core 安装 # 2.v2ray-core 安装
@ -69,8 +64,11 @@ initVar(){
# 选择的个性化安装方式 # 选择的个性化安装方式
selectCustomInstallType= selectCustomInstallType=
# 配置文件的路径 # v2ray-core配置文件的路径
configFilePath= v2rayCoreConfigFilePath=
# xray-core配置文件的路径
xrayCoreConfigFilePath=
# 配置文件的path # 配置文件的path
currentPath= currentPath=
@ -81,11 +79,9 @@ initVar(){
# 安装时选择的core类型 # 安装时选择的core类型
selectCoreType= selectCoreType=
# v2rayCoreInstallStatus
v2rayCoreInstallStatus=
# xrayCoreInstallStatus
xrayCoreInstallStatus=
# 默认core版本 # 默认core版本
v2rayCoreVersion= v2rayCoreVersion=
@ -94,10 +90,20 @@ initVar(){
# centos version # centos version
centosVersion= centosVersion=
# UUID
currentUUID=
currentUUIDDirect=
} }
# 检测安装方式 # 检测安装方式
initInstallType(){ readInstallType(){
coreInstallType=
v2rayAgentInstallType=
xrayCoreConfigFilePath=
v2rayCoreConfigFilePath=
echo 进入readInstallType
# 1.检测安装目录 # 1.检测安装目录
if [[ -d "/etc/v2ray-agent" ]] if [[ -d "/etc/v2ray-agent" ]]
then then
@ -107,7 +113,7 @@ initInstallType(){
if [[ -f "/etc/v2ray-agent/v2ray/config_full.json" ]] if [[ -f "/etc/v2ray-agent/v2ray/config_full.json" ]]
then then
v2rayAgentInstallType=1 v2rayAgentInstallType=1
configFilePath=/etc/v2ray-agent/v2ray/config_full.json v2rayCoreConfigFilePath=/etc/v2ray-agent/v2ray/config_full.json
if [[ ! -z `cat /etc/v2ray-agent/v2ray/config_full.json|grep xtls` ]] if [[ ! -z `cat /etc/v2ray-agent/v2ray/config_full.json|grep xtls` ]]
then then
coreInstallType=3 coreInstallType=3
@ -119,7 +125,7 @@ initInstallType(){
elif [[ -d "/etc/v2ray-agent/v2ray/conf" && -f "/etc/v2ray-agent/v2ray/conf/02_VLESS_TCP_inbounds.json" ]] elif [[ -d "/etc/v2ray-agent/v2ray/conf" && -f "/etc/v2ray-agent/v2ray/conf/02_VLESS_TCP_inbounds.json" ]]
then then
v2rayAgentInstallType=2 v2rayAgentInstallType=2
configFilePath=/etc/v2ray-agent/v2ray/conf/02_VLESS_TCP_inbounds.json v2rayCoreConfigFilePath=/etc/v2ray-agent/v2ray/conf/02_VLESS_TCP_inbounds.json
if [[ ! -z `cat /etc/v2ray-agent/v2ray/conf/02_VLESS_TCP_inbounds.json|grep xtls` ]] if [[ ! -z `cat /etc/v2ray-agent/v2ray/conf/02_VLESS_TCP_inbounds.json|grep xtls` ]]
then then
coreInstallType=3 coreInstallType=3
@ -128,12 +134,14 @@ initInstallType(){
coreInstallType=2 coreInstallType=2
fi fi
fi fi
elif [[ -d "/etc/v2ray-agent/xray" && -f "/etc/v2ray-agent/xray/xray" ]] fi
if [[ -d "/etc/v2ray-agent/xray" && -f "/etc/v2ray-agent/xray/xray" ]]
then then
# 这里检测xray-core # 这里检测xray-core
if [[ -f "/etc/v2ray-agent/xray/config_full.json" ]] if [[ -f "/etc/v2ray-agent/xray/config_full.json" ]]
then then
configFilePath=/etc/v2ray-agent/xray/config_full.json xrayCoreConfigFilePath=/etc/v2ray-agent/xray/config_full.json
v2rayAgentInstallType=1 v2rayAgentInstallType=1
if [[ ! -z `cat /etc/v2ray-agent/xray/config_full.json` ]] if [[ ! -z `cat /etc/v2ray-agent/xray/config_full.json` ]]
then then
@ -142,8 +150,9 @@ initInstallType(){
elif [[ -d "/etc/v2ray-agent/v2ray/conf" && -f "/etc/v2ray-agent/v2ray/conf/02_VLESS_TCP_inbounds.json" ]] elif [[ -d "/etc/v2ray-agent/v2ray/conf" && -f "/etc/v2ray-agent/v2ray/conf/02_VLESS_TCP_inbounds.json" ]]
then then
configFilePath=/etc/v2ray-agent/v2ray/conf/02_VLESS_TCP_inbounds.jso xrayCoreConfigFilePath=/etc/v2ray-agent/xray/conf/02_VLESS_TCP_inbounds.json
v2rayAgentInstallType=2 v2rayAgentInstallType=2
if [[ ! -z `cat /etc/v2ray-agent/xray/conf/02_VLESS_TCP_inbounds.json` ]] if [[ ! -z `cat /etc/v2ray-agent/xray/conf/02_VLESS_TCP_inbounds.json` ]]
then then
coreInstallType=1 coreInstallType=1
@ -154,10 +163,19 @@ initInstallType(){
} }
# 检测个性化安装的方式 # 检测个性化安装的方式
initCustomInstallType(){ readCustomInstallType(){
customConf=
if [[ "${v2rayAgentInstallType}" = "2" ]] if [[ "${v2rayAgentInstallType}" = "2" ]]
then then
# currentCustomInstallType # currentCustomInstallType
local customConf=
if [[ "${coreInstallType}" = "1" ]]
then
customConf=ls /etc/v2ray-agent/xray/conf|grep -v grep|grep inbounds.json|awk -F "[.]" '{print $1}'
else
customConf=ls /etc/v2ray-agent/v2ray/conf|grep -v grep|grep inbounds.json|awk -F "[.]" '{print $1}'
fi
while read row while read row
do do
if [[ ! -z `echo ${row}|grep VLESS_TCP_inbounds` ]] if [[ ! -z `echo ${row}|grep VLESS_TCP_inbounds` ]]
@ -176,45 +194,75 @@ initCustomInstallType(){
then then
currentCustomInstallType=${currentCustomInstallType}'3' currentCustomInstallType=${currentCustomInstallType}'3'
fi fi
done < <(echo `ls /etc/v2ray-agent/v2ray/conf|grep -v grep|grep inbounds.json|awk -F "[.]" '{print $1}'`) done < <(echo ``)
fi fi
} }
# 检查文件目录以及path路径 # 检查文件目录以及path路径
initConfigHostPath(){ readConfigHostPathUUID(){
currentPath=
# path currentUUID=
if [[ ! -z "${configFilePath}" ]] currentUUIDDirect=
currentHost=
# currentPath
if [[ ! -z "${v2rayCoreConfigFilePath}" ]]
then then
local path=`cat ${configFilePath}|jq .inbounds[0].settings.fallbacks|jq -c '.[].path'|awk -F "[\"][/]" '{print $2}'|awk -F "[\"]" '{print $1}'|tail -n +2|head -n 1` local path=`cat ${v2rayCoreConfigFilePath}|jq .inbounds[0].settings.fallbacks|jq -c '.[].path'|awk -F "[\"][/]" '{print $2}'|awk -F "[\"]" '{print $1}'|tail -n +2|head -n 1`
if [[ ! -z "${path}" ]]
then
currentPath=${path:0:4}
fi
elif [[ ! -z "${xrayCoreConfigFilePath}" ]]
then
local path=`cat ${xrayCoreConfigFilePath}|jq .inbounds[0].settings.fallbacks|jq -c '.[].path'|awk -F "[\"][/]" '{print $2}'|awk -F "[\"]" '{print $1}'|tail -n +2|head -n 1`
if [[ ! -z "${path}" ]] if [[ ! -z "${path}" ]]
then then
currentPath=${path:0:4} currentPath=${path:0:4}
fi fi
fi fi
# host # currentHost currentUUID currentUUIDDirect
if [[ "${coreInstallType}" = "2" ]] if [[ "${coreInstallType}" = "1" ]]
then then
currentHost=`cat ${configFilePath}|jq .inbounds[0].streamSettings.tlsSettings.certificates[0].certificateFile|awk -F '[t][l][s][/]' '{print $2}'|awk -F '["]' '{print $1}'|awk -F '[.][c][r][t]' '{print $1}'` currentHost=`cat ${xrayCoreConfigFilePath}|jq .inbounds[0].streamSettings.xtlsSettings.certificates[0].certificateFile|awk -F '[t][l][s][/]' '{print $2}'|awk -F '["]' '{print $1}'|awk -F '[.][c][r][t]' '{print $1}'`
currentUUID=`cat ${xrayCoreConfigFilePath}|jq .inbounds[0].settings.clients[0].id|awk -F '["]' '{print $2}'`
currentUUIDDirect=`cat ${xrayCoreConfigFilePath}|jq .inbounds[0].settings.clients[1].id|awk -F '["]' '{print $2}'`
echo currentUUIDDirect:${currentUUIDDirect}
echo xrayCoreConfigFilePath:${xrayCoreConfigFilePath}
elif [[ "${coreInstallType}" = "2" ]]
then
currentHost=`cat ${v2rayCoreConfigFilePath}|jq .inbounds[0].streamSettings.tlsSettings.certificates[0].certificateFile|awk -F '[t][l][s][/]' '{print $2}'|awk -F '["]' '{print $1}'|awk -F '[.][c][r][t]' '{print $1}'`
currentUUID=`cat ${v2rayCoreConfigFilePath}|jq .inbounds[0].settings.clients[0].id|awk -F '["]' '{print $2}'`
elif [[ "${coreInstallType}" = "3" ]] elif [[ "${coreInstallType}" = "3" ]]
then then
currentHost=`cat ${configFilePath}|jq .inbounds[0].streamSettings.xtlsSettings.certificates[0].certificateFile|awk -F '[t][l][s][/]' '{print $2}'|awk -F '["]' '{print $1}'|awk -F '[.][c][r][t]' '{print $1}'` currentHost=`cat ${v2rayCoreConfigFilePath}|jq .inbounds[0].streamSettings.xtlsSettings.certificates[0].certificateFile|awk -F '[t][l][s][/]' '{print $2}'|awk -F '["]' '{print $1}'|awk -F '[.][c][r][t]' '{print $1}'`
currentUUID=`cat ${v2rayCoreConfigFilePath}|jq .inbounds[0].settings.clients[0].id|awk -F '["]' '{print $2}'`
currentUUIDDirect=`cat ${v2rayCoreConfigFilePath}|jq .inbounds[0].settings.clients[1].id|awk -F '["]' '{print $2}'`
fi fi
} }
# 检查core安装状态 # 清理旧残留
checkCoreStatus(){ cleanUp(){
if [[ -d "/etc/v2ray-agent" && -d "/etc/v2ray-agent/v2ray" ]] && [[ -f "/etc/v2ray-agent/v2ray/v2ray" && -f "/etc/v2ray-agent/v2ray/v2ctl" ]] if [[ "$1" = "v2rayClean" ]]
then then
v2rayCoreInstallStatus=true rm -rf `ls /etc/v2ray-agent/v2ray|egrep -v '(config_full.json|conf)'`
elif [[ -d "/etc/v2ray-agent" && -d "/etc/v2ray-agent/xray" ]] && [[ -f "/etc/v2ray-agent/xray/xray" ]] handleV2Ray stop > /dev/null 2>&1
rm -f /etc/systemd/system/v2ray.service
elif [[ "$1" = "xrayClean" ]]
then then
v2rayCoreInstallStatus=true rm -rf `ls /etc/v2ray-agent/xray|egrep -v '(config_full.json|conf)'`
else handleXray stop > /dev/null 2>&1
v2rayCoreInstallStatus= rm -f /etc/systemd/system/xray.service
elif [[ "$1" = "v2rayDel" ]]
then
rm -rf `ls /etc/v2ray-agent/v2ray/*`
elif [[ "$1" = "xrayDel" ]]
then
rm -rf `ls /etc/v2ray-agent/xray/*`
fi fi
} }
@ -222,14 +270,12 @@ initVar
echo initVar echo initVar
checkSystem checkSystem
echo checkSystem echo checkSystem
initInstallType readInstallType
echo initInstallType echo readInstallType
checkCoreStatus readCustomInstallType
echo checkCoreStatus echo readCustomInstallType
initCustomInstallType readConfigHostPathUUID
echo initCustomInstallType echo readConfigHostPathUUID
initConfigHostPath
echo initConfigHostPath
@ -266,39 +312,6 @@ echoContent(){
esac esac
} }
echoContent red coreInstallType:${coreInstallType}
echoContent red v2rayAgentInstallType:${v2rayAgentInstallType}
# 当前的个性化安装方式
echoContent red currentCustomInstallType:${currentCustomInstallType}
# 选择的个性化安装方式
echoContent red selectCustomInstallType:${selectCustomInstallType}
# 配置文件的路径
echoContent red configFilePath:${configFilePath}
# 配置文件的path
echoContent red currentPath:${currentPath}
# 配置文件的host
echoContent red currentHost:${currentHost}
# 安装时选择的core类型
echoContent red selectCoreType:${selectCoreType}
echoContent red ${v2rayCoreInstallStatus}
echoContent red ${v2rayCoreVersion}
echoContent red ${customPath}
echoContent red ${centosVersion}
# 初始化安装目录 # 初始化安装目录
mkdirTools(){ mkdirTools(){
mkdir -p /etc/v2ray-agent/tls mkdir -p /etc/v2ray-agent/tls
@ -580,14 +593,7 @@ EOF
randomPathFunction(){ randomPathFunction(){
echoContent skyBlue "\n进度 $1/${totalProgress} : 生成随机路径" echoContent skyBlue "\n进度 $1/${totalProgress} : 生成随机路径"
customPath= if [[ ! -z "${currentPath}" ]]
if [[ ! -z "${configFilePath}" ]]
then
path=`cat ${configFilePath}|jq .inbounds[0].settings.fallbacks|jq -c '.[].path'|awk -F "[\"][/]" '{print $2}'|awk -F "[\"]" '{print $1}'|tail -n +2|head -n 1`
customPath=${path:0:4}
fi
if [[ ! -z "${customPath}" ]]
then then
echo echo
read -p "读取到上次安装记录是否使用上次安装时的path路径 [y/n]:" historyPathStatus read -p "读取到上次安装记录是否使用上次安装时的path路径 [y/n]:" historyPathStatus
@ -596,6 +602,7 @@ randomPathFunction(){
if [[ "${historyPathStatus}" = "y" ]] if [[ "${historyPathStatus}" = "y" ]]
then then
customPath=${currentPath}
echoContent green " ---> 使用成功\n" echoContent green " ---> 使用成功\n"
else else
echoContent yellow "请输入自定义路径[例: alone],不需要斜杠,[回车]随机路径" echoContent yellow "请输入自定义路径[例: alone],不需要斜杠,[回车]随机路径"
@ -810,8 +817,7 @@ checkTLStatus(){
# 安装V2Ray、指定版本 # 安装V2Ray、指定版本
installV2Ray(){ installV2Ray(){
checkCoreStatus readInstallType
echoContent red v2rayCoreInstallStatus:${v2rayCoreInstallStatus}
echoContent skyBlue "\n进度 $1/${totalProgress} : 安装V2Ray" echoContent skyBlue "\n进度 $1/${totalProgress} : 安装V2Ray"
# 首先要卸载掉其余途径安装的V2Ray # 首先要卸载掉其余途径安装的V2Ray
if [[ ! -z `ps -ef|grep -v grep|grep v2ray` ]] && [[ -z `ps -ef|grep -v grep|grep v2ray|grep v2ray-agent` ]] if [[ ! -z `ps -ef|grep -v grep|grep v2ray` ]] && [[ -z `ps -ef|grep -v grep|grep v2ray|grep v2ray-agent` ]]
@ -820,7 +826,7 @@ installV2Ray(){
ps -ef|grep -v grep|grep v2ray|awk '{print $2}'|xargs kill -9 > /dev/null 2>&1 ps -ef|grep -v grep|grep v2ray|awk '{print $2}'|xargs kill -9 > /dev/null 2>&1
fi fi
if [[ -z "${v2rayCoreInstallStatus}" ]] if [[ "${coreInstallType}" != "2" && "${coreInstallType}" != "3" ]]
then then
if [[ "${selectCoreType}" = "2" ]] if [[ "${selectCoreType}" = "2" ]]
then then
@ -861,8 +867,7 @@ installV2Ray(){
# 安装xray # 安装xray
installXray(){ installXray(){
checkCoreStatus readInstallType
echoContent red v2rayCoreInstallStatus:${v2rayCoreInstallStatus}
echoContent skyBlue "\n进度 $1/${totalProgress} : 安装Xray" echoContent skyBlue "\n进度 $1/${totalProgress} : 安装Xray"
# 首先要卸载掉其余途径安装的Xray # 首先要卸载掉其余途径安装的Xray
if [[ ! -z `ps -ef|grep -v grep|grep xray` ]] && [[ -z `ps -ef|grep -v grep|grep v2ray|grep v2ray-agent` ]] if [[ ! -z `ps -ef|grep -v grep|grep xray` ]] && [[ -z `ps -ef|grep -v grep|grep v2ray|grep v2ray-agent` ]]
@ -892,7 +897,7 @@ installXray(){
if [[ "${reInstallXrayStatus}" = "y" ]] if [[ "${reInstallXrayStatus}" = "y" ]]
then then
rm -f /etc/v2ray-agent/xray/xray rm -f /etc/v2ray-agent/xray/xray
installV2Ray $1 installXray $1
fi fi
fi fi
} }
@ -964,8 +969,8 @@ v2rayVersionManageMenu(){
# 更新V2Ray # 更新V2Ray
updateV2Ray(){ updateV2Ray(){
checkCoreStatus readInstallType
if [[ -z "${v2rayCoreInstallStatus}" ]] if [[ "${coreInstallType}" = "2" || "${coreInstallType}" = "3" ]]
then then
if [[ ! -z "$1" ]] if [[ ! -z "$1" ]]
then then
@ -1352,30 +1357,19 @@ handleTrojanGo(){
# 初始化V2Ray 配置文件 # 初始化V2Ray 配置文件
initV2RayConfig(){ initV2RayConfig(){
echoContent skyBlue "\n进度 $2/${totalProgress} : 初始化V2Ray配置" echoContent skyBlue "\n进度 $2/${totalProgress} : 初始化V2Ray配置"
if [[ ! -z "${configFilePath}" ]] if [[ ! -z "${currentUUID}" ]]
then then
echo echo
read -p "读取到上次安装记录是否使用上次安装时的UUID [y/n]:" historyUUIDStatus read -p "读取到上次安装记录是否使用上次安装时的UUID [y/n]:" historyUUIDStatus
if [[ "${historyUUIDStatus}" = "y" ]] if [[ "${historyUUIDStatus}" = "y" ]]
then then
if [[ "${v2rayAgentInstallType}" = "1" ]] uuid=${currentUUID}
then uuidDirect=${currentUUIDDirect}
uuid=`cat ${configFilePath}|jq .inbounds[0].settings.clients[0].id|awk -F '["]' '{print $2}'`
elif [[ "${v2rayAgentInstallType}" = "2" ]]
then
uuid=`cat ${configFilePath}|jq .inbounds[0].settings.clients[0].id|awk -F '["]' '{print $2}'`
uuidDirect=`cat ${configFilePath}|jq .inbounds[0].settings.clients[1].id|awk -F '["]' '{print $2}'`
fi fi
else else
uuid=`/etc/v2ray-agent/v2ray/v2ctl uuid` uuid=`/etc/v2ray-agent/v2ray/v2ctl uuid`
uuidDirect=`/etc/v2ray-agent/v2ray/v2ctl uuid` uuidDirect=`/etc/v2ray-agent/v2ray/v2ctl uuid`
fi fi
else
echoContent red '\n ---> 无法读取目录'
exit 0;
fi
echoContent red uuid:${uuid}
echoContent red uuidDirect:${uuidDirect}
if [[ -z "${uuid}" ]] if [[ -z "${uuid}" ]]
then then
echoContent red "\n ---> uuid读取错误重新生成" echoContent red "\n ---> uuid读取错误重新生成"
@ -1974,37 +1968,26 @@ EOF
# 初始化Xray 配置文件 # 初始化Xray 配置文件
initXrayConfig(){ initXrayConfig(){
echoContent skyBlue "\n进度 $2/${totalProgress} : 初始化Xray配置" echoContent skyBlue "\n进度 $2/${totalProgress} : 初始化Xray配置"
if [[ ! -z "${configFilePath}" ]] if [[ ! -z "${currentUUID}" ]]
then then
echo echo
read -p "读取到上次安装记录是否使用上次安装时的UUID [y/n]:" historyUUIDStatus read -p "读取到上次安装记录是否使用上次安装时的UUID [y/n]:" historyUUIDStatus
if [[ "${historyUUIDStatus}" = "y" ]] if [[ "${historyUUIDStatus}" = "y" ]]
then then
if [[ "${v2rayAgentInstallType}" = "1" ]] uuid=${currentUUID}
then uuidDirect=${currentUUIDDirect}
uuid=`cat ${configFilePath}|jq .inbounds[0].settings.clients[0].id|awk -F '["]' '{print $2}'`
elif [[ "${v2rayAgentInstallType}" = "2" ]]
then
uuid=`cat ${configFilePath}|jq .inbounds[0].settings.clients[0].id|awk -F '["]' '{print $2}'`
uuidDirect=`cat ${configFilePath}|jq .inbounds[0].settings.clients[1].id|awk -F '["]' '{print $2}'`
fi fi
else else
uuid=`/etc/v2ray-agent/xray/xray uuid` uuid=`/etc/v2ray-agent/xray/xray uuid`
uuidDirect=`/etc/v2ray-agent/xray/xray uuid` uuidDirect=`/etc/v2ray-agent/xray/xray uuid`
fi fi
else
uuid=`/etc/v2ray-agent/xray/xray uuid`
uuidDirect=`/etc/v2ray-agent/xray/xray uuid`
fi
echoContent red uuid:${uuid}
echoContent red uuidDirect:${uuidDirect}
if [[ -z "${uuid}" ]] if [[ -z "${uuid}" ]]
then then
echoContent red "\n ---> uuid读取错误重新生成" echoContent red "\n ---> uuid读取错误重新生成"
uuid=`/etc/v2ray-agent/xray/xray uuid` uuid=`/etc/v2ray-agent/xray/xray uuid`
fi fi
if [[ -z "${uuidDirect}" ]] && [[ "${selectCoreType}" = "3" ]] if [[ -z "${uuidDirect}" ]] && [[ "${selectCoreType}" = "1" ]]
then then
echoContent red "\n ---> uuid XTLS-direct读取错误重新生成" echoContent red "\n ---> uuid XTLS-direct读取错误重新生成"
uuidDirect=`/etc/v2ray-agent/xray/xray uuid` uuidDirect=`/etc/v2ray-agent/xray/xray uuid`
@ -2026,8 +2009,8 @@ initXrayConfig(){
cat << EOF > /etc/v2ray-agent/xray/config_full.json cat << EOF > /etc/v2ray-agent/xray/config_full.json
{ {
"log": { "log": {
"access": "/etc/v2ray-agent/xray/xray_access.log", "access": "/etc/v2ray-agent/v2ray/v2ray_access.log",
"error": "/etc/v2ray-agent/xray/xray_error.log", "error": "/etc/v2ray-agent/v2ray/v2ray_error.log",
"loglevel": "debug" "loglevel": "debug"
}, },
"inbounds": [ "inbounds": [
@ -2039,7 +2022,13 @@ initXrayConfig(){
{ {
"id": "${uuid}", "id": "${uuid}",
"add": "${add}", "add": "${add}",
"email": "${domain}_VLESS_TLS_TCP" "flow":"xtls-rprx-origin",
"email": "${domain}_VLESS_XTLS/TLS-origin_TCP"
},
{
"id": "${uuidDirect}",
"flow":"xtls-rprx-direct",
"email": "${domain}_VLESS_XTLS/TLS-direct_TCP"
} }
], ],
"decryption": "none", "decryption": "none",
@ -2067,8 +2056,8 @@ initXrayConfig(){
}, },
"streamSettings": { "streamSettings": {
"network": "tcp", "network": "tcp",
"security": "tls", "security": "xtls",
"tlsSettings": { "xtlsSettings": {
"alpn": [ "alpn": [
"http/1.1" "http/1.1"
], ],
@ -2429,8 +2418,6 @@ EOF
fi fi
# 清空v2ray的内容
rm -rf /etc/v2ray-agent/v2ray/*
} }
# 初始化Trojan-Go配置 # 初始化Trojan-Go配置
initTrojanGoConfig(){ initTrojanGoConfig(){
@ -2600,16 +2587,26 @@ defaultBase64Code(){
# 账号 # 账号
showAccounts(){ showAccounts(){
initInstallType readInstallType
readConfigHostPathUUID
showStatus= showStatus=
# local host=
echo v2rayAgentInstallType:${v2rayAgentInstallType} echo v2rayAgentInstallType:${v2rayAgentInstallType}
echoContent skyBlue "\n进度 $1/${totalProgress} : 账号" echoContent skyBlue "\n进度 $1/${totalProgress} : 账号"
if [[ "${v2rayAgentInstallType}" = "1" ]] if [[ "${v2rayAgentInstallType}" = "1" ]]
then then
showStatus=true showStatus=true
local configPath=
if [[ "${coreInstallType}" = "1" ]]
then
configPath=${xrayCoreConfigFilePath}
elif [[ "${coreInstallType}" = "2" || "${coreInstallType}" = "3" ]]
then
configPath=${v2rayCoreConfigFilePath}
fi
# VLESS tcp # VLESS tcp
local tcp=`cat ${configFilePath}|jq .inbounds[0]` local tcp=`cat ${configPath}|jq .inbounds[0]`
local port=`echo ${tcp}|jq .port` local port=`echo ${tcp}|jq .port`
local tcpID=`echo ${tcp}|jq .settings.clients[0].id` local tcpID=`echo ${tcp}|jq .settings.clients[0].id`
local tcpEmail="`echo ${tcp}|jq .settings.clients[0].email|awk -F '["]' '{print $2}'`" local tcpEmail="`echo ${tcp}|jq .settings.clients[0].email|awk -F '["]' '{print $2}'`"
@ -2621,26 +2618,24 @@ showAccounts(){
# VLESS ws # VLESS ws
local vlessWS=`cat ${configFilePath}|jq .inbounds[3]` local vlessWS=`cat ${configPath}|jq .inbounds[3]`
local vlessWSID=`echo ${vlessWS}|jq .settings.clients[0].id` local vlessWSID=`echo ${vlessWS}|jq .settings.clients[0].id`
local vlessWSEmail="`echo ${vlessWS}|jq .settings.clients[0].email|awk -F '["]' '{print $2}'`" local vlessWSEmail="`echo ${vlessWS}|jq .settings.clients[0].email|awk -F '["]' '{print $2}'`"
local vlessWSPath=`echo ${vlessWS}|jq .streamSettings.wsSettings.path` local vlessWSPath=`echo ${vlessWS}|jq .streamSettings.wsSettings.path`
# Vmess ws # Vmess ws
local ws=`cat ${configFilePath}|jq .inbounds[1]` local ws=`cat ${configPath}|jq .inbounds[1]`
local wsID=`echo ${ws}|jq .settings.clients[0].id` local wsID=`echo ${ws}|jq .settings.clients[0].id`
local wsEmail="`echo ${ws}|jq .settings.clients[0].email|awk -F '["]' '{print $2}'`" local wsEmail="`echo ${ws}|jq .settings.clients[0].email|awk -F '["]' '{print $2}'`"
local wsPath=`echo ${ws}|jq .streamSettings.wsSettings.path` local wsPath=`echo ${ws}|jq .streamSettings.wsSettings.path`
# Vmess tcp # Vmess tcp
local vmessTCP=`cat ${configFilePath}|jq .inbounds[2]` local vmessTCP=`cat ${configPath}|jq .inbounds[2]`
local vmessTCPID=`echo ${vmessTCP}|jq .settings.clients[0].id` local vmessTCPID=`echo ${vmessTCP}|jq .settings.clients[0].id`
local vmessTCPEmail="`echo ${vmessTCP}|jq .settings.clients[0].email|awk -F '["]' '{print $2}'`" local vmessTCPEmail="`echo ${vmessTCP}|jq .settings.clients[0].email|awk -F '["]' '{print $2}'`"
local vmessTCPath=`echo ${vmessTCP}|jq .streamSettings.tcpSettings.header.request.path[0]` local vmessTCPath=`echo ${vmessTCP}|jq .streamSettings.tcpSettings.header.request.path[0]`
echoContent red currentHost:${currentHost} if [[ "${coreInstallType}" = "3" || "${coreInstallType}" = "1" ]]
if [[ "${coreInstallType}" = "3" ]]
then then
# host=`echo ${tcp}|jq .streamSettings.xtlsSettings.certificates[0].certificateFile|awk -F '[t][l][s][/]' '{print $2}'|awk -F '["]' '{print $1}'|awk -F '[.][c][r][t]' '{print $1}'`
echoContent skyBlue "\n============================ VLESS TCP TLS/XTLS-origin ===========================" echoContent skyBlue "\n============================ VLESS TCP TLS/XTLS-origin ==========================="
defaultBase64Code vlesstcp ${tcpEmail} "${tcpID}" "${currentHost}:${port}" ${add} defaultBase64Code vlesstcp ${tcpEmail} "${tcpID}" "${currentHost}:${port}" ${add}
@ -2649,7 +2644,6 @@ showAccounts(){
elif [[ "${coreInstallType}" = "2" ]] elif [[ "${coreInstallType}" = "2" ]]
then then
# host=`echo ${tcp}|jq .streamSettings.tlsSettings.certificates[0].certificateFile|awk -F '[t][l][s][/]' '{print $2}'|awk -F '["]' '{print $1}'|awk -F '[.][c][r][t]' '{print $1}'`
echoContent skyBlue "\n============================ VLESS TCP TLS =======================================" echoContent skyBlue "\n============================ VLESS TCP TLS ======================================="
defaultBase64Code vlesstcp ${tcpEmail} "${tcpID}" "${currentHost}:${port}" ${add} defaultBase64Code vlesstcp ${tcpEmail} "${tcpID}" "${currentHost}:${port}" ${add}
fi fi
@ -2665,10 +2659,19 @@ showAccounts(){
elif [[ "${v2rayAgentInstallType}" = "2" ]] elif [[ "${v2rayAgentInstallType}" = "2" ]]
then then
local configPath=
if [[ "${coreInstallType}" = "1" ]]
then
configPath=${xrayCoreConfigFilePath}
elif [[ "${coreInstallType}" = "2" || "${coreInstallType}" = "3" ]]
then
configPath=${v2rayCoreConfigFilePath}
fi
showStatus=true showStatus=true
# VLESS tcp # VLESS tcp
local tcp=`cat /etc/v2ray-agent/v2ray/conf/02_VLESS_TCP_inbounds.json|jq .inbounds[0]` local tcp=`cat ${configPath}|jq .inbounds[0]`
local port=`echo ${tcp}|jq .port` local port=`echo ${tcp}|jq .port`
local tcpID=`echo ${tcp}|jq .settings.clients[0].id` local tcpID=`echo ${tcp}|jq .settings.clients[0].id`
local tcpEmail="`echo ${tcp}|jq .settings.clients[0].email|awk -F '["]' '{print $2}'`" local tcpEmail="`echo ${tcp}|jq .settings.clients[0].email|awk -F '["]' '{print $2}'`"
@ -2680,7 +2683,6 @@ showAccounts(){
if [[ "${coreInstallType}" = "3" ]] if [[ "${coreInstallType}" = "3" ]]
then then
# host=`echo ${tcp}|jq .streamSettings.xtlsSettings.certificates[0].certificateFile|awk -F '[t][l][s][/]' '{print $2}'|awk -F '["]' '{print $1}'|awk -F '[.][c][r][t]' '{print $1}'`
echoContent skyBlue "\n============================ VLESS TCP TLS/XTLS-origin ===========================" echoContent skyBlue "\n============================ VLESS TCP TLS/XTLS-origin ==========================="
defaultBase64Code vlesstcp ${tcpEmail} "${tcpID}" "${currentHost}:${port}" ${add} defaultBase64Code vlesstcp ${tcpEmail} "${tcpID}" "${currentHost}:${port}" ${add}
@ -2696,10 +2698,19 @@ showAccounts(){
if [[ ! -z "${currentCustomInstallType}" ]] if [[ ! -z "${currentCustomInstallType}" ]]
then then
local coreType=
if [[ "${coreInstallType}" = "1" ]]
then
coreType=xray
elif [[ "${coreInstallType}" = "2" || "${coreInstallType}" = "3" ]]
then
coreType=v2ray
fi
if [[ ! -z `echo ${currentCustomInstallType}|grep 1` ]] if [[ ! -z `echo ${currentCustomInstallType}|grep 1` ]]
then then
# VLESS ws # VLESS ws
local vlessWS=`cat /etc/v2ray-agent/v2ray/conf/03_VLESS_WS_inbounds.json|jq .inbounds[0]` local vlessWS=`cat /etc/v2ray-agent/${coreType}/conf/03_VLESS_WS_inbounds.json|jq .inbounds[0]`
local vlessWSID=`echo ${vlessWS}|jq .settings.clients[0].id` local vlessWSID=`echo ${vlessWS}|jq .settings.clients[0].id`
local vlessWSAdd=`echo ${tcp}|jq .settings.clients[0].add|awk -F '["]' '{print $2}'` local vlessWSAdd=`echo ${tcp}|jq .settings.clients[0].add|awk -F '["]' '{print $2}'`
local vlessWSEmail="`echo ${vlessWS}|jq .settings.clients[0].email|awk -F '["]' '{print $2}'`" local vlessWSEmail="`echo ${vlessWS}|jq .settings.clients[0].email|awk -F '["]' '{print $2}'`"
@ -2711,7 +2722,7 @@ showAccounts(){
if [[ ! -z `echo ${currentCustomInstallType}|grep 2` ]] if [[ ! -z `echo ${currentCustomInstallType}|grep 2` ]]
then then
local vmessTCP=`cat /etc/v2ray-agent/v2ray/conf/04_VMess_TCP_inbounds.json|jq .inbounds[0]` local vmessTCP=`cat /etc/v2ray-agent/${coreType}/conf/04_VMess_TCP_inbounds.json|jq .inbounds[0]`
local vmessTCPID=`echo ${vmessTCP}|jq .settings.clients[0].id` local vmessTCPID=`echo ${vmessTCP}|jq .settings.clients[0].id`
local vmessTCPEmail="`echo ${vmessTCP}|jq .settings.clients[0].email|awk -F '["]' '{print $2}'`" local vmessTCPEmail="`echo ${vmessTCP}|jq .settings.clients[0].email|awk -F '["]' '{print $2}'`"
local vmessTCPath=`echo ${vmessTCP}|jq .streamSettings.tcpSettings.header.request.path[0]` local vmessTCPath=`echo ${vmessTCP}|jq .streamSettings.tcpSettings.header.request.path[0]`
@ -2722,7 +2733,7 @@ showAccounts(){
if [[ ! -z `echo ${currentCustomInstallType}|grep 3` ]] if [[ ! -z `echo ${currentCustomInstallType}|grep 3` ]]
then then
local ws=`cat /etc/v2ray-agent/v2ray/conf/05_VMess_WS_inbounds.json|jq .inbounds[0]` local ws=`cat /etc/v2ray-agent/${coreType}/conf/05_VMess_WS_inbounds.json|jq .inbounds[0]`
local wsID=`echo ${ws}|jq .settings.clients[0].id` local wsID=`echo ${ws}|jq .settings.clients[0].id`
local wsEmail="`echo ${ws}|jq .settings.clients[0].email|awk -F '["]' '{print $2}'`" local wsEmail="`echo ${ws}|jq .settings.clients[0].email|awk -F '["]' '{print $2}'`"
local wsPath=`echo ${ws}|jq .streamSettings.wsSettings.path` local wsPath=`echo ${ws}|jq .streamSettings.wsSettings.path`
@ -2801,7 +2812,7 @@ updateV2RayCDN(){
if [[ ! -z "${v2rayAgentInstallType}" ]] if [[ ! -z "${v2rayAgentInstallType}" ]]
then then
local add=`cat ${configFilePath}|grep -v grep|grep add` local add=`cat ${v2rayCoreConfigFilePath}|grep -v grep|grep add`
if [[ ! -z ${add} ]] if [[ ! -z ${add} ]]
then then
echoContent red "==============================================================" echoContent red "=============================================================="
@ -2834,7 +2845,7 @@ updateV2RayCDN(){
sed -i "s/${add}/${setDomain}/g" `grep "${add}" -rl ${configPath}` sed -i "s/${add}/${setDomain}/g" `grep "${add}" -rl ${configPath}`
fi fi
if [[ `cat ${configFilePath}|grep -v grep|grep add|awk -F '["]' '{print $4}'` = ${setDomain} ]] if [[ `cat ${v2rayCoreConfigFilePath}|grep -v grep|grep add|awk -F '["]' '{print $4}'` = ${setDomain} ]]
then then
echoContent green " ---> V2Ray CDN修改成功" echoContent green " ---> V2Ray CDN修改成功"
handleV2Ray stop handleV2Ray stop
@ -2997,9 +3008,9 @@ resetUUID(){
fi fi
if [[ "${resetStatus}" = "true" ]] if [[ "${resetStatus}" = "true" ]]
then then
initInstallType readInstallType
initConfigHostPath readConfigHostPathUUID
initCustomInstallType readCustomInstallType
showAccounts 1 showAccounts 1
fi fi
} }
@ -3160,9 +3171,9 @@ customInstall(){
handleV2Ray start handleV2Ray start
# 生成账号 # 生成账号
checkGFWStatue 15 checkGFWStatue 15
initInstallType readInstallType
initConfigHostPath readConfigHostPathUUID
initCustomInstallType readCustomInstallType
showAccounts 16 showAccounts 16
else else
echoContent red " ---> 输入不合法" echoContent red " ---> 输入不合法"
@ -3211,6 +3222,7 @@ selectCoreInstall(){
# v2ray-core 安装 # v2ray-core 安装
v2rayCoreInstall(){ v2rayCoreInstall(){
cleanUp xrayClean
customInstallType= customInstallType=
totalProgress=17 totalProgress=17
installTools 2 installTools 2
@ -3227,6 +3239,7 @@ v2rayCoreInstall(){
installTrojanService 10 installTrojanService 10
customCDNIP 11 customCDNIP 11
initV2RayConfig all 12 initV2RayConfig all 12
cleanUp xrayDel
initTrojanGoConfig 13 initTrojanGoConfig 13
installCronTLS 14 installCronTLS 14
nginxBlog 15 nginxBlog 15
@ -3239,15 +3252,16 @@ v2rayCoreInstall(){
handleTrojanGo start handleTrojanGo start
# 生成账号 # 生成账号
checkGFWStatue 16 checkGFWStatue 16
initInstallType readInstallType
initConfigHostPath readConfigHostPathUUID
initCustomInstallType readCustomInstallType
showAccounts 17 showAccounts 17
} }
# xray-core 安装 # xray-core 安装
xrayCoreInstall(){ xrayCoreInstall(){
customInstallType= customInstallType=
cleanUp v2rayClean
totalProgress=17 totalProgress=17
installTools 2 installTools 2
@ -3265,6 +3279,7 @@ xrayCoreInstall(){
installTrojanService 10 installTrojanService 10
customCDNIP 11 customCDNIP 11
initXrayConfig all 12 initXrayConfig all 12
cleanUp v2rayDel
initTrojanGoConfig 13 initTrojanGoConfig 13
# installCronTLS 14 # installCronTLS 14
nginxBlog 15 nginxBlog 15
@ -3278,9 +3293,9 @@ xrayCoreInstall(){
handleTrojanGo start handleTrojanGo start
# 生成账号 # 生成账号
checkGFWStatue 16 checkGFWStatue 16
initInstallType readInstallType
initConfigHostPath readConfigHostPathUUID
initCustomInstallType readCustomInstallType
showAccounts 17 showAccounts 17
} }
# 主菜单 # 主菜单
@ -3293,7 +3308,7 @@ menu(){
echoContent green "描述:七合一共存脚本" echoContent green "描述:七合一共存脚本"
echoContent red "==============================================================" echoContent red "=============================================================="
echoContent yellow "1.安装" echoContent yellow "1.安装"
echoContent yellow "2.任意组合安装" echoContent yellow "2.任意组合安装[临时屏蔽]"
echoContent skyBlue "-------------------------工具管理-----------------------------" echoContent skyBlue "-------------------------工具管理-----------------------------"
echoContent yellow "3.查看账号" echoContent yellow "3.查看账号"
echoContent yellow "4.自动排错 [已废弃]" echoContent yellow "4.自动排错 [已废弃]"
@ -3317,7 +3332,9 @@ menu(){
selectCoreInstall selectCoreInstall
;; ;;
2) 2)
selectCoreInstall echoContent red " ---> 暂不开放"
exit 0;
# selectCoreInstall
;; ;;
3) 3)
showAccounts 1 showAccounts 1