mirror of https://github.com/mack-a/v2ray-agent
feat(脚本): 增加快捷重新安装(读取上次配置)
parent
f1e2708606
commit
795eb7a8f8
98
install.sh
98
install.sh
|
@ -321,6 +321,9 @@ initVar() {
|
|||
addressWarpReg=
|
||||
secretKeyWarpReg=
|
||||
|
||||
# 上次安装配置状态
|
||||
lastInstallationConfig=
|
||||
|
||||
}
|
||||
|
||||
# 读取tls证书详情
|
||||
|
@ -484,6 +487,7 @@ readInstallProtocolType() {
|
|||
currentInstallProtocolType="${currentInstallProtocolType}7,"
|
||||
if [[ "${coreInstallType}" == "1" ]]; then
|
||||
xrayVLESSRealityServerName=$(jq -r .inbounds[0].streamSettings.realitySettings.serverNames[0] "${row}.json")
|
||||
realityServerName=${xrayVLESSRealityServerName}
|
||||
xrayVLESSRealityPort=$(jq -r .inbounds[0].port "${row}.json")
|
||||
# xrayVLESSRealityPrivateKey=$(jq -r .inbounds[0].streamSettings.realitySettings.privateKey "${row}.json")
|
||||
# xrayVLESSRealityPublicKey=$(jq -r .inbounds[0].streamSettings.realitySettings.publicKey "${row}.json")
|
||||
|
@ -494,6 +498,7 @@ readInstallProtocolType() {
|
|||
frontingTypeReality=07_VLESS_vision_reality_inbounds
|
||||
singBoxVLESSRealityVisionPort=$(jq -r .inbounds[0].listen_port "${row}.json")
|
||||
singBoxVLESSRealityVisionServerName=$(jq -r .inbounds[0].tls.server_name "${row}.json")
|
||||
realityServerName=${singBoxVLESSRealityVisionServerName}
|
||||
if [[ -f "${configPath}reality_key" ]]; then
|
||||
singBoxVLESSRealityPublicKey=$(grep "publicKey" <"${configPath}reality_key" | awk -F "[:]" '{print $2}')
|
||||
|
||||
|
@ -754,6 +759,15 @@ readSingBoxConfig() {
|
|||
fi
|
||||
}
|
||||
|
||||
# 读取上次安装的配置
|
||||
readLastInstallationConfig() {
|
||||
if [[ -n "${configPath}" ]]; then
|
||||
read -r -p "读取到上次安装的配置,是否使用 ?[y/n]:" lastInstallationConfigStatus
|
||||
if [[ "${lastInstallationConfigStatus}" == "y" ]]; then
|
||||
lastInstallationConfig=true
|
||||
fi
|
||||
fi
|
||||
}
|
||||
# 卸载 sing-box
|
||||
unInstallSingBox() {
|
||||
local type=$1
|
||||
|
@ -970,10 +984,10 @@ cleanUp() {
|
|||
initVar "$1"
|
||||
checkSystem
|
||||
checkCPUVendor
|
||||
|
||||
readInstallType
|
||||
readInstallProtocolType
|
||||
readConfigHostPathUUID
|
||||
#readInstallAlpn
|
||||
readCustomPort
|
||||
readSingBoxConfig
|
||||
# -------------------------------------------------------------
|
||||
|
@ -1378,7 +1392,7 @@ EOF
|
|||
initTLSNginxConfig() {
|
||||
handleNginx stop
|
||||
echoContent skyBlue "\n进度 $1/${totalProgress} : 初始化Nginx申请证书配置"
|
||||
if [[ -n "${currentHost}" ]]; then
|
||||
if [[ -n "${currentHost}" && -z "${lastInstallationConfig}" ]]; then
|
||||
echo
|
||||
read -r -p "读取到上次安装记录,是否使用上次安装时的域名 ?[y/n]:" historyDomainStatus
|
||||
if [[ "${historyDomainStatus}" == "y" ]]; then
|
||||
|
@ -1389,6 +1403,8 @@ initTLSNginxConfig() {
|
|||
echoContent yellow "请输入要配置的域名 例: www.v2ray-agent.com --->"
|
||||
read -r -p "域名:" domain
|
||||
fi
|
||||
elif [[ -n "${currentHost}" && -n "${lastInstallationConfig}" ]]; then
|
||||
domain=${currentHost}
|
||||
else
|
||||
echo
|
||||
echoContent yellow "请输入要配置的域名 例: www.v2ray-agent.com --->"
|
||||
|
@ -1808,11 +1824,15 @@ customPortFunction() {
|
|||
local historyCustomPortStatus=
|
||||
if [[ -n "${customPort}" || -n "${currentPort}" ]]; then
|
||||
echo
|
||||
if [[ -z "${lastInstallationConfig}" ]]; then
|
||||
read -r -p "读取到上次安装时的端口,是否使用上次安装时的端口?[y/n]:" historyCustomPortStatus
|
||||
if [[ "${historyCustomPortStatus}" == "y" ]]; then
|
||||
port=${currentPort}
|
||||
echoContent yellow "\n ---> 端口: ${port}"
|
||||
fi
|
||||
elif [[ -n "${lastInstallationConfig}" ]]; then
|
||||
port=${currentPort}
|
||||
fi
|
||||
fi
|
||||
if [[ -z "${currentPort}" ]] || [[ "${historyCustomPortStatus}" == "n" ]]; then
|
||||
echo
|
||||
|
@ -1884,6 +1904,7 @@ installTLS() {
|
|||
|
||||
else
|
||||
if [[ -d "$HOME/.acme.sh/${tlsDomain}_ecc" && -f "$HOME/.acme.sh/${tlsDomain}_ecc/${tlsDomain}.key" && -f "$HOME/.acme.sh/${tlsDomain}_ecc/${tlsDomain}.cer" ]] || [[ "${installedDNSAPIStatus}" == "true" ]]; then
|
||||
if [[ -z "${lastInstallationConfig}" ]]; then
|
||||
echoContent yellow " ---> 如未过期或者自定义证书请选择[n]\n"
|
||||
read -r -p "是否重新安装?[y/n]:" reInstallStatus
|
||||
if [[ "${reInstallStatus}" == "y" ]]; then
|
||||
|
@ -1892,6 +1913,7 @@ installTLS() {
|
|||
fi
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
elif [[ -d "$HOME/.acme.sh" ]] && [[ ! -f "$HOME/.acme.sh/${tlsDomain}_ecc/${tlsDomain}.cer" || ! -f "$HOME/.acme.sh/${tlsDomain}_ecc/${tlsDomain}.key" ]]; then
|
||||
switchDNSAPI
|
||||
|
@ -1957,10 +1979,12 @@ randomPathFunction() {
|
|||
echoContent skyBlue "生成随机路径"
|
||||
fi
|
||||
|
||||
if [[ -n "${currentPath}" ]]; then
|
||||
if [[ -n "${currentPath}" && -z "${lastInstallationConfig}" ]]; then
|
||||
echo
|
||||
read -r -p "读取到上次安装记录,是否使用上次安装时的path路径 ?[y/n]:" historyPathStatus
|
||||
echo
|
||||
elif [[ -n "${currentPath}" && -n "${lastInstallationConfig}" ]]; then
|
||||
historyPathStatus="y"
|
||||
fi
|
||||
|
||||
if [[ "${historyPathStatus}" == "y" ]]; then
|
||||
|
@ -2005,7 +2029,12 @@ nginxBlog() {
|
|||
|
||||
if [[ -d "${nginxStaticPath}" && -f "${nginxStaticPath}/check" ]]; then
|
||||
echo
|
||||
if [[ -z "${lastInstallationConfig}" ]]; then
|
||||
read -r -p "检测到安装伪装站点,是否需要重新安装[y/n]:" nginxBlogInstallStatus
|
||||
else
|
||||
nginxBlogInstallStatus="n"
|
||||
fi
|
||||
|
||||
if [[ "${nginxBlogInstallStatus}" == "y" ]]; then
|
||||
rm -rf "${nginxStaticPath}*"
|
||||
# randomNum=$((RANDOM % 6 + 1))
|
||||
|
@ -2288,12 +2317,14 @@ installSingBox() {
|
|||
fi
|
||||
else
|
||||
echoContent green " ---> sing-box版本:v$(/etc/v2ray-agent/sing-box/sing-box version | grep "sing-box version" | awk '{print $3}')"
|
||||
if [[ -z "${lastInstallationConfig}" ]]; then
|
||||
read -r -p "是否更新、升级?[y/n]:" reInstallSingBoxStatus
|
||||
if [[ "${reInstallSingBoxStatus}" == "y" ]]; then
|
||||
rm -f /etc/v2ray-agent/sing-box/sing-box
|
||||
installSingBox "$1"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
}
|
||||
|
||||
|
@ -2318,7 +2349,6 @@ installXray() {
|
|||
if [[ ! -f "/etc/v2ray-agent/xray/xray" ]]; then
|
||||
|
||||
version=$(curl -s "https://api.github.com/repos/XTLS/Xray-core/releases?per_page=5" | jq -r ".[]|select (.prerelease==${prereleaseStatus})|.tag_name" | head -1)
|
||||
|
||||
echoContent green " ---> Xray-core版本:${version}"
|
||||
if [[ "${release}" == "alpine" ]]; then
|
||||
wget -c -q -P /etc/v2ray-agent/xray/ "https://github.com/XTLS/Xray-core/releases/download/${version}/${xrayCoreCPUVendor}.zip"
|
||||
|
@ -2351,6 +2381,7 @@ installXray() {
|
|||
chmod 655 /etc/v2ray-agent/xray/xray
|
||||
fi
|
||||
else
|
||||
if [[ -z "${lastInstallationConfig}" ]]; then
|
||||
echoContent green " ---> Xray-core版本:$(/etc/v2ray-agent/xray/xray --version | awk '{print $2}' | head -1)"
|
||||
read -r -p "是否更新、升级?[y/n]:" reInstallXrayStatus
|
||||
if [[ "${reInstallXrayStatus}" == "y" ]]; then
|
||||
|
@ -2358,6 +2389,7 @@ installXray() {
|
|||
installXray "$1" "$2"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
}
|
||||
|
||||
# v2ray版本管理
|
||||
|
@ -3975,13 +4007,15 @@ initXrayFrontingConfig() {
|
|||
# 初始化sing-box端口
|
||||
initSingBoxPort() {
|
||||
local port=$1
|
||||
if [[ -n "${port}" ]]; then
|
||||
if [[ -n "${port}" && -z "${lastInstallationConfig}" ]]; then
|
||||
read -r -p "读取到上次使用的端口,是否使用 ?[y/n]:" historyPort
|
||||
if [[ "${historyPort}" != "y" ]]; then
|
||||
port=
|
||||
else
|
||||
echo "${port}"
|
||||
fi
|
||||
elif [[ -n "${port}" && -n "${lastInstallationConfig}" ]]; then
|
||||
echo "${port}"
|
||||
fi
|
||||
if [[ -z "${port}" ]]; then
|
||||
read -r -p '请输入自定义端口[需合法],端口不可重复,[回车]随机端口:' port
|
||||
|
@ -4005,12 +4039,14 @@ initXrayConfig() {
|
|||
echo
|
||||
local uuid=
|
||||
local addClientsStatus=
|
||||
if [[ -n "${currentUUID}" ]]; then
|
||||
if [[ -n "${currentUUID}" && -z "${lastInstallationConfig}" ]]; then
|
||||
read -r -p "读取到上次用户配置,是否使用上次安装的配置 ?[y/n]:" historyUUIDStatus
|
||||
if [[ "${historyUUIDStatus}" == "y" ]]; then
|
||||
addClientsStatus=true
|
||||
echoContent green "\n ---> 使用成功"
|
||||
fi
|
||||
elif [[ -n "${currentUUID}" && -n "${lastInstallationConfig}" ]]; then
|
||||
addClientsStatus=true
|
||||
fi
|
||||
|
||||
if [[ -z "${addClientsStatus}" ]]; then
|
||||
|
@ -4351,6 +4387,7 @@ EOF
|
|||
# VLESS_TCP/reality
|
||||
if echo "${selectCustomInstallType}" | grep -q ",7," || [[ "$1" == "all" ]]; then
|
||||
echoContent skyBlue "\n===================== 配置VLESS+Reality =====================\n"
|
||||
|
||||
initXrayRealityPort
|
||||
initRealityClientServersName
|
||||
initRealityKey
|
||||
|
@ -4466,12 +4503,14 @@ initSingBoxConfig() {
|
|||
elif [[ -n "${currentHost}" ]]; then
|
||||
sslDomain="${currentHost}"
|
||||
fi
|
||||
if [[ -n "${currentUUID}" ]]; then
|
||||
if [[ -n "${currentUUID}" && -z "${lastInstallationConfig}" ]]; then
|
||||
read -r -p "读取到上次用户配置,是否使用上次安装的配置 ?[y/n]:" historyUUIDStatus
|
||||
if [[ "${historyUUIDStatus}" == "y" ]]; then
|
||||
addClientsStatus=true
|
||||
echoContent green "\n ---> 使用成功"
|
||||
fi
|
||||
elif [[ -n "${currentUUID}" && -n "${lastInstallationConfig}" ]]; then
|
||||
addClientsStatus=true
|
||||
fi
|
||||
|
||||
if [[ -z "${addClientsStatus}" ]]; then
|
||||
|
@ -8028,6 +8067,7 @@ customSingBoxInstall() {
|
|||
fi
|
||||
|
||||
if [[ "${selectCustomInstallType//,/}" =~ ^[0-9]+$ ]]; then
|
||||
readLastInstallationConfig
|
||||
totalProgress=9
|
||||
installTools 1
|
||||
# 申请tls
|
||||
|
@ -8098,6 +8138,7 @@ customXrayInstall() {
|
|||
selectCustomInstallType=",${selectCustomInstallType},"
|
||||
fi
|
||||
if [[ "${selectCustomInstallType//,/}" =~ ^[0-7]+$ ]]; then
|
||||
readLastInstallationConfig
|
||||
unInstallSubscribe
|
||||
checkBTPanel
|
||||
check1Panel
|
||||
|
@ -8156,7 +8197,7 @@ customXrayInstall() {
|
|||
fi
|
||||
}
|
||||
|
||||
# 选择核心安装---v2ray-core、xray-core
|
||||
# 选择核心安装sing-box、xray-core
|
||||
selectCoreInstall() {
|
||||
echoContent skyBlue "\n功能 1/${totalProgress} : 选择核心安装"
|
||||
echoContent red "\n=============================================================="
|
||||
|
@ -8188,6 +8229,7 @@ selectCoreInstall() {
|
|||
|
||||
# xray-core 安装
|
||||
xrayCoreInstall() {
|
||||
readLastInstallationConfig
|
||||
unInstallSubscribe
|
||||
checkBTPanel
|
||||
check1Panel
|
||||
|
@ -8233,17 +8275,12 @@ xrayCoreInstall() {
|
|||
|
||||
# sing-box 全部安装
|
||||
singBoxInstall() {
|
||||
readLastInstallationConfig
|
||||
checkBTPanel
|
||||
check1Panel
|
||||
selectCustomInstallType=
|
||||
totalProgress=8
|
||||
installTools 2
|
||||
# if [[ -n "${btDomain}" ]]; then
|
||||
# echoContent skyBlue "\n进度 3/${totalProgress} : 检测到宝塔面板,跳过申请TLS步骤"
|
||||
# handleXray stop
|
||||
# customPortFunction
|
||||
# else
|
||||
# 申请tls
|
||||
|
||||
if [[ -n "${btDomain}" ]]; then
|
||||
echoContent skyBlue "\n进度 3/${totalProgress} : 检测到宝塔面板/1Panel,跳过申请TLS步骤"
|
||||
|
@ -8261,6 +8298,7 @@ singBoxInstall() {
|
|||
installSingBox 5
|
||||
installSingBoxService 6
|
||||
initSingBoxConfig all 7
|
||||
|
||||
cleanUp xrayDel
|
||||
installCronTLS 8
|
||||
|
||||
|
@ -9183,12 +9221,15 @@ switchAlpn() {
|
|||
# 初始化realityKey
|
||||
initRealityKey() {
|
||||
echoContent skyBlue "\n生成Reality key\n"
|
||||
if [[ -n "${currentRealityPublicKey}" ]]; then
|
||||
if [[ -n "${currentRealityPublicKey}" && -z "${lastInstallationConfig}" ]]; then
|
||||
read -r -p "读取到上次安装记录,是否使用上次安装时的PublicKey/PrivateKey ?[y/n]:" historyKeyStatus
|
||||
if [[ "${historyKeyStatus}" == "y" ]]; then
|
||||
realityPrivateKey=${currentRealityPrivateKey}
|
||||
realityPublicKey=${currentRealityPublicKey}
|
||||
fi
|
||||
elif [[ -n "${currentRealityPublicKey}" && -n "${lastInstallationConfig}" ]]; then
|
||||
realityPrivateKey=${currentRealityPrivateKey}
|
||||
realityPublicKey=${currentRealityPublicKey}
|
||||
fi
|
||||
if [[ -z "${realityPrivateKey}" ]]; then
|
||||
if [[ "${selectCoreType}" == "2" || "${coreInstallType}" == "2" ]]; then
|
||||
|
@ -9247,15 +9288,26 @@ initRealityDest() {
|
|||
}
|
||||
# 初始化客户端可用的ServersName
|
||||
initRealityClientServersName() {
|
||||
|
||||
if [[ -n "${realityServerName}" && -z "${lastInstallationConfig}" ]]; then
|
||||
read -r -p "读取到上次安装设置的Reality域名,是否使用?[y/n]:" realityServerNameStatus
|
||||
if [[ "${realityServerNameStatus}" != "y" ]]; then
|
||||
realityServerName=
|
||||
fi
|
||||
elif [[ -z "${lastInstallationConfig}" ]]; then
|
||||
realityServerName=
|
||||
fi
|
||||
if [[ -n "${realityServerName}" ]] && [[ "${realityServerName}" != "${domain}" ]]; then
|
||||
realityDomainPort=443
|
||||
fi
|
||||
|
||||
if [[ -z "${realityServerName}" ]]; then
|
||||
if [[ -n "${domain}" ]]; then
|
||||
echo
|
||||
read -r -p "是否使用 ${domain} 此域名作为Reality目标域名 ?[y/n]:" realityServerNameCurrentDomainStatus
|
||||
if [[ "${realityServerNameCurrentDomainStatus}" == "y" ]]; then
|
||||
realityServerName="${domain}"
|
||||
if [[ "${selectCoreType}" == "1" ]]; then
|
||||
# if [[ -n "${port}" ]]; then
|
||||
# realityDomainPort="${port}"
|
||||
if [[ -z "${subscribePort}" ]]; then
|
||||
echo
|
||||
installSubscribe
|
||||
|
@ -9281,7 +9333,6 @@ initRealityClientServersName() {
|
|||
echoContent yellow "录入示例:addons.mozilla.org:443\n"
|
||||
read -r -p "请输入目标域名,[回车]随机域名,默认端口443:" realityServerName
|
||||
if [[ -z "${realityServerName}" ]]; then
|
||||
# randomNum=$((RANDOM % 27 + 1))
|
||||
randomNum=$(randomNum 1 27)
|
||||
realityServerName=$(echo "${realityDestDomainList}" | awk -F ',' -v randomNum="$randomNum" '{print $randomNum}')
|
||||
fi
|
||||
|
@ -9290,16 +9341,19 @@ initRealityClientServersName() {
|
|||
realityServerName=$(echo "${realityServerName}" | awk -F "[:]" '{print $1}')
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
|
||||
echoContent yellow "\n ---> 客户端可用域名: ${realityServerName}:${realityDomainPort}\n"
|
||||
}
|
||||
# 初始化reality端口
|
||||
initXrayRealityPort() {
|
||||
if [[ -n "${xrayVLESSRealityPort}" ]]; then
|
||||
if [[ -n "${xrayVLESSRealityPort}" && -z "${lastInstallationConfig}" ]]; then
|
||||
read -r -p "读取到上次安装记录,是否使用上次安装时的端口 ?[y/n]:" historyRealityPortStatus
|
||||
if [[ "${historyRealityPortStatus}" == "y" ]]; then
|
||||
realityPort=${xrayVLESSRealityPort}
|
||||
fi
|
||||
elif [[ -n "${xrayVLESSRealityPort}" && -n "${lastInstallationConfig}" ]]; then
|
||||
realityPort=${xrayVLESSRealityPort}
|
||||
fi
|
||||
|
||||
if [[ -z "${realityPort}" ]]; then
|
||||
|
@ -9332,11 +9386,13 @@ initXrayRealityPort() {
|
|||
}
|
||||
# 初始化SplitHTTP端口
|
||||
initXraySplitPort() {
|
||||
if [[ -n "${xrayVLESSSplitHTTPort}" ]]; then
|
||||
if [[ -n "${xrayVLESSSplitHTTPort}" && -z "${lastInstallationConfig}" ]]; then
|
||||
read -r -p "读取到上次安装记录,是否使用上次安装时的端口 ?[y/n]:" historySplitHTTPortStatus
|
||||
if [[ "${historySplitHTTPortStatus}" == "y" ]]; then
|
||||
splitHTTPort=${xrayVLESSSplitHTTPort}
|
||||
fi
|
||||
elif [[ -n "${xrayVLESSSplitHTTPort}" && -n "${lastInstallationConfig}" ]]; then
|
||||
splitHTTPort=${xrayVLESSSplitHTTPort}
|
||||
fi
|
||||
|
||||
if [[ -z "${splitHTTPort}" ]]; then
|
||||
|
@ -9629,7 +9685,7 @@ menu() {
|
|||
cd "$HOME" || exit
|
||||
echoContent red "\n=============================================================="
|
||||
echoContent green "作者:mack-a"
|
||||
echoContent green "当前版本:v3.3.18"
|
||||
echoContent green "当前版本:v3.3.19"
|
||||
echoContent green "Github:https://github.com/mack-a/v2ray-agent"
|
||||
echoContent green "描述:八合一共存脚本\c"
|
||||
showInstallStatus
|
||||
|
|
Loading…
Reference in New Issue