mirror of https://github.com/mack-a/v2ray-agent
fix(脚本): 修复重置uuid时报错问题
parent
c7d48ac0be
commit
3158d4c5e1
81
install.sh
81
install.sh
|
@ -226,18 +226,12 @@ readConfigHostPathUUID(){
|
||||||
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}'`
|
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}'`
|
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}'`
|
currentUUIDDirect=`cat ${xrayCoreConfigFilePath}|jq .inbounds[0].settings.clients[1].id|awk -F '["]' '{print $2}'`
|
||||||
elif [[ "${coreInstallType}" = "2" ]]
|
elif [[ "${coreInstallType}" = "2" || "${coreInstallType}" = "3" ]]
|
||||||
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" ]]
|
|
||||||
then
|
then
|
||||||
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}'`
|
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}'`
|
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}'`
|
currentUUIDDirect=`cat ${v2rayCoreConfigFilePath}|jq .inbounds[0].settings.clients[1].id|awk -F '["]' '{print $2}'`
|
||||||
fi
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# 清理旧残留
|
# 清理旧残留
|
||||||
|
@ -2851,12 +2845,19 @@ updateV2RayCDN(){
|
||||||
resetUUID(){
|
resetUUID(){
|
||||||
echoContent skyBlue "\n进度 $1/${totalProgress} : 重置UUID"
|
echoContent skyBlue "\n进度 $1/${totalProgress} : 重置UUID"
|
||||||
local resetStatus=false
|
local resetStatus=false
|
||||||
if [[ ! -z "${v2rayAgentInstallType}" ]] && [[ -z "${currentCustomInstallType}" ]]
|
if [[ "${coreInstallType}" = "1" ]]
|
||||||
|
then
|
||||||
|
newUUID=`/etc/v2ray-agent/xray/xray uuid`
|
||||||
|
newDirectUUID=`/etc/v2ray-agent/xray/xray uuid`
|
||||||
|
elif [[ "${coreInstallType}" = "2" || "${coreInstallType}" = "3" ]]
|
||||||
then
|
then
|
||||||
newUUID=`/etc/v2ray-agent/v2ray/v2ctl uuid`
|
newUUID=`/etc/v2ray-agent/v2ray/v2ctl uuid`
|
||||||
newDirectUUID=`/etc/v2ray-agent/v2ray/v2ctl uuid`
|
newDirectUUID=`/etc/v2ray-agent/v2ray/v2ctl uuid`
|
||||||
currentUUID=`cat /etc/v2ray-agent/v2ray/config_full.json|jq .inbounds[0].settings.clients[0].id|awk -F '["]' '{print $2}'`
|
fi
|
||||||
currentDirectUUID=`cat /etc/v2ray-agent/v2ray/config_full.json|jq .inbounds[0].settings.clients[1].id|awk -F '["]' '{print $2}'`
|
|
||||||
|
if [[ ! -z "${v2rayAgentInstallType}" ]] && [[ -z "${currentCustomInstallType}" ]]
|
||||||
|
then
|
||||||
|
|
||||||
if [[ ! -z "${currentUUID}" ]]
|
if [[ ! -z "${currentUUID}" ]]
|
||||||
then
|
then
|
||||||
read -p "是否自定义uuid?[y/n]:" customUUIDStatus
|
read -p "是否自定义uuid?[y/n]:" customUUIDStatus
|
||||||
|
@ -2866,9 +2867,16 @@ resetUUID(){
|
||||||
read -p "请输入合法的uuid:" newUUID
|
read -p "请输入合法的uuid:" newUUID
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
|
if [[ "${coreInstallType}" = "1" ]]
|
||||||
|
then
|
||||||
|
sed -i "s/${currentUUID}/${newUUID}/g" `grep "${currentUUID}" -rl /etc/v2ray-agent/xray/config_full.json`
|
||||||
|
elif [[ "${coreInstallType}" = "2" || "${coreInstallType}" = "3" ]]
|
||||||
|
then
|
||||||
sed -i "s/${currentUUID}/${newUUID}/g" `grep "${currentUUID}" -rl /etc/v2ray-agent/v2ray/config_full.json`
|
sed -i "s/${currentUUID}/${newUUID}/g" `grep "${currentUUID}" -rl /etc/v2ray-agent/v2ray/config_full.json`
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
elif [[ ! -z "${currentDirectUUID}" ]]
|
if [[ ! -z "${currentUUIDDirect}" ]]
|
||||||
then
|
then
|
||||||
echoContent skyBlue "-------------------------------------------------------------"
|
echoContent skyBlue "-------------------------------------------------------------"
|
||||||
read -p "是否自定义 XTLS-direct-uuid?[y/n]:" customUUIDStatus
|
read -p "是否自定义 XTLS-direct-uuid?[y/n]:" customUUIDStatus
|
||||||
|
@ -2884,16 +2892,31 @@ resetUUID(){
|
||||||
exit 0;
|
exit 0;
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
sed -i "s/${currentDirectUUID}/${newDirectUUID}/g" `grep "${currentDirectUUID}" -rl /etc/v2ray-agent/v2ray/config_full.json`
|
if [[ "${coreInstallType}" = "1" ]]
|
||||||
|
then
|
||||||
|
sed -i "s/${currentUUIDDirect}/${newDirectUUID}/g" `grep "${currentUUIDDirect}" -rl /etc/v2ray-agent/xray/config_full.json`
|
||||||
|
elif [[ "${coreInstallType}" = "2" || "${coreInstallType}" = "3" ]]
|
||||||
|
then
|
||||||
|
sed -i "s/${currentUUIDDirect}/${newDirectUUID}/g" `grep "${currentUUIDDirect}" -rl /etc/v2ray-agent/v2ray/config_full.json`
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
fi
|
||||||
|
if [[ "${coreInstallType}" = "1" ]]
|
||||||
|
then
|
||||||
|
echoContent green " ---> Xray UUID重置完毕"
|
||||||
|
handleXray stop
|
||||||
|
handleXray start
|
||||||
|
elif [[ "${coreInstallType}" = "2" || "${coreInstallType}" = "3" ]]
|
||||||
|
then
|
||||||
echoContent green " ---> V2Ray UUID重置完毕"
|
echoContent green " ---> V2Ray UUID重置完毕"
|
||||||
handleV2Ray stop
|
handleV2Ray stop
|
||||||
handleV2Ray start
|
handleV2Ray start
|
||||||
|
fi
|
||||||
|
|
||||||
resetStatus=true
|
resetStatus=true
|
||||||
|
|
||||||
elif [[ ! -z "${v2rayAgentInstallType}" ]] && [[ ! -z "${currentCustomInstallType}" ]]
|
elif [[ ! -z "${v2rayAgentInstallType}" ]] && [[ ! -z "${currentCustomInstallType}" ]]
|
||||||
then
|
then
|
||||||
newUUID=`/etc/v2ray-agent/v2ray/v2ctl uuid`
|
|
||||||
newDirectUUID=`/etc/v2ray-agent/v2ray/v2ctl uuid`
|
|
||||||
read -p "是否自定义uuid?[y/n]:" customUUIDStatus
|
read -p "是否自定义uuid?[y/n]:" customUUIDStatus
|
||||||
if [[ "${customUUIDStatus}" = "y" ]]
|
if [[ "${customUUIDStatus}" = "y" ]]
|
||||||
then
|
then
|
||||||
|
@ -2901,18 +2924,26 @@ resetUUID(){
|
||||||
read -p "请输入合法的uuid:" newUUID
|
read -p "请输入合法的uuid:" newUUID
|
||||||
echo
|
echo
|
||||||
fi
|
fi
|
||||||
|
local configPathType=
|
||||||
|
if [[ "${coreInstallType}" = "1" ]]
|
||||||
|
then
|
||||||
|
configPathType=xray
|
||||||
|
elif [[ "${coreInstallType}" = "2" || "${coreInstallType}" = "3" ]]
|
||||||
|
then
|
||||||
|
configPathType=v2ray
|
||||||
|
fi
|
||||||
|
|
||||||
uuidCount=0
|
uuidCount=0
|
||||||
ls /etc/v2ray-agent/v2ray/conf|grep inbounds|while read row
|
ls /etc/v2ray-agent/${configPathType}/conf|grep inbounds|while read row
|
||||||
do
|
do
|
||||||
cat /etc/v2ray-agent/v2ray/conf/${row}|jq .inbounds|jq -c '.[].settings.clients'|jq -c '.[].id'|while read row2
|
cat /etc/v2ray-agent/${configPathType}/conf/${row}|jq .inbounds|jq -c '.[].settings.clients'|jq -c '.[].id'|while read row2
|
||||||
do
|
do
|
||||||
if [[ "${row}" = "02_VLESS_TCP_inbounds.json" ]]
|
if [[ "${row}" = "02_VLESS_TCP_inbounds.json" ]]
|
||||||
then
|
then
|
||||||
if [[ "${uuidCount}" != "1" ]]
|
if [[ "${uuidCount}" != "1" ]]
|
||||||
then
|
then
|
||||||
oldUUID=`echo ${row2}|awk -F "[\"]" '{print $2}'`
|
oldUUID=`echo ${row2}|awk -F "[\"]" '{print $2}'`
|
||||||
sed -i "s/${oldUUID}/${newUUID}/g" `grep "${oldUUID}" -rl /etc/v2ray-agent/v2ray/conf/${row}`
|
sed -i "s/${oldUUID}/${newUUID}/g" `grep "${oldUUID}" -rl /etc/v2ray-agent/${configPathType}/conf/${row}`
|
||||||
fi
|
fi
|
||||||
if [[ "${row}" = "02_VLESS_TCP_inbounds.json" ]]
|
if [[ "${row}" = "02_VLESS_TCP_inbounds.json" ]]
|
||||||
then
|
then
|
||||||
|
@ -2920,14 +2951,12 @@ resetUUID(){
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
oldUUID=`echo ${row2}|awk -F "[\"]" '{print $2}'`
|
oldUUID=`echo ${row2}|awk -F "[\"]" '{print $2}'`
|
||||||
sed -i "s/${oldUUID}/${newUUID}/g" `grep "${oldUUID}" -rl /etc/v2ray-agent/v2ray/conf/${row}`
|
sed -i "s/${oldUUID}/${newUUID}/g" `grep "${oldUUID}" -rl /etc/v2ray-agent/${configPathType}/conf/${row}`
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
done
|
done
|
||||||
|
|
||||||
currentDirectUUID=`cat /etc/v2ray-agent/v2ray/conf/02_VLESS_TCP_inbounds.json|jq .inbounds|jq -c '.[].settings.clients[1].id'|awk -F "[\"]" '{print $2}'`
|
if [[ ! -z "${currentUUIDDirect}" ]]
|
||||||
if [[ ! -z "${currentDirectUUID}" ]]
|
|
||||||
then
|
then
|
||||||
echoContent skyBlue "-------------------------------------------------------------"
|
echoContent skyBlue "-------------------------------------------------------------"
|
||||||
read -p "是否自定义xtls-direct-uuid?[y/n]:" customUUIDStatus
|
read -p "是否自定义xtls-direct-uuid?[y/n]:" customUUIDStatus
|
||||||
|
@ -2943,12 +2972,20 @@ resetUUID(){
|
||||||
exit 0;
|
exit 0;
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
sed -i "s/${currentDirectUUID}/${newDirectUUID}/g" `grep "${currentDirectUUID}" -rl /etc/v2ray-agent/v2ray/conf/02_VLESS_TCP_inbounds.json`
|
sed -i "s/${currentUUIDDirect}/${newDirectUUID}/g" `grep "${currentUUIDDirect}" -rl /etc/v2ray-agent/${configPathType}/conf/02_VLESS_TCP_inbounds.json`
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ "${coreInstallType}" = "1" ]]
|
||||||
|
then
|
||||||
|
echoContent green " ---> Xray UUID重置完毕"
|
||||||
|
handleXray stop
|
||||||
|
handleXray start
|
||||||
|
elif [[ "${coreInstallType}" = "2" || "${coreInstallType}" = "3" ]]
|
||||||
|
then
|
||||||
echoContent green " ---> V2Ray UUID重置完毕"
|
echoContent green " ---> V2Ray UUID重置完毕"
|
||||||
handleV2Ray stop
|
handleV2Ray stop
|
||||||
handleV2Ray start
|
handleV2Ray start
|
||||||
|
fi
|
||||||
resetStatus=true
|
resetStatus=true
|
||||||
else
|
else
|
||||||
echoContent red " ---> 未使用脚本安装V2Ray"
|
echoContent red " ---> 未使用脚本安装V2Ray"
|
||||||
|
|
Loading…
Reference in New Issue