feat(脚本): 修改warning

pull/534/merge
mack-a 2021-09-03 15:19:21 +08:00
parent 67550ed2c6
commit ff1b71ea01
2 changed files with 363 additions and 422 deletions

View File

@ -50,9 +50,6 @@ checkSystem() {
upgrade="yum update -y --skip-broken"
elif grep </etc/issue -q -i "debian" && [[ -f "/etc/issue" ]] || grep </etc/issue -q -i "debian" && [[ -f "/proc/version" ]]; then
if grep </etc/issue -i "8"; then
debianVersion=8
fi
release="debian"
installType='apt -y install'
upgrade="apt update"
@ -172,9 +169,6 @@ initVar() {
# UUID
currentUUID=
# pingIPv6 pingIPv4
pingIP=
pingIPv6=
localIP=
# 集成更新证书逻辑不再使用单独的脚本--RenewTLS
@ -225,31 +219,30 @@ readInstallProtocolType() {
currentInstallProtocolType=
while read -r row; do
if echo ${row} | grep -q 02_trojan_TCP_inbounds; then
if echo "${row}" | grep -q 02_trojan_TCP_inbounds; then
currentInstallProtocolType=${currentInstallProtocolType}'trojan'
frontingType=02_trojan_TCP_inbounds
fi
if echo ${row} | grep -q VLESS_TCP_inbounds; then
if echo "${row}" | grep -q VLESS_TCP_inbounds; then
currentInstallProtocolType=${currentInstallProtocolType}'0'
frontingType=02_VLESS_TCP_inbounds
fi
if echo ${row} | grep -q VLESS_WS_inbounds; then
if echo "${row}" | grep -q VLESS_WS_inbounds; then
currentInstallProtocolType=${currentInstallProtocolType}'1'
fi
if echo ${row} | grep -q trojan_gRPC_inbounds; then
if echo "${row}" | grep -q trojan_gRPC_inbounds; then
currentInstallProtocolType=${currentInstallProtocolType}'2'
fi
if echo ${row} | grep -q VMess_WS_inbounds; then
if echo "${row}" | grep -q VMess_WS_inbounds; then
currentInstallProtocolType=${currentInstallProtocolType}'3'
fi
if echo ${row} | grep -q 04_trojan_TCP_inbounds; then
if echo "${row}" | grep -q 04_trojan_TCP_inbounds; then
currentInstallProtocolType=${currentInstallProtocolType}'4'
fi
if echo ${row} | grep -q VLESS_gRPC_inbounds; then
if echo "${row}" | grep -q VLESS_gRPC_inbounds; then
currentInstallProtocolType=${currentInstallProtocolType}'5'
fi
done < <(ls ${configPath} | grep inbounds.json | awk -F "[.]" '{print $1}')
done < <(find ${configPath} -name "*inbounds.json" | awk -F "[.]" '{print $1}')
}
# 检查文件目录以及path路径
@ -261,9 +254,11 @@ readConfigHostPathUUID() {
currentAdd=
# 读取path
if [[ -n "${configPath}" ]]; then
local fallback=$(jq -r -c '.inbounds[0].settings.fallbacks[]|select(.path)' ${configPath}${frontingType}.json|head -1)
local fallback
fallback=$(jq -r -c '.inbounds[0].settings.fallbacks[]|select(.path)' ${configPath}${frontingType}.json | head -1)
local path=$(echo "${fallback}"|jq -r .path|awk -F "[/]" '{print $2}')
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}')
@ -377,7 +372,7 @@ cleanUp() {
fi
}
initVar $1
initVar "$1"
checkSystem
checkCPUVendor
readInstallType
@ -599,14 +594,14 @@ installWarp(){
elif [[ "${release}" == "centos" ]]; then
${installType} yum-utils >/dev/null 2>&1
sudo rpm -ivh http://pkg.cloudflareclient.com/cloudflare-release-el${centosVersion}.rpm >/dev/null 2>&1
sudo rpm -ivh "http://pkg.cloudflareclient.com/cloudflare-release-el${centosVersion}.rpm" >/dev/null 2>&1
fi
echoContent green " ---> 安装WARP"
${installType} cloudflare-warp >/dev/null 2>&1
if [[ -z $(which warp-cli) ]]; then
echoContent red " ---> 安装WARP失败"
exit 0;
exit 0
fi
systemctl enable warp-svc
warp-cli --accept-tos register
@ -683,7 +678,7 @@ server {
listen [::]:80;
server_name ${domain};
# shellcheck disable=SC2154
return 301 https://${domain}$request_uri;
return 301 https://${domain}\${request_uri};
}
server {
listen 127.0.0.1:31300;
@ -691,7 +686,8 @@ server {
return 403;
}
EOF
if [[ -n $(echo "${selectCustomInstallType}" |grep 2) && -n $(echo "${selectCustomInstallType}" |grep 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
server {
@ -830,14 +826,14 @@ checkIP() {
handleFirewall stop
fi
exit 0;
exit 0
fi
if echo "${localIP}" | awk -F "[,]" '{print $2}' | grep -q "." || echo "${localIP}" | awk -F "[,]" '{print $2}' | grep -q ":"; then
echoContent red "\n ---> 检测到多个ip请确认是否关闭cloudflare的云朵"
echoContent yellow " ---> 关闭云朵后等待三分钟后重试"
echoContent yellow " ---> 检测到的ip如下[${localIP}]"
exit 0;
exit 0
fi
echoContent green " ---> 当前域名ip为[${localIP}]"
@ -852,13 +848,13 @@ installTLS() {
echoContent green " ---> 检测到证书"
checkTLStatus "${tlsDomain}"
if [[ "${tlsStatus}" == "已过期" ]]; then
rm -rf $HOME/.acme.sh/${tlsDomain}_ecc/*
rm -rf /etc/v2ray-agent/tls/${tlsDomain}*
rm -rf "$HOME/.acme.sh/${tlsDomain}_ecc/*"
rm -rf "/etc/v2ray-agent/tls/${tlsDomain}*"
installTLS "$1"
else
echoContent green " ---> 证书有效"
if ! ls /etc/v2ray-agent/tls/ | grep -q "${tlsDomain}.crt" || ! ls /etc/v2ray-agent/tls/ | grep -q "${tlsDomain}.key" || [[ -z $(cat "/etc/v2ray-agent/tls/${tlsDomain}.crt") ]]; then
#
if [[ -z ${find/etc/v2ray-agent/tls/ -name "${tlsDomain}.crt"} ]] || [[ -z ${find/etc/v2ray-agent/tls/ -name "${tlsDomain}.key"} ]] || [[ -z $(cat "/etc/v2ray-agent/tls/${tlsDomain}.crt") ]]; then
sudo "$HOME/.acme.sh/acme.sh" --installcert -d "${tlsDomain}" --fullchainpath "/etc/v2ray-agent/tls/${tlsDomain}.crt" --keypath "/etc/v2ray-agent/tls/${tlsDomain}.key" --ecc >/dev/null
else
echoContent yellow " ---> 如未过期请选择[n]\n"
@ -872,9 +868,9 @@ installTLS() {
elif [[ -d "$HOME/.acme.sh" ]] && [[ ! -f "$HOME/.acme.sh/${tlsDomain}_ecc/${tlsDomain}.cer" || ! -f "$HOME/.acme.sh/${tlsDomain}_ecc/${tlsDomain}.key" ]]; then
echoContent green " ---> 安装TLS证书"
if echo "${localIP}" | grep -q ":"; then
sudo "$HOME/.acme.sh/acme.sh" --issue -d "${tlsDomain}" --standalone -k ec-256 --server letsencrypt --listen-v6 >> /etc/v2ray-agent/tls/acme.log
sudo "$HOME/.acme.sh/acme.sh" --issue -d "${tlsDomain}" --standalone -k ec-256 --server letsencrypt --listen-v6 | tee -a /etc/v2ray-agent/tls/acme.log >/dev/null
else
sudo "$HOME/.acme.sh/acme.sh" --issue -d "${tlsDomain}" --standalone -k ec-256 --server letsencrypt >> /etc/v2ray-agent/tls/acme.log
sudo "$HOME/.acme.sh/acme.sh" --issue -d "${tlsDomain}" --standalone -k ec-256 --server letsencrypt | tee -a /etc/v2ray-agent/tls/acme.log >/dev/null
fi
if [[ -d "$HOME/.acme.sh/${tlsDomain}_ecc" && -f "$HOME/.acme.sh/${tlsDomain}_ecc/${tlsDomain}.key" && -f "$HOME/.acme.sh/${tlsDomain}_ecc/${tlsDomain}.cer" ]]; then
@ -932,7 +928,7 @@ randomPathFunction() {
read -r -p '路径:' customPath
if [[ -z "${customPath}" ]]; then
customPath=$(head -n 50 /dev/urandom | sed 's/[^a-z]//g' | strings -n 4 | tr 'A-Z' 'a-z' | head -1)
customPath=$(head -n 50 /dev/urandom | sed 's/[^a-z]//g' | strings -n 4 | tr '[:upper:]' '[:lower:]' | head -1)
currentPath=${customPath:0:4}
customPath=${currentPath}
else
@ -973,12 +969,13 @@ handleNginx() {
if [[ -z $(pgrep -f "nginx") ]] && [[ "$1" == "start" ]]; then
nginx
sleep 0.5
if ! ps -ef | grep -v grep | grep -q nginx; then
if [[ -z $(pgrep -f nginx) ]]; then
echoContent red " ---> Nginx启动失败"
echoContent red " ---> 请手动尝试安装nginx后再次执行脚本"
exit 0
fi
elif [[ "$1" == "stop" ]] && [[ -n $(pgrep -f "nginx") ]]; then
elif [[ -n $(pgrep -f "nginx") ]] && [[ "$1" == "stop" ]]; then
nginx -s stop >/dev/null 2>&1
sleep 0.5
if [[ -n $(pgrep -f "nginx") ]]; then
@ -991,7 +988,8 @@ handleNginx() {
installCronTLS() {
echoContent skyBlue "\n进度 $1/${totalProgress} : 添加定时维护证书"
crontab -l >/etc/v2ray-agent/backup_crontab.cron
local historyCrontab=$(sed '/v2ray-agent/d;/acme.sh/d' /etc/v2ray-agent/backup_crontab.cron)
local historyCrontab
historyCrontab=$(sed '/v2ray-agent/d;/acme.sh/d' /etc/v2ray-agent/backup_crontab.cron)
echo "${historyCrontab}" >/etc/v2ray-agent/backup_crontab.cron
echo "30 1 * * * /bin/bash /etc/v2ray-agent/install.sh RenewTLS >> /etc/v2ray-agent/crontab_tls.log 2>&1" >>/etc/v2ray-agent/backup_crontab.cron
crontab /etc/v2ray-agent/backup_crontab.cron
@ -1003,13 +1001,13 @@ renewalTLS() {
echoContent skyBlue "\n进度 1/1 : 更新证书"
if [[ -d "$HOME/.acme.sh/${currentHost}_ecc" ]] && [[ -f "$HOME/.acme.sh/${currentHost}_ecc/${currentHost}.key" ]] && [[ -f "$HOME/.acme.sh/${currentHost}_ecc/${currentHost}.cer" ]]; then
modifyTime=$(stat $HOME/.acme.sh/${currentHost}_ecc/${currentHost}.cer | sed -n '7,6p' | awk '{print $2" "$3" "$4" "$5}')
modifyTime=$(stat "$HOME/.acme.sh/${currentHost}_ecc/${currentHost}.cer" | sed -n '7,6p' | awk '{print $2" "$3" "$4" "$5}')
modifyTime=$(date +%s -d "${modifyTime}")
currentTime=$(date +%s)
stampDiff=$(expr ${currentTime} - ${modifyTime})
days=$(expr ${stampDiff} / 86400)
remainingDays=$(expr 90 - ${days})
stampDiff=$(("${currentTime}" - "${modifyTime}"))
days=$(("${stampDiff}" / 86400))
remainingDays=$((90 - "${days}"))
tlsStatus=${remainingDays}
if [[ ${remainingDays} -le 0 ]]; then
tlsStatus="已过期"
@ -1039,13 +1037,13 @@ checkTLStatus() {
if [[ -n "$1" ]]; then
if [[ -d "$HOME/.acme.sh/$1_ecc" ]] && [[ -f "$HOME/.acme.sh/$1_ecc/$1.key" ]] && [[ -f "$HOME/.acme.sh/$1_ecc/$1.cer" ]]; then
modifyTime=$(stat $HOME/.acme.sh/$1_ecc/$1.key | sed -n '7,6p' | awk '{print $2" "$3" "$4" "$5}')
modifyTime=$(stat "$HOME/.acme.sh/$1_ecc/$1.key" | sed -n '7,6p' | awk '{print $2" "$3" "$4" "$5}')
modifyTime=$(date +%s -d "${modifyTime}")
currentTime=$(date +%s)
stampDiff=$(expr ${currentTime} - ${modifyTime})
days=$(expr ${stampDiff} / 86400)
remainingDays=$(expr 90 - ${days})
stampDiff=$(("${currentTime}" - "${modifyTime}"))
days=$(("${stampDiff}" / 86400))
remainingDays=$((90 - "${days}"))
tlsStatus=${remainingDays}
if [[ ${remainingDays} -le 0 ]]; then
tlsStatus="已过期"
@ -1077,8 +1075,8 @@ installV2Ray() {
wget -c -P /etc/v2ray-agent/v2ray/ "https://github.com/v2fly/v2ray-core/releases/download/${version}/${v2rayCoreCPUVendor}.zip" >/dev/null 2>&1
fi
unzip -o /etc/v2ray-agent/v2ray/${v2rayCoreCPUVendor}.zip -d /etc/v2ray-agent/v2ray >/dev/null
rm -rf /etc/v2ray-agent/v2ray/${v2rayCoreCPUVendor}.zip
unzip -o "/etc/v2ray-agent/v2ray/${v2rayCoreCPUVendor}.zip" -d /etc/v2ray-agent/v2ray >/dev/null
rm -rf "/etc/v2ray-agent/v2ray/${v2rayCoreCPUVendor}.zip"
else
if [[ "${selectCoreType}" == "3" ]]; then
echoContent green " ---> 锁定v2ray-core版本为v4.32.1"
@ -1113,8 +1111,8 @@ installXray() {
wget -c -P /etc/v2ray-agent/xray/ "https://github.com/XTLS/Xray-core/releases/download/${version}/${xrayCoreCPUVendor}.zip" >/dev/null 2>&1
fi
unzip -o /etc/v2ray-agent/xray/${xrayCoreCPUVendor}.zip -d /etc/v2ray-agent/xray >/dev/null
rm -rf /etc/v2ray-agent/xray/${xrayCoreCPUVendor}.zip
unzip -o "/etc/v2ray-agent/xray/${xrayCoreCPUVendor}.zip" -d /etc/v2ray-agent/xray >/dev/null
rm -rf "/etc/v2ray-agent/xray/${xrayCoreCPUVendor}.zip"
chmod 655 /etc/v2ray-agent/xray/xray
else
echoContent green " ---> Xray-core版本:$(/etc/v2ray-agent/xray/xray --version | awk '{print $2}' | head -1)"
@ -1129,8 +1127,7 @@ installXray() {
# 安装Trojan-go
installTrojanGo() {
echoContent skyBlue "\n进度 $1/${totalProgress} : 安装Trojan-Go"
if ! ls /etc/v2ray-agent/trojan/ | grep -q trojan-go; then
if [[ -z ${find/etc/v2ray-agent/trojan/ -name "trojan-go"} ]]; then
version=$(curl -s https://api.github.com/repos/p4gefau1t/trojan-go/releases | jq -r .[0].tag_name)
echoContent green " ---> Trojan-Go版本:${version}"
@ -1139,8 +1136,8 @@ installTrojanGo() {
else
wget -c -P /etc/v2ray-agent/trojan/ "https://github.com/p4gefau1t/trojan-go/releases/download/${version}/${trojanGoCPUVendor}.zip" >/dev/null 2>&1
fi
unzip -o /etc/v2ray-agent/trojan/${trojanGoCPUVendor}.zip -d /etc/v2ray-agent/trojan >/dev/null
rm -rf /etc/v2ray-agent/trojan/${trojanGoCPUVendor}.zip
unzip -o "/etc/v2ray-agent/trojan/${trojanGoCPUVendor}.zip" -d /etc/v2ray-agent/trojan >/dev/null
rm -rf "/etc/v2ray-agent/trojan/${trojanGoCPUVendor}.zip"
else
echoContent green " ---> Trojan-Go版本:$(/etc/v2ray-agent/trojan/trojan-go --version | awk '{print $2}' | head -1)"
@ -1181,7 +1178,7 @@ v2rayVersionManageMenu() {
read -r -p "请输入要回退的版本:" selectV2rayVersionType
version=$(curl -s https://api.github.com/repos/v2fly/v2ray-core/releases | jq -r .[].tag_name | head -5 | awk '{print ""NR""":"$0}' | grep "${selectV2rayVersionType}:" | awk -F "[:]" '{print $2}')
if [[ -n "${version}" ]]; then
updateV2Ray ${version}
updateV2Ray "${version}"
else
echoContent red "\n ---> 输入有误,请重新输入"
v2rayVersionManageMenu 1
@ -1259,8 +1256,8 @@ updateV2Ray() {
wget -c -P "/etc/v2ray-agent/v2ray/ https://github.com/v2fly/v2ray-core/releases/download/${version}/${v2rayCoreCPUVendor}.zip" >/dev/null 2>&1
fi
unzip -o /etc/v2ray-agent/v2ray/${v2rayCoreCPUVendor}.zip -d /etc/v2ray-agent/v2ray >/dev/null
rm -rf /etc/v2ray-agent/v2ray/${v2rayCoreCPUVendor}.zip
unzip -o "/etc/v2ray-agent/v2ray/${v2rayCoreCPUVendor}.zip" -d /etc/v2ray-agent/v2ray >/dev/null
rm -rf "/etc/v2ray-agent/v2ray/${v2rayCoreCPUVendor}.zip"
handleV2Ray stop
handleV2Ray start
else
@ -1333,8 +1330,8 @@ updateXray() {
wget -c -P /etc/v2ray-agent/xray/ "https://github.com/XTLS/Xray-core/releases/download/${version}/${xrayCoreCPUVendor}.zip" >/dev/null 2>&1
fi
unzip -o /etc/v2ray-agent/xray/${xrayCoreCPUVendor}.zip -d /etc/v2ray-agent/xray >/dev/null
rm -rf /etc/v2ray-agent/xray/${xrayCoreCPUVendor}.zip
unzip -o "/etc/v2ray-agent/xray/${xrayCoreCPUVendor}.zip" -d /etc/v2ray-agent/xray >/dev/null
rm -rf "/etc/v2ray-agent/xray/${xrayCoreCPUVendor}.zip"
chmod 655 /etc/v2ray-agent/xray/xray
handleXray stop
handleXray start
@ -1525,7 +1522,7 @@ handleV2Ray() {
}
# 操作xray
handleXray() {
if [[ -n $(find /bin /usr/bin -name "systemctl") ]] && ls /etc/systemd/system/ | grep -q xray.service; then
if [[ -n $(find /bin /usr/bin -name "systemctl") ]] && [[ -n $(find /etc/systemd/system/ -name "xray.service") ]]; then
if [[ -z $(pgrep -f "xray/xray") ]] && [[ "$1" == "start" ]]; then
systemctl start xray.service
elif [[ -n $(pgrep -f "xray/xray") ]] && [[ "$1" == "stop" ]]; then
@ -1554,36 +1551,6 @@ handleXray() {
fi
}
# 操作Trojan-Go
handleTrojanGo() {
if [[ -n $(find /bin /usr/bin -name "systemctl") ]] && ls /etc/systemd/system/ | grep -q trojan-go.service; then
if [[ -z $(pgrep -f "trojan-go") ]] && [[ "$1" == "start" ]]; then
systemctl start trojan-go.service
elif [[ -n $(pgrep -f "trojan-go") ]] && [[ "$1" == "stop" ]]; then
systemctl stop trojan-go.service
fi
fi
sleep 0.5
if [[ "$1" == "start" ]]; then
if [[ -n $(pgrep -f "trojan-go") ]]; then
echoContent green " ---> Trojan-Go启动成功"
else
echoContent red "Trojan-Go启动失败"
echoContent red "请手动执行【/etc/v2ray-agent/trojan/trojan-go -config /etc/v2ray-agent/trojan/config_full.json】查看错误日志"
exit 0
fi
elif [[ "$1" == "stop" ]]; then
if [[ -z $(pgrep -f "trojan-go") ]]; then
echoContent green " ---> Trojan-Go关闭成功"
else
echoContent red "Trojan-Go关闭失败"
echoContent red "请手动执行【ps -ef|grep -v grep|grep trojan-go|awk '{print \$2}'|xargs kill -9】"
exit 0
fi
fi
}
# 初始化V2Ray 配置文件
initV2RayConfig() {
echoContent skyBlue "\n进度 $2/${totalProgress} : 初始化V2Ray配置"
@ -1666,7 +1633,6 @@ EOF
EOF
fi
# dns
cat <<EOF >/etc/v2ray-agent/v2ray/conf/11_dns.json
{
@ -1681,7 +1647,7 @@ EOF
# 回落nginx
local fallbacksList='{"dest":31300,"xver":0},{"alpn":"h2","dest":31302,"xver":0}'
if [[ -n $(echo "${selectCustomInstallType}" | grep 4) || "$1" == "all" ]]; then
if echo "${selectCustomInstallType}" | grep -q 4 || [[ "$1" == "all" ]]; then
fallbacksList='{"dest":31296,"xver":1},{"alpn":"h2","dest":31302,"xver":0}'
cat <<EOF >/etc/v2ray-agent/v2ray/conf/04_trojan_TCP_inbounds.json
{
@ -1749,7 +1715,6 @@ EOF
EOF
fi
# VMess_WS
if echo "${selectCustomInstallType}" | grep -q 3 || [[ "$1" == "all" ]]; then
fallbacksList=${fallbacksList}',{"path":"/'${customPath}'vws","dest":31299,"xver":1}'
@ -1934,7 +1899,8 @@ initXrayFrontingConfig(){
if [[ "${xtlsType}" == "Trojan" ]]; then
local VLESSConfig=$(cat ${configPath}${frontingType}.json)
local VLESSConfig
VLESSConfig=$(cat ${configPath}${frontingType}.json)
VLESSConfig=${VLESSConfig//"id"/"password"}
VLESSConfig=${VLESSConfig//VLESSTCP/TrojanTCPXTLS}
VLESSConfig=${VLESSConfig//VLESS/Trojan}
@ -1945,7 +1911,8 @@ initXrayFrontingConfig(){
rm ${configPath}${frontingType}.json
elif [[ "${xtlsType}" == "VLESS" ]]; then
local VLESSConfig=$(cat ${configPath}02_trojan_TCP_inbounds.json)
local VLESSConfig
VLESSConfig=$(cat ${configPath}02_trojan_TCP_inbounds.json)
VLESSConfig=${VLESSConfig//"password"/"id"}
VLESSConfig=${VLESSConfig//TrojanTCPXTLS/VLESSTCP}
VLESSConfig=${VLESSConfig//Trojan/VLESS}
@ -1958,7 +1925,7 @@ initXrayFrontingConfig(){
reloadCore
fi
exit 0;
exit 0
}
# 初始化Xray 配置文件
@ -2048,7 +2015,6 @@ EOF
EOF
fi
# dns
cat <<EOF >/etc/v2ray-agent/xray/conf/11_dns.json
{
@ -2065,7 +2031,7 @@ EOF
local fallbacksList='{"dest":31300,"xver":0},{"alpn":"h2","dest":31302,"xver":0}'
# trojan
if [[ -n $(echo "${selectCustomInstallType}" | grep 4) || "$1" == "all" ]]; then
if echo "${selectCustomInstallType}" | grep -q 4 || [[ "$1" == "all" ]]; then
fallbacksList='{"dest":31296,"xver":1},{"alpn":"h2","dest":31302,"xver":0}'
cat <<EOF >/etc/v2ray-agent/xray/conf/04_trojan_TCP_inbounds.json
{
@ -2133,10 +2099,9 @@ EOF
EOF
fi
# trojan_grpc
if echo ${selectCustomInstallType} | grep -q 2 || [[ "$1" == "all" ]]; then
if ! echo ${selectCustomInstallType} | grep -q 5 && [[ -n ${selectCustomInstallType} ]];then
if echo "${selectCustomInstallType}" | grep -q 2 || [[ "$1" == "all" ]]; then
if ! echo "${selectCustomInstallType}" | grep -q 5 && [[ -n ${selectCustomInstallType} ]]; then
fallbacksList=${fallbacksList//31302/31304}
fi
@ -2173,7 +2138,6 @@ EOF
EOF
fi
# VMess_WS
if echo "${selectCustomInstallType}" | grep -q 3 || [[ "$1" == "all" ]]; then
fallbacksList=${fallbacksList}',{"path":"/'${customPath}'vws","dest":31299,"xver":1}'
@ -2372,10 +2336,12 @@ defaultBase64Code() {
local path=$5
local add=$6
local subAccount=${currentHost}_$(echo "${id}_currentHost" | md5sum | awk '{print $1}')
local subAccount
subAccount=${currentHost}_$(echo "${id}_currentHost" | md5sum | awk '{print $1}')
if [[ "${type}" == "vlesstcp" ]]; then
if [[ "${coreInstallType}" == "1" ]] && echo ${currentInstallProtocolType} | grep -q 0; then
if [[ "${coreInstallType}" == "1" ]] && echo "${currentInstallProtocolType}" | grep -q 0; then
echoContent yellow " ---> 通用格式(VLESS+TCP+TLS/xtls-rprx-direct)"
echoContent green " vless://${id}@${host}:${port}?encryption=none&security=xtls&type=tcp&host=${host}&headerType=none&sni=${host}&flow=xtls-rprx-direct#${email}\n"
@ -2385,7 +2351,7 @@ defaultBase64Code() {
vless://${id}@${host}:${port}?encryption=none&security=xtls&type=tcp&host=${host}&headerType=none&sni=${host}&flow=xtls-rprx-direct#${email}
EOF
echoContent yellow " ---> 二维码 VLESS(VLESS+TCP+TLS/xtls-rprx-direct)"
echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless%3A%2F%2F${id}%40${host}%3A${port}%3F${encryption}%3Dnone%26security%3Dxtls%26type%3Dtcp%26${host}%3D${host}%26headerType%3Dnone%26sni%3D${host}%26flow%3Dxtls-rprx-direct%23${email}\n"
echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless%3A%2F%2F${id}%40${host}%3A${port}%3Fencryption%3Dnone%26security%3Dxtls%26type%3Dtcp%26${host}%3D${host}%26headerType%3Dnone%26sni%3D${host}%26flow%3Dxtls-rprx-direct%23${email}\n"
echoContent skyBlue "----------------------------------------------------------------------------------"
@ -2398,9 +2364,9 @@ EOF
vless://${id}@${host}:${port}?encryption=none&security=xtls&type=tcp&host=${host}&headerType=none&sni=${host}&flow=xtls-rprx-splice#${email}
EOF
echoContent yellow " ---> 二维码 VLESS(VLESS+TCP+TLS/xtls-rprx-splice)"
echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless%3A%2F%2F${id}%40${host}%3A${port}%3F${encryption}%3Dnone%26security%3Dxtls%26type%3Dtcp%26${host}%3D${host}%26headerType%3Dnone%26sni%3D${host}%26flow%3Dxtls-rprx-splice%23${email}\n"
echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vless%3A%2F%2F${id}%40${host}%3A${port}%3Fencryption%3Dnone%26security%3Dxtls%26type%3Dtcp%26${host}%3D${host}%26headerType%3Dnone%26sni%3D${host}%26flow%3Dxtls-rprx-splice%23${email}\n"
elif [[ "${coreInstallType}" == "2" || "${coreInstallType}" == "3" ]]; then
elif [[ "${coreInstallType}" == 2 || "${coreInstallType}" == "3" ]]; then
echoContent yellow " ---> 通用格式(VLESS+TCP+TLS)"
echoContent green " vless://${id}@${host}:${port}?security=tls&encryption=none&host=${host}&headerType=none&type=tcp#${email}\n"
@ -2439,14 +2405,15 @@ EOF
echoContent yellow " ---> 二维码 Trojan(Trojan+TCP+TLS/xtls-rprx-splice)"
echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=trojan%3A%2F%2F${id}%40${host}%3A${port}%3Fencryption%3Dnone%26security%3Dxtls%26type%3Dtcp%26${host}%3D${host}%26headerType%3Dnone%26sni%3D${host}%26flow%3Dxtls-rprx-splice%23${email}\n"
elif
[[ "${type}" == "vmessws" ]]
then
elif [[ "${type}" == "vmessws" ]]; then
qrCodeBase64Default=$(echo -n '{"port":"'${port}'","ps":'\"${email}\"',"tls":"tls","id":'\"${id}\"',"aid":"0","v":"2","host":"'${host}'","type":"none","path":"/'${path}'","net":"ws","add":"'${add}'","allowInsecure":0,"method":"none","peer":"'${host}'","sni":"'${host}'"}' | sed 's#/#\\\/#g' | base64)
qrCodeBase64Default=$(echo ${qrCodeBase64Default} | sed 's/ //g')
qrCodeBase64Default=$(echo -n "{\"port\":${port},\"ps\":\"${email}\",\"tls\":\"tls\",\"id\":\"${id}\",\"aid\":0,\"v\":2,\"host\":\"${host}\",\"type\":\"none\",\"path\":\"/${path}\",\"net\":\"ws\",\"add\":\"${add}\",\"allowInsecure\":0,\"method\":\"none\",\"peer\":\"${host}\",\"sni\":\"${host}\"}" | sed 's#/#\\\/#g' | base64)
qrCodeBase64Default="${qrCodeBase64Default// /}"
echoContent yellow " ---> 通用json(VMess+WS+TLS)"
echoContent green ' {"port":"'${port}'","ps":'\"${ps}\"',"tls":"tls","id":'\"${id}\"',"aid":"0","v":"2","host":"'${host}'","type":"none","path":"/'${path}'","net":"ws","add":"'${add}'","allowInsecure":0,"method":"none","peer":"'${host}'","sni":"'${host}'"}\n'
echoContent green " {\"port\":${port},\"ps\":\"${email}\",\"tls\":\"tls\",\"id\":\"${id}\",\"aid\":0,\"v\":2,\"host\":'${host}',\"type\":\"none\",\"path\":\"${path}\",\"net\":\"ws\",\"add\":\"${add}\",\"allowInsecure\":0,\"method\":\"none\",\"peer\":\"${host}\",\"sni\":\"${host}\"}\n"
echoContent yellow " ---> 通用vmess(VMess+WS+TLS)链接"
echoContent green " vmess://${qrCodeBase64Default}\n"
echoContent yellow " ---> 二维码 vmess(VMess+WS+TLS)"
@ -2458,25 +2425,12 @@ EOF
elif [[ "${type}" == "vmesstcp" ]]; then
# echoContent yellow " ---> 通用格式[新版,推荐]"
#
# echoContent green " vmess://tcp+tls:2e6257c5-1402-41a6-a96d-1e0bdad78159-0@vu3.s83h.xyz:443/?type=http&tlsServerName=vu3.s83h.xyz#vu3.s83h.xyz_vmess_tcp"
# echoContent green " vmess://tcp+tls:${id//\"/}-0@${add}:${port}/?type=http&path=/${path}&tlsServerName=${host}&alpn=http1.1#${ps//\"/}\n"
#
# echoContent yellow " ---> 格式化明文(vmess+http+tls)"
# echoContent green "协议类型vmess地址${host},端口:${port}用户ID${id}安全tls传输方式http账户名:${ps}\n"
# cat <<EOF >>"/etc/v2ray-agent/subscribe_tmp/${subAccount}"
#vmess://http+tls:${id}-0@${add}:${port}/?path=/${path}&tlsServerName=${host}&alpn=http1.1#${ps}
#EOF
# echoContent yellow " ---> 二维码 vmess(http+tls)"
# echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=vmess%3A%2F%2Fhttp%2Btls%3A${id}-0%40add%3A${port}%2F%3Fpath%3D%2F${path}%26tlsServerName%3D${host}%26alpn%3Dhttp1.1%23%24%7B${ps}%7D\n"
echoContent red path:${path}
qrCodeBase64Default=$(echo -n '{"add":"'${add}'","aid":"0","host":"'${host}'","id":'"${id}"',"net":"tcp","path":"/'${path}'","port":"'${port}'","ps":'${ps}',"scy":"none","sni":"'${host}'","tls":"tls","v":"2","type":"http","allowInsecure":0,"peer":"'${host}'","obfs":"http","obfsParam":"'${host}'"}' | base64)
qrCodeBase64Default=$(echo ${qrCodeBase64Default} | sed 's/ //g')
echoContent red "path:${path}"
qrCodeBase64Default=$(echo -n "{\"add\":\"${add}\",\"aid\":0,\"host\":\"${host}\",\"id\":\"${id}\",\"net\":\"tcp\",\"path\":\"${path}\",\"port\":${port},\"ps\":\"${email}\",\"scy\":\"none\",\"sni\":\"${host}\",\"tls\":\"tls\",\"v\":2,\"type\":\"http\",\"allowInsecure\":0,\"peer\":\"${host}\",\"obfs\":\"http\",\"obfsParam\":\"${host}\"}" | base64)
qrCodeBase64Default="${qrCodeBase64Default// /}"
echoContent yellow " ---> 通用json(VMess+TCP+TLS)"
echoContent green ' {"port":"'${port}'","ps":'${ps}',"tls":"tls","id":'"${id}"',"aid":"0","v":"2","host":"'${host}'","type":"http","path":"/'${path}'","net":"http","add":"'${add}'","allowInsecure":0,"method":"post","peer":"'${host}'","obfs":"http","obfsParam":"'${host}'"}\n'
echoContent green " {\"port\":'${port}',\"ps\":\"${email}\",\"tls\":\"tls\",\"id\":\"${id}\",\"aid\":0,\"v\":2,\"host\":\"${host}\",\"type\":\"http\",\"path\":\"${path}\",\"net\":\"http\",\"add\":\"${add}\",\"allowInsecure\":0,\"method\":\"post\",\"peer\":\"${host}\",\"obfs\":\"http\",\"obfsParam\":\"${host}\"}\n"
echoContent yellow " ---> 通用vmess(VMess+TCP+TLS)链接"
echoContent green " vmess://${qrCodeBase64Default}\n"
@ -2559,7 +2513,9 @@ EOF
echoContent green " trojan-go://${id}@${add}:${port}?sni=${host}&type=ws&host=${host}&path=%2F${path}#${host}_Trojan_ws\n"
fi
}
# 账号
showAccounts() {
readInstallType
@ -2575,7 +2531,7 @@ showAccounts() {
jq .inbounds[0].settings.clients ${configPath}02_trojan_TCP_inbounds.json | jq -c '.[]' | while read -r user; do
echoContent skyBlue "\n ---> 帐号:$(echo "${user}" | jq -r .email)_$(echo "${user}" | jq -r .password)"
echo
defaultBase64Code trojanTCPXTLS $(echo "${user}" | jq -r .email) $(echo "${user}" | jq -r .password) "${currentHost}:${currentPort}" ${currentHost}
defaultBase64Code trojanTCPXTLS "$(echo "${user}" | jq -r .email)" "$(echo "${user}" | jq -r .password)" "${currentHost}:${currentPort}" "${currentHost}"
done
else
@ -2583,11 +2539,10 @@ showAccounts() {
jq .inbounds[0].settings.clients ${configPath}02_VLESS_TCP_inbounds.json | jq -c '.[]' | while read -r user; do
echoContent skyBlue "\n ---> 帐号:$(echo "${user}" | jq -r .email)_$(echo "${user}" | jq -r .id)"
echo
defaultBase64Code vlesstcp $(echo "${user}" | jq -r .email) $(echo "${user}" | jq -r .id) "${currentHost}:${currentPort}" ${currentHost}
defaultBase64Code vlesstcp "$(echo "${user}" | jq -r .email)" "$(echo "${user}" | jq -r .id)" "${currentHost}:${currentPort}" "${currentHost}"
done
fi
# VLESS WS
if echo ${currentInstallProtocolType} | grep -q 1; then
echoContent skyBlue "\n================================ VLESS WS TLS CDN ================================\n"
@ -2600,7 +2555,7 @@ showAccounts() {
echoContent yellow "Xray的0-RTT path后面会有?ed=2048不兼容以v2ray为核心的客户端请手动删除?ed=2048后使用\n"
path="${currentPath}ws?ed=2048"
fi
defaultBase64Code vlessws $(echo "${user}" | jq -r .email) $(echo "${user}" | jq -r .id) "${currentHost}:${currentPort}" ${path} ${currentAdd}
defaultBase64Code vlessws "$(echo "${user}" | jq -r .email)" "$(echo "${user}" | jq -r .id)" "${currentHost}:${currentPort}" "${path}" "${currentAdd}"
done
fi
@ -2614,7 +2569,7 @@ showAccounts() {
jq .inbounds[0].settings.clients ${configPath}05_VMess_WS_inbounds.json | jq -c '.[]' | while read -r user; do
echoContent skyBlue "\n ---> 帐号:$(echo "${user}" | jq -r .email)_$(echo "${user}" | jq -r .id)"
echo
defaultBase64Code vmessws $(echo "${user}" | jq -r .email) $(echo "${user}" | jq -r .id) "${currentHost}:${currentPort}" ${path} ${currentAdd}
defaultBase64Code vmessws "$(echo "${user}" | jq -r .email)" "$(echo "${user}" | jq -r .id)" "${currentHost}:${currentPort}" "${path}" "${currentAdd}"
done
fi
@ -2622,11 +2577,12 @@ showAccounts() {
if echo ${currentInstallProtocolType} | grep -q 5; then
echoContent skyBlue "\n=============================== VLESS gRPC TLS CDN ===============================\n"
echoContent red "\n --->gRPC目前处于测试阶段可能对你使用的客户端不兼容如不能使用请忽略"
local serviceName=$(jq -r .inbounds[0].streamSettings.grpcSettings.serviceName ${configPath}06_VLESS_gRPC_inbounds.json)
local serviceName
serviceName=$(jq -r .inbounds[0].streamSettings.grpcSettings.serviceName ${configPath}06_VLESS_gRPC_inbounds.json)
jq .inbounds[0].settings.clients ${configPath}06_VLESS_gRPC_inbounds.json | jq -c '.[]' | while read -r user; do
echoContent skyBlue "\n ---> 帐号:$(echo "${user}" | jq -r .email)_$(echo "${user}" | jq -r .id)"
echo
defaultBase64Code vlessgrpc $(echo "${user}" | jq -r .email) $(echo "${user}" | jq -r .id) "${currentHost}:${currentPort}" ${serviceName} ${currentAdd}
defaultBase64Code vlessgrpc "$(echo "${user}" | jq -r .email)" "$(echo "${user}" | jq -r .id)" "${currentHost}:${currentPort}" "${serviceName}" "${currentAdd}"
done
fi
fi
@ -2637,18 +2593,19 @@ showAccounts() {
jq .inbounds[0].settings.clients ${configPath}04_trojan_TCP_inbounds.json | jq -c '.[]' | while read -r user; do
echoContent skyBlue "\n ---> 帐号:$(echo "${user}" | jq -r .email)_$(echo "${user}" | jq -r .password)"
echo
defaultBase64Code trojan trojan $(echo "${user}" | jq -r .password) ${currentHost}
defaultBase64Code trojan trojan "$(echo "${user}" | jq -r .password)" "${currentHost}"
done
fi
if echo ${currentInstallProtocolType} | grep -q 2; then
echoContent skyBlue "\n================================ Trojan gRPC TLS ================================\n"
echoContent red "\n --->gRPC目前处于测试阶段可能对你使用的客户端不兼容如不能使用请忽略"
local serviceName=$(jq -r .inbounds[0].streamSettings.grpcSettings.serviceName ${configPath}04_trojan_gRPC_inbounds.json)
local serviceName=
serviceName=$(jq -r .inbounds[0].streamSettings.grpcSettings.serviceName ${configPath}04_trojan_gRPC_inbounds.json)
jq .inbounds[0].settings.clients ${configPath}04_trojan_gRPC_inbounds.json | jq -c '.[]' | while read -r user; do
echoContent skyBlue "\n ---> 帐号:$(echo "${user}" | jq -r .email)_$(echo "${user}" | jq -r .password)"
echo
defaultBase64Code trojangrpc $(echo "${user}" | jq -r .email) $(echo "${user}" | jq -r .password) "${currentHost}:${currentPort}" ${serviceName} ${currentAdd}
defaultBase64Code trojangrpc "$(echo "${user}" | jq -r .email)" "$(echo "${user}" | jq -r .password)" "${currentHost}:${currentPort}" "${serviceName}" "${currentAdd}"
done
fi
@ -2712,7 +2669,7 @@ addCorePort() {
if [[ -n "${newPort}" ]]; then
while read -r port; do
cat <<EOF >${configPath}02_dokodemodoor_inbounds_${port}.json
cat <<EOF >"${configPath}02_dokodemodoor_inbounds_${port}.json"
{
"inbounds": [
{
@ -2737,12 +2694,12 @@ EOF
fi
elif [[ "${selectNewPortType}" == "2" ]]; then
ls ${configPath} | grep dokodemodoor | awk -F "[_]" '{print $4}' | awk -F "[.]" '{print ""NR""":"$1}'
find ${configPath} -name "*dokodemodoor*" | awk -F "[c][o][n][f][/]" '{print ""NR""":"$2}'
read -r -p "请输入要删除的端口编号:" portIndex
local dokoConfig=$(ls ${configPath} | grep dokodemodoor | awk '{print ""NR""":"$1}' | grep ${portIndex}":")
local dokoConfig
dokoConfig=$(find ${configPath} -name "*dokodemodoor*" | awk -F "[c][o][n][f][/]" '{print ""NR""":"$2}' | grep "${portIndex}:")
if [[ -n "${dokoConfig}" ]]; then
rm ${configPath}/$(echo "${dokoConfig}" | awk -F "[:]" '{print $2}')
rm "${configPath}/$(echo "${dokoConfig}" | awk -F "[:]" '{print $2}')"
reloadCore
else
echoContent yellow "\n ---> 编号输入错误,请重新选择"
@ -2796,7 +2753,7 @@ updateV2RayCDN() {
# todo 重构此方法
echoContent skyBlue "\n进度 $1/${totalProgress} : 修改CDN节点"
if [[ -n ${currentAdd} ]]; then
if [[ -n "${currentAdd}" ]]; then
echoContent red "=============================================================="
echoContent yellow "1.CNAME www.digitalocean.com"
echoContent yellow "2.CNAME www.cloudflare.com"
@ -2820,10 +2777,10 @@ updateV2RayCDN() {
esac
if [[ -n ${setDomain} ]]; then
if [[ -n ${currentAdd} ]]; then
sed -i "s/\"${currentAdd}\"/\"${setDomain}\"/g" $(grep "${currentAdd}" -rl ${configPath}${frontingType}.json)
if [[ -n "${currentAdd}" ]]; then
sed -i "s/\"${currentAdd}\"/\"${setDomain}\"/g" "$(grep "${currentAdd}" -rl ${configPath}${frontingType}.json)"
fi
if [[ $(jq -r .inbounds[0].settings.clients[0].add ${configPath}${frontingType}.json) == ${setDomain} ]]; then
if [[ $(jq -r .inbounds[0].settings.clients[0].add ${configPath}${frontingType}.json) == "${setDomain}" ]]; then
echoContent green " ---> CDN修改成功"
reloadCore
else
@ -2862,10 +2819,9 @@ customUUID() {
if [[ -z "${currentCustomUUID}" ]]; then
echoContent red " ---> UUID不可为空"
else
local repeat=
jq -r -c '.inbounds[0].settings.clients[].id' ${configPath}${frontingType}.json | while read -r line; do
if [[ "${line}" == "${currentCustomUUID}" ]]; then
echo repeat >/tmp/v2ray-agent
echo >/tmp/v2ray-agent
fi
done
if [[ -f "/tmp/v2ray-agent" && -n $(cat /tmp/v2ray-agent) ]]; then
@ -2887,10 +2843,9 @@ customUserEmail() {
if [[ -z "${currentCustomEmail}" ]]; then
echoContent red " ---> email不可为空"
else
local repeat=
jq -r -c '.inbounds[0].settings.clients[].email' ${configPath}${frontingType}.json | while read -r line; do
if [[ "${line}" == "${currentCustomEmail}" ]]; then
echo repeat >/tmp/v2ray-agent
echo >/tmp/v2ray-agent
fi
done
if [[ -f "/tmp/v2ray-agent" && -n $(cat /tmp/v2ray-agent) ]]; then
@ -2914,72 +2869,55 @@ addUser() {
fi
# 生成用户
local users=
local trojanGoUsers=
if [[ "${userNum}" == "1" ]]; then
customUUID
customUserEmail
fi
while [[ ${userNum} -gt 0 ]]; do
local users=
((userNum--)) || true
if [[ -n "${currentCustomUUID}" ]]; then
uuid=${currentCustomUUID}
else
uuid=$(${ctlPath} uuid)
fi
if [[ -n "${currentCustomEmail}" ]]; then
email=${currentCustomEmail}
else
email=${currentHost}_${uuid}
fi
if [[ ${userNum} == 0 ]]; then
users=${users}{\"id\":\"${uuid}\",\"flow\":\"xtls-rprx-direct\",\"email\":\"${email}\",\"alterId\":0}
if echo ${currentInstallProtocolType} | grep -q 4; then
trojanGoUsers=${trojanGoUsers}\"${uuid}\"
fi
else
users=${users}{\"id\":\"${uuid}\",\"flow\":\"xtls-rprx-direct\",\"email\":\"${email}\",\"alterId\":0},
if echo ${currentInstallProtocolType} | grep -q 4; then
trojanGoUsers=${trojanGoUsers}\"${uuid}\",
fi
fi
done
# 兼容v2ray-core
users="{\"id\":\"${uuid}\",\"flow\":\"xtls-rprx-direct\",\"email\":\"${email}\",\"alterId\":0}"
if [[ "${coreInstallType}" == "2" ]]; then
users="${users//\"flow\":\"xtls-rprx-direct\"\,/}"
users="{\"id\":\"${uuid}\",\"email\":\"${email}\",\"alterId\":0}"
fi
if echo ${currentInstallProtocolType} | grep -q 0; then
local vlessUsers="${users//\,\"alterId\":0/}"
local vlessTcpResult
vlessTcpResult=$(jq -r '.inbounds[0].settings.clients += ['${vlessUsers}']' ${configPath}${frontingType}.json)
vlessTcpResult=$(jq -r ".inbounds[0].settings.clients += [${vlessUsers}]" ${configPath}${frontingType}.json)
echo "${vlessTcpResult}" | jq . >${configPath}${frontingType}.json
fi
if echo ${currentInstallProtocolType} | grep -q trojan; then
local trojanXTLSUsers="${users//\,\"alterId\":0/}"
trojanXTLSUsers=${trojanXTLSUsers//"id"/"password"}
echo trojanXTLSUsers:${trojanXTLSUsers}
local trojanXTLSResult
trojanXTLSResult=$(jq -r '.inbounds[0].settings.clients += ['${trojanXTLSUsers}']' ${configPath}${frontingType}.json)
trojanXTLSResult=$(jq -r ".inbounds[0].settings.clients += [${trojanXTLSUsers}]" ${configPath}${frontingType}.json)
echo "${trojanXTLSResult}" | jq . >${configPath}${frontingType}.json
fi
# users="${users//"flow":"xtls-rprx-direct",/"alterId":1,}"
if echo ${currentInstallProtocolType} | grep -q 1; then
local vlessUsers="${users//\,\"alterId\":0/}"
vlessUsers="${vlessUsers//\"flow\":\"xtls-rprx-direct\"\,/}"
local vlessWsResult
vlessWsResult=$(jq -r '.inbounds[0].settings.clients += ['${vlessUsers}']' ${configPath}03_VLESS_WS_inbounds.json)
vlessWsResult=$(jq -r ".inbounds[0].settings.clients += [${vlessUsers}]" ${configPath}03_VLESS_WS_inbounds.json)
echo "${vlessWsResult}" | jq . >${configPath}03_VLESS_WS_inbounds.json
fi
@ -2989,7 +2927,7 @@ addUser() {
trojangRPCUsers=${trojangRPCUsers//"id"/"password"}
local trojangRPCResult
trojangRPCResult=$(jq -r '.inbounds[0].settings.clients += ['${trojangRPCUsers}']' ${configPath}04_trojan_gRPC_inbounds.json)
trojangRPCResult=$(jq -r ".inbounds[0].settings.clients += [${trojangRPCUsers}]" ${configPath}04_trojan_gRPC_inbounds.json)
echo "${trojangRPCResult}" | jq . >${configPath}04_trojan_gRPC_inbounds.json
fi
@ -2997,7 +2935,7 @@ addUser() {
local vmessUsers="${users//\"flow\":\"xtls-rprx-direct\"\,/}"
local vmessWsResult
vmessWsResult=$(jq -r '.inbounds[0].settings.clients += ['${vmessUsers}']' ${configPath}05_VMess_WS_inbounds.json)
vmessWsResult=$(jq -r ".inbounds[0].settings.clients += [${vmessUsers}]" ${configPath}05_VMess_WS_inbounds.json)
echo "${vmessWsResult}" | jq . >${configPath}05_VMess_WS_inbounds.json
fi
@ -3006,7 +2944,7 @@ addUser() {
vlessGRPCUsers="${vlessGRPCUsers//\,\"alterId\":0/}"
local vlessGRPCResult
vlessGRPCResult=$(jq -r '.inbounds[0].settings.clients += ['${vlessGRPCUsers}']' ${configPath}06_VLESS_gRPC_inbounds.json)
vlessGRPCResult=$(jq -r ".inbounds[0].settings.clients += [${vlessGRPCUsers}]" ${configPath}06_VLESS_gRPC_inbounds.json)
echo "${vlessGRPCResult}" | jq . >${configPath}06_VLESS_gRPC_inbounds.json
fi
@ -3015,19 +2953,11 @@ addUser() {
trojanUsers="${trojanUsers//id/password}"
trojanUsers="${trojanUsers//\,\"alterId\":0/}"
local trojanTCPResult
trojanTCPResult=$(jq -r '.inbounds[0].settings.clients += ['${trojanUsers}']' ${configPath}04_trojan_TCP_inbounds.json)
trojanTCPResult=$(jq -r ".inbounds[0].settings.clients += [${trojanUsers}]" ${configPath}04_trojan_TCP_inbounds.json)
echo "${trojanTCPResult}" | jq . >${configPath}04_trojan_TCP_inbounds.json
fi
# if echo ${currentInstallProtocolType} | grep -q 4; then
# local trojanResult
# trojanResult=$(jq -r '.password += ['${trojanGoUsers}']' ${configPath}../../trojan/config_full.json)
# echo "${trojanResult}" | jq . >${configPath}../../trojan/config_full.json
# handleTrojanGo stop
# handleTrojanGo start
# fi
done
reloadCore
echoContent green " ---> 添加完成"
@ -3043,7 +2973,7 @@ removeUser() {
if [[ $(jq -r '.inbounds[0].settings.clients|length' ${configPath}${frontingType}.json) -lt ${delUserIndex} ]]; then
echoContent red " ---> 选择错误"
else
delUserIndex=$((${delUserIndex} - 1))
delUserIndex=$((delUserIndex - 1))
local vlessTcpResult
vlessTcpResult=$(jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}'])' ${configPath}${frontingType}.json)
echo "${vlessTcpResult}" | jq . >${configPath}${frontingType}.json
@ -3082,6 +3012,7 @@ removeUser() {
reloadCore
fi
manageAccount 1
}
# 更新脚本
updateV2RayAgent() {
@ -3094,13 +3025,14 @@ updateV2RayAgent() {
fi
sudo chmod 700 /etc/v2ray-agent/install.sh
local version=$(cat /etc/v2ray-agent/install.sh | grep '当前版本v' | awk -F "[v]" '{print $2}' | tail -n +2 | head -n 1 | awk -F "[\"]" '{print $1}')
local version
version=$(grep '当前版本v' "/etc/v2ray-agent/install.sh" | awk -F "[v]" '{print $2}' | tail -n +2 | head -n 1 | awk -F "[\"]" '{print $1}')
echoContent green "\n ---> 更新完毕"
echoContent yellow " ---> 请手动执行[vasma]打开脚本"
echoContent green " ---> 当前版本:${version}\n"
echoContent yellow "如更新不成功,请手动执行下面命令\n"
echoContent skyBlue "wget -P /root -N --no-check-certificate "https://raw.githubusercontent.com/mack-a/v2ray-agent/master/install.sh" && chmod 700 /root/install.sh && /root/install.sh"
echoContent skyBlue "wget -P /root -N --no-check-certificate https://raw.githubusercontent.com/mack-a/v2ray-agent/master/install.sh && chmod 700 /root/install.sh && /root/install.sh"
echo
exit 0
}
@ -3142,7 +3074,7 @@ checkLog() {
echoContent red " ---> 没有检测到安装目录,请执行脚本安装内容"
fi
local logStatus=false
if [[ -n $(cat ${configPath}00_log.json | grep access) ]]; then
if grep -q "access" ${configPath}00_log.json; then
logStatus=true
fi
@ -3213,7 +3145,7 @@ EOF
# 脚本快捷方式
aliasInstall() {
if [[ -f "$HOME/install.sh" ]] && [[ -d "/etc/v2ray-agent" ]] && grep <$HOME/install.sh -q "作者mack-a"; then
if [[ -f "$HOME/install.sh" ]] && [[ -d "/etc/v2ray-agent" ]] && grep <"$HOME/install.sh" -q "作者mack-a"; then
mv "$HOME/install.sh" /etc/v2ray-agent/install.sh
local vasmaType=
if [[ -d "/usr/bin/" ]]; then
@ -3271,18 +3203,18 @@ ipv6Routing() {
echoContent yellow "4.不允许有特殊字符,注意逗号的格式"
echoContent yellow "5.每次添加都是重新添加,不会保留上次域名"
echoContent yellow "6.录入示例:google,youtube,facebook\n"
read -r -p "请按照上面示例录入域名" domainList
read -r -p "请按照上面示例录入域名:" domainList
if [[ -f "${configPath}09_routing.json" ]]; then
unInstallRouting IPv6-out
routing=$(jq -r '.routing.rules += [{"type":"field","domain":["geosite:'${domainList//,/\",\"geosite:}'"],"outboundTag":"IPv6-out"}]' ${configPath}09_routing.json)
routing=$(jq -r ".routing.rules += [{\"type\":\"field\",\"domain\":[\"geosite:${domainList//,/\",\"geosite:}\"],\"outboundTag\":\"IPv6-out\"}]" ${configPath}09_routing.json)
echo "${routing}" | jq . >${configPath}09_routing.json
else
cat <<EOF >${configPath}09_routing.json
cat <<EOF >"${configPath}09_routing.json"
{
"routing":{
"domainStrategy": "IPOnDemand",
@ -3379,8 +3311,6 @@ fi
echo "${outbounds}" | jq . >${configPath}10_ipv4_outbounds.json
echoContent green " ---> BT下载禁用成功"
elif [[ "${btStatus}" == "2" ]]; then
@ -3405,11 +3335,12 @@ unInstallRouting(){
local tag=$1
if [[ -f "${configPath}09_routing.json" ]]; then
local routing=
local routing
if grep -q "${tag}" ${configPath}09_routing.json; then
local index=$(jq .routing.rules[].outboundTag ${configPath}09_routing.json|awk '{print ""NR""":"$0}'|grep "${tag}"|awk -F "[:]" '{print $1}'|head -1)
local index
index=$(jq .routing.rules[].outboundTag ${configPath}09_routing.json | awk '{print ""NR""":"$0}' | grep "${tag}" | awk -F "[:]" '{print $1}' | head -1)
if [[ ${index} -gt 0 ]]; then
routing=$(jq -r 'del(.routing.rules['$(expr ${index} - 1)'])' ${configPath}09_routing.json)
routing=$(jq -r 'del(.routing.rules['"$(("${index}" - 1))"'])' ${configPath}09_routing.json)
echo "${routing}" | jq . >${configPath}09_routing.json
fi
fi
@ -3421,9 +3352,10 @@ unInstallOutbounds(){
local tag=$1
if grep -q "${tag}" ${configPath}10_ipv4_outbounds.json; then
local ipv6OutIndex=$(jq .outbounds[].tag ${configPath}10_ipv4_outbounds.json|awk '{print ""NR""":"$0}'|grep "${tag}"|awk -F "[:]" '{print $1}'|head -1)
local ipv6OutIndex
ipv6OutIndex=$(jq .outbounds[].tag ${configPath}10_ipv4_outbounds.json | awk '{print ""NR""":"$0}' | grep "${tag}" | awk -F "[:]" '{print $1}' | head -1)
if [[ ${ipv6OutIndex} -gt 0 ]]; then
routing=$(jq -r 'del(.outbounds['$(expr ${ipv6OutIndex} - 1)'])' ${configPath}10_ipv4_outbounds.json)
routing=$(jq -r 'del(.outbounds['$(("${ipv6OutIndex}" - 1))'])' ${configPath}10_ipv4_outbounds.json)
echo "${routing}" | jq . >${configPath}10_ipv4_outbounds.json
fi
fi
@ -3432,17 +3364,19 @@ unInstallOutbounds(){
# 卸载嗅探
unInstallSniffing() {
ls ${configPath}|grep inbounds.json|while read -r inbound;do
sniffing=$(jq -r 'del(.inbounds[0].sniffing)' ${configPath}${inbound})
echo "${sniffing}" |jq . >${configPath}${inbound}
find ${configPath} -name "*inbounds.json*" | awk -F "[c][o][n][f][/]" '{print $2}' | while read -r inbound; do
sniffing=$(jq -r 'del(.inbounds[0].sniffing)' "${configPath}${inbound}")
echo "${sniffing}" | jq . >"${configPath}${inbound}"
done
}
# 安装嗅探
installSniffing() {
ls ${configPath}|grep inbounds.json|while read -r inbound;do
sniffing=$(jq -r '.inbounds[0].sniffing = {"enabled":true,"destOverride":["http","tls"]}' ${configPath}${inbound})
echo "${sniffing}" |jq . >${configPath}${inbound}
find ${configPath} -name "*inbounds.json*" | awk -F "[c][o][n][f][/]" '{print $2}' | while read -r inbound; do
sniffing=$(jq -r '.inbounds[0].sniffing = {"enabled":true,"destOverride":["http","tls"]}' "${configPath}${inbound}")
echo "${sniffing}" | jq . >"${configPath}${inbound}"
done
}
@ -3482,12 +3416,12 @@ warpRouting(){
echoContent yellow "5.不允许有特殊字符,注意逗号的格式"
echoContent yellow "6.每次添加都是重新添加,不会保留上次域名"
echoContent yellow "7.录入示例:google,youtube,facebook\n"
read -r -p "请按照上面示例录入域名" domainList
read -r -p "请按照上面示例录入域名:" domainList
if [[ -f "${configPath}09_routing.json" ]]; then
unInstallRouting warp-socks-out
routing=$(jq -r '.routing.rules += [{"type":"field","domain":["geosite:'${domainList//,/\",\"geosite:}'"],"outboundTag":"warp-socks-out"}]' ${configPath}09_routing.json)
routing=$(jq -r ".routing.rules += [{\"type\":\"field\",\"domain\":[\"geosite:${domainList//,/\",\"geosite:}\"],\"outboundTag\":\"warp-socks-out\"}]" ${configPath}09_routing.json)
echo "${routing}" | jq . >${configPath}09_routing.json
@ -3511,7 +3445,8 @@ EOF
fi
unInstallOutbounds warp-socks-out
local outbounds=$(jq -r '.outbounds += [{"protocol":"socks","settings":{"servers":[{"address":"127.0.0.1","port":31303}]},"tag":"warp-socks-out"}]' ${configPath}10_ipv4_outbounds.json)
local outbounds
outbounds=$(jq -r '.outbounds += [{"protocol":"socks","settings":{"servers":[{"address":"127.0.0.1","port":31303}]},"tag":"warp-socks-out"}]' ${configPath}10_ipv4_outbounds.json)
echo "${outbounds}" | jq . >${configPath}10_ipv4_outbounds.json
@ -3588,7 +3523,7 @@ setDokodemoDoorUnblockNetflixOutbounds() {
unInstallOutbounds netflix-80
unInstallOutbounds netflix-443
outbounds=$(jq -r '.outbounds += [{"tag":"netflix-80","protocol":"freedom","settings":{"domainStrategy":"AsIs","redirect":"'${setIP}':22387"}},{"tag":"netflix-443","protocol":"freedom","settings":{"domainStrategy":"AsIs","redirect":"'${setIP}':22388"}}]' ${configPath}10_ipv4_outbounds.json)
outbounds=$(jq -r ".outbounds += [{\"tag\":\"netflix-80\",\"protocol\":\"freedom\",\"settings\":{\"domainStrategy\":\"AsIs\",\"redirect\":\"${setIP}:22387\"}},{\"tag\":\"netflix-443\",\"protocol\":\"freedom\",\"settings\":{\"domainStrategy\":\"AsIs\",\"redirect\":\"${setIP}:22388\"}}]" ${configPath}10_ipv4_outbounds.json)
echo "${outbounds}" | jq . >${configPath}10_ipv4_outbounds.json
@ -3596,7 +3531,8 @@ setDokodemoDoorUnblockNetflixOutbounds() {
unInstallRouting netflix-80
unInstallRouting netflix-443
local routing=$(jq -r '.routing.rules += [{"type":"field","port":80,"domain":["ip.sb","geosite:netflix"],"outboundTag":"netflix-80"},{"type":"field","port":443,"domain":["ip.sb","geosite:netflix"],"outboundTag":"netflix-443"}]' ${configPath}09_routing.json)
local routing
routing=$(jq -r '.routing.rules += [{"type":"field","port":80,"domain":["ip.sb","geosite:netflix"],"outboundTag":"netflix-80"},{"type":"field","port":443,"domain":["ip.sb","geosite:netflix"],"outboundTag":"netflix-443"}]' ${configPath}09_routing.json)
echo "${routing}" | jq . >${configPath}09_routing.json
else
cat <<EOF >${configPath}09_routing.json
@ -3742,17 +3678,20 @@ EOF
}
}
EOF
local ips=
while read -r ip; do
if [[ -z ${ips} ]];then
ips=\"${ip}\"
else
ips=${ips},\"${ip}\"
fi
done< <(echo ${setIPs}|tr ',' '\n')
local routing=$(jq -r '.routing.rules[0].source += ['${ips}']' ${configPath}09_routing.json)
oldIFS="${IFS}"
IFS=","
# shellcheck disable=SC2206
sourceIPs=(${setIPs})
IFS="${oldIFS}"
local routing
for value in "${sourceIPs[@]}"; do
routing=$(jq -r ".routing.rules[0].source += [\"${value}\"]" ${configPath}09_routing.json)
echo "${routing}" | jq . >${configPath}09_routing.json
done
reloadCore
echoContent green " ---> 添加落地机入站解锁Netflix成功"
exit 0
@ -4161,9 +4100,11 @@ subscribe() {
mv /etc/v2ray-agent/subscribe_tmp/* /etc/v2ray-agent/subscribe/
if [[ -n $(ls /etc/v2ray-agent/subscribe) ]]; then
ls /etc/v2ray-agent/subscribe | while read -r email; do
local base64Result=$(base64 -w 0 /etc/v2ray-agent/subscribe/${email})
echo ${base64Result} >"/etc/v2ray-agent/subscribe/${email}"
find /etc/v2ray-agent/subscribe | while read -r email; do
email=$(echo "${email}" | awk -F "[s][u][b][s][c][r][i][b][e][/]" '{print $2}')
local base64Result
base64Result=$(base64 -w 0 "/etc/v2ray-agent/subscribe/${email}")
echo "${base64Result}" >"/etc/v2ray-agent/subscribe/${email}"
echoContent skyBlue "--------------------------------------------------------------"
echoContent yellow "email$(echo "${email}" | awk -F "[_]" '{print $1}')\n"
echoContent yellow "urlhttps://${currentHost}/s/${email}\n"
@ -4182,7 +4123,7 @@ menu() {
cd "$HOME" || exit
echoContent red "\n=============================================================="
echoContent green "作者mack-a"
echoContent green "当前版本v2.5.28"
echoContent green "当前版本v2.5.29"
echoContent green "Githubhttps://github.com/mack-a/v2ray-agent"
echoContent green "描述:八合一共存脚本\c"
showInstallStatus

View File

@ -178,10 +178,10 @@ initVar() {
pingIPv6=
localIP=
# 集成更新证书逻辑不再使用单独的脚本--RenewTLS
# Integrated Update Certificate Logic No longer use separate scripts--RenewTLS
renewTLS=$1
# tls安装失败后尝试的次数
# Number of attempts after a failed tls installation
installTLSCount=
}
@ -648,7 +648,7 @@ initTLSNginxConfig() {
echoContent red " Domain name--->"
initTLSNginxConfig
else
# 修改配置
# update config
touch /etc/nginx/conf.d/alone.conf
cat <<EOF >/etc/nginx/conf.d/alone.conf
server {
@ -672,7 +672,7 @@ server {
}
}
EOF
# 启动nginx
# start nginx
handleNginx start
checkIP
fi
@ -1386,7 +1386,7 @@ updateXray() {
fi
}
# 验证整个服务是否可用
# Verify that the entire service is available
checkGFWStatue() {
readInstallType
echoContent skyBlue "\n progress $1/${totalProgress} : Verify service startup status"
@ -1907,7 +1907,7 @@ EOF
fi
}
# initializationXray Trojan XTLS 配置文件
# initializationXray Trojan XTLS config
initXrayFrontingConfig(){
if [[ -z "${configPath}" ]]; then
echoContent red " ---> Not installed, please use the script installation"
@ -3130,7 +3130,7 @@ handleFirewall(){
fi
}
# 安装BBR
# install BBR
bbrInstall() {
echoContent red "\n=============================================================="
echoContent green "BBR、DDMature works for [YLX2016] with scripts, address [https://github.com/ylx2016/linux-netspeed], please be familiar"
@ -3464,7 +3464,7 @@ warpRouting(){
echoContent yellow "2.It can be used normally without rebooting the machine, if you have to use the official warp, it is recommended not to reboot the machine"
echoContent yellow "3.Some machines still work normally after reboot"
echoContent yellow "4.Uninstall and reinstall if you can't use it after reboot"
# 安装warp
# Install WARP
if [[ -z $(which warp-cli) ]];then
echo
read -r -p "WARP not installed, installed or not [y/n]:" installCloudflareWarpStatus
@ -3480,7 +3480,7 @@ warpRouting(){
echoContent yellow "1.Add Domain"
echoContent yellow "2.Uninstall the WARP diversion"
echoContent red "=============================================================="
read -r -p "请选择:" warpStatus
read -r -p "please choose:" warpStatus
if [[ "${warpStatus}" == "1" ]]; then
echoContent red "=============================================================="
echoContent yellow "# Cautions\n"
@ -3534,9 +3534,9 @@ EOF
unInstallOutbounds warp-socks-out
echoContent green " ---> WARP分流卸载成功"
echoContent green " ---> WARP shunt uninstall success"
else
echoContent red " ---> 选择错误"
echoContent red " ---> wrong selection"
exit 0
fi
reloadCore