mirror of https://github.com/mack-a/v2ray-agent
feat(脚本): 添加sing-box替换Tuic
parent
72bd755de7
commit
d845585fa2
634
install.sh
634
install.sh
|
@ -95,6 +95,7 @@ checkCPUVendor() {
|
||||||
hysteriaCoreCPUVendor="hysteria-linux-amd64"
|
hysteriaCoreCPUVendor="hysteria-linux-amd64"
|
||||||
tuicCoreCPUVendor="-x86_64-unknown-linux-musl"
|
tuicCoreCPUVendor="-x86_64-unknown-linux-musl"
|
||||||
warpRegCoreCPUVendor="main-linux-amd64"
|
warpRegCoreCPUVendor="main-linux-amd64"
|
||||||
|
singBoxCoreCPUVendor="-linux-amd64"
|
||||||
;;
|
;;
|
||||||
'armv8' | 'aarch64')
|
'armv8' | 'aarch64')
|
||||||
cpuVendor="arm"
|
cpuVendor="arm"
|
||||||
|
@ -103,6 +104,7 @@ checkCPUVendor() {
|
||||||
hysteriaCoreCPUVendor="hysteria-linux-arm64"
|
hysteriaCoreCPUVendor="hysteria-linux-arm64"
|
||||||
tuicCoreCPUVendor="-aarch64-unknown-linux-musl"
|
tuicCoreCPUVendor="-aarch64-unknown-linux-musl"
|
||||||
warpRegCoreCPUVendor="main-linux-arm64"
|
warpRegCoreCPUVendor="main-linux-arm64"
|
||||||
|
singBoxCoreCPUVendor="-linux-arm64"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
echo " 不支持此CPU架构--->"
|
echo " 不支持此CPU架构--->"
|
||||||
|
@ -174,6 +176,9 @@ initVar() {
|
||||||
|
|
||||||
# hysteria 配置文件的路径
|
# hysteria 配置文件的路径
|
||||||
hysteriaConfigPath=
|
hysteriaConfigPath=
|
||||||
|
|
||||||
|
# sing-box配置文件路径
|
||||||
|
singBoxConfigPath=
|
||||||
# interfaceName=
|
# interfaceName=
|
||||||
# 端口跳跃
|
# 端口跳跃
|
||||||
portHoppingStart=
|
portHoppingStart=
|
||||||
|
@ -312,20 +317,19 @@ readCustomPort() {
|
||||||
readInstallType() {
|
readInstallType() {
|
||||||
coreInstallType=
|
coreInstallType=
|
||||||
configPath=
|
configPath=
|
||||||
hysteriaConfigPath=
|
|
||||||
|
|
||||||
# 1.检测安装目录
|
# 1.检测安装目录
|
||||||
if [[ -d "/etc/v2ray-agent" ]]; then
|
if [[ -d "/etc/v2ray-agent" ]]; then
|
||||||
# 检测安装方式 v2ray-core
|
# 检测安装方式 v2ray-core
|
||||||
if [[ -d "/etc/v2ray-agent/v2ray" && -f "/etc/v2ray-agent/v2ray/v2ray" && -f "/etc/v2ray-agent/v2ray/v2ctl" ]]; then
|
# if [[ -d "/etc/v2ray-agent/v2ray" && -f "/etc/v2ray-agent/v2ray/v2ray" && -f "/etc/v2ray-agent/v2ray/v2ctl" ]]; then
|
||||||
if [[ -d "/etc/v2ray-agent/v2ray/conf" && -f "/etc/v2ray-agent/v2ray/conf/02_VLESS_TCP_inbounds.json" ]]; then
|
# if [[ -d "/etc/v2ray-agent/v2ray/conf" && -f "/etc/v2ray-agent/v2ray/conf/02_VLESS_TCP_inbounds.json" ]]; then
|
||||||
configPath=/etc/v2ray-agent/v2ray/conf/
|
# configPath=/etc/v2ray-agent/v2ray/conf/
|
||||||
if grep </etc/v2ray-agent/v2ray/conf/02_VLESS_TCP_inbounds.json -q '"security": "tls"'; then
|
# if grep </etc/v2ray-agent/v2ray/conf/02_VLESS_TCP_inbounds.json -q '"security": "tls"'; then
|
||||||
coreInstallType=2
|
# coreInstallType=2
|
||||||
ctlPath=/etc/v2ray-agent/v2ray/v2ctl
|
# ctlPath=/etc/v2ray-agent/v2ray/v2ctl
|
||||||
fi
|
# fi
|
||||||
fi
|
# fi
|
||||||
fi
|
# fi
|
||||||
|
|
||||||
if [[ -d "/etc/v2ray-agent/xray" && -f "/etc/v2ray-agent/xray/xray" ]]; then
|
if [[ -d "/etc/v2ray-agent/xray" && -f "/etc/v2ray-agent/xray/xray" ]]; then
|
||||||
# 这里检测xray-core
|
# 这里检测xray-core
|
||||||
|
@ -345,10 +349,16 @@ readInstallType() {
|
||||||
hysteriaConfigPath=/etc/v2ray-agent/hysteria/conf/
|
hysteriaConfigPath=/etc/v2ray-agent/hysteria/conf/
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
#
|
||||||
|
# if [[ -d "/etc/v2ray-agent/tuic" && -f "/etc/v2ray-agent/tuic/tuic" ]]; then
|
||||||
|
# if [[ -d "/etc/v2ray-agent/tuic/conf" ]] && [[ -f "/etc/v2ray-agent/tuic/conf/config.json" ]]; then
|
||||||
|
# tuicConfigPath=/etc/v2ray-agent/tuic/conf/
|
||||||
|
# fi
|
||||||
|
# fi
|
||||||
|
|
||||||
if [[ -d "/etc/v2ray-agent/tuic" && -f "/etc/v2ray-agent/tuic/tuic" ]]; then
|
if [[ -d "/etc/v2ray-agent/sing-box" && -f "/etc/v2ray-agent/sing-box/sing-box" ]]; then
|
||||||
if [[ -d "/etc/v2ray-agent/tuic/conf" ]] && [[ -f "/etc/v2ray-agent/tuic/conf/config.json" ]]; then
|
if [[ -d "/etc/v2ray-agent/sing-box/conf" ]] && [[ -f "/etc/v2ray-agent/sing-box/conf/config.json" ]]; then
|
||||||
tuicConfigPath=/etc/v2ray-agent/tuic/conf/
|
singBoxConfigPath=/etc/v2ray-agent/sing-box/conf/
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -393,9 +403,11 @@ readInstallProtocolType() {
|
||||||
done < <(find ${configPath} -name "*inbounds.json" | awk -F "[.]" '{print $1}')
|
done < <(find ${configPath} -name "*inbounds.json" | awk -F "[.]" '{print $1}')
|
||||||
|
|
||||||
if [[ -n "${hysteriaConfigPath}" ]]; then
|
if [[ -n "${hysteriaConfigPath}" ]]; then
|
||||||
|
# if [[ -n "${singBoxConfigPath}" ]] && [[ -f "/etc/v2ray-agent/sing-box/conf/config.json" ]] && grep -q 'hysteria' </etc/v2ray-agent/sing-box/conf/config.json; then
|
||||||
currentInstallProtocolType=${currentInstallProtocolType}'6'
|
currentInstallProtocolType=${currentInstallProtocolType}'6'
|
||||||
fi
|
fi
|
||||||
if [[ -n "${tuicConfigPath}" ]]; then
|
# if [[ -n "${tuicConfigPath}" ]]; then
|
||||||
|
if [[ -n "${singBoxConfigPath}" ]] && [[ -f "/etc/v2ray-agent/sing-box/conf/config.json" ]] && grep -q 'tuic' </etc/v2ray-agent/sing-box/conf/config.json; then
|
||||||
currentInstallProtocolType=${currentInstallProtocolType}'9'
|
currentInstallProtocolType=${currentInstallProtocolType}'9'
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
@ -547,9 +559,11 @@ readHysteriaConfig() {
|
||||||
}
|
}
|
||||||
# 读取Tuic配置
|
# 读取Tuic配置
|
||||||
readTuicConfig() {
|
readTuicConfig() {
|
||||||
if [[ -n "${tuicConfigPath}" ]]; then
|
# if [[ -n "${tuicConfigPath}" ]]; then
|
||||||
tuicPort=$(jq -r .server <"${tuicConfigPath}config.json" | cut -d ':' -f 4)
|
if [[ -n "${singBoxConfigPath}" ]] && [[ -f "/etc/v2ray-agent/sing-box/conf/config.json" ]] && grep -q 'tuic' </etc/v2ray-agent/sing-box/conf/config.json; then
|
||||||
tuicAlgorithm=$(jq -r .congestion_control <"${tuicConfigPath}config.json")
|
singBoxConfigPath=/etc/v2ray-agent/sing-box/conf/
|
||||||
|
tuicPort=$(jq -r '.inbounds[]|select(.type=="tuic")|(.listen_port)' <"${singBoxConfigPath}config.json")
|
||||||
|
tuicAlgorithm=$(jq -r '.inbounds[]|select(.type=="tuic")|(.congestion_control)' <"${singBoxConfigPath}config.json")
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
# 读取xray reality配置
|
# 读取xray reality配置
|
||||||
|
@ -715,11 +729,12 @@ showInstallStatus() {
|
||||||
|
|
||||||
# 清理旧残留
|
# 清理旧残留
|
||||||
cleanUp() {
|
cleanUp() {
|
||||||
if [[ "$1" == "v2rayClean" ]]; then
|
# if [[ "$1" == "v2rayClean" ]]; then
|
||||||
rm -rf "$(find /etc/v2ray-agent/v2ray/* | grep -E '(config_full.json|conf)')"
|
# rm -rf "$(find /etc/v2ray-agent/v2ray/* | grep -E '(config_full.json|conf)')"
|
||||||
handleV2Ray stop >/dev/null
|
# handleV2Ray stop >/dev/null
|
||||||
rm -f /etc/systemd/system/v2ray.service
|
# rm -f /etc/systemd/system/v2ray.service
|
||||||
elif [[ "$1" == "xrayClean" ]]; then
|
# el
|
||||||
|
if [[ "$1" == "xrayClean" ]]; then
|
||||||
rm -rf "$(find /etc/v2ray-agent/xray/* | grep -E '(config_full.json|conf)')"
|
rm -rf "$(find /etc/v2ray-agent/xray/* | grep -E '(config_full.json|conf)')"
|
||||||
handleXray stop >/dev/null
|
handleXray stop >/dev/null
|
||||||
rm -f /etc/systemd/system/xray.service
|
rm -f /etc/systemd/system/xray.service
|
||||||
|
@ -766,6 +781,8 @@ mkdirTools() {
|
||||||
mkdir -p /etc/v2ray-agent/warp
|
mkdir -p /etc/v2ray-agent/warp
|
||||||
|
|
||||||
mkdir -p /etc/v2ray-agent/tuic/conf
|
mkdir -p /etc/v2ray-agent/tuic/conf
|
||||||
|
|
||||||
|
mkdir -p /etc/v2ray-agent/sing-box/conf/config
|
||||||
}
|
}
|
||||||
|
|
||||||
# 安装工具包
|
# 安装工具包
|
||||||
|
@ -1919,6 +1936,36 @@ installHysteria() {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 安装 sing-box
|
||||||
|
installSingBox() {
|
||||||
|
readInstallType
|
||||||
|
echoContent skyBlue "\n进度 $1/${totalProgress} : 安装sing-box"
|
||||||
|
|
||||||
|
if [[ -z "${singBoxConfigPath}" ]]; then
|
||||||
|
|
||||||
|
version=$(curl -s "https://api.github.com/repos/SagerNet/sing-box/releases?per_page=10" | jq -r ".[]|select (.prerelease==${prereleaseStatus})|.tag_name" | head -1)
|
||||||
|
|
||||||
|
echoContent green " ---> sing-box版本:${version}"
|
||||||
|
|
||||||
|
wget -c -q "${wgetShowProgressStatus}" -P /etc/v2ray-agent/sing-box/ "https://github.com/SagerNet/sing-box/releases/download/${version}/sing-box-${version/v/}-linux-amd64.tar.gz"
|
||||||
|
|
||||||
|
tar zxvf "/etc/v2ray-agent/sing-box/sing-box-${version/v/}${singBoxCoreCPUVendor}.tar.gz" -C "/etc/v2ray-agent/sing-box/" >/dev/null 2>&1
|
||||||
|
|
||||||
|
mv "/etc/v2ray-agent/sing-box/sing-box-${version/v/}${singBoxCoreCPUVendor}/sing-box" /etc/v2ray-agent/sing-box/sing-box
|
||||||
|
# rm -rf /etc/v2ray-agent/sing-box/sing-box-*
|
||||||
|
chmod 655 /etc/v2ray-agent/sing-box/sing-box
|
||||||
|
|
||||||
|
else
|
||||||
|
echoContent green " ---> sing-box版本:v$(/etc/v2ray-agent/sing-box/sing-box version | grep "sing-box version" | awk '{print $3}')"
|
||||||
|
read -r -p "是否更新、升级?[y/n]:" reInstallSingBoxStatus
|
||||||
|
if [[ "${reInstallSingBoxStatus}" == "y" ]]; then
|
||||||
|
rm -f /etc/v2ray-agent/sing-box/sing-box
|
||||||
|
installSingBox "$1"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
# 安装 tuic
|
# 安装 tuic
|
||||||
installTuic() {
|
installTuic() {
|
||||||
readInstallType
|
readInstallType
|
||||||
|
@ -2265,40 +2312,40 @@ checkGFWStatue() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# V2Ray开机自启
|
# V2Ray开机自启
|
||||||
installV2RayService() {
|
#installV2RayService() {
|
||||||
echoContent skyBlue "\n进度 $1/${totalProgress} : 配置V2Ray开机自启"
|
# echoContent skyBlue "\n进度 $1/${totalProgress} : 配置V2Ray开机自启"
|
||||||
if [[ -n $(find /bin /usr/bin -name "systemctl") ]]; then
|
# if [[ -n $(find /bin /usr/bin -name "systemctl") ]]; then
|
||||||
rm -rf /etc/systemd/system/v2ray.service
|
# rm -rf /etc/systemd/system/v2ray.service
|
||||||
touch /etc/systemd/system/v2ray.service
|
# touch /etc/systemd/system/v2ray.service
|
||||||
execStart='/etc/v2ray-agent/v2ray/v2ray -confdir /etc/v2ray-agent/v2ray/conf'
|
# execStart='/etc/v2ray-agent/v2ray/v2ray -confdir /etc/v2ray-agent/v2ray/conf'
|
||||||
cat <<EOF >/etc/systemd/system/v2ray.service
|
# cat <<EOF >/etc/systemd/system/v2ray.service
|
||||||
[Unit]
|
#[Unit]
|
||||||
Description=V2Ray - A unified platform for anti-censorship
|
#Description=V2Ray - A unified platform for anti-censorship
|
||||||
Documentation=https://v2ray.com https://guide.v2fly.org
|
#Documentation=https://v2ray.com https://guide.v2fly.org
|
||||||
After=network.target nss-lookup.target
|
#After=network.target nss-lookup.target
|
||||||
Wants=network-online.target
|
#Wants=network-online.target
|
||||||
|
#
|
||||||
|
#[Service]
|
||||||
|
#Type=simple
|
||||||
|
#User=root
|
||||||
|
#CapabilityBoundingSet=CAP_NET_BIND_SERVICE CAP_NET_RAW
|
||||||
|
#NoNewPrivileges=yes
|
||||||
|
#ExecStart=${execStart}
|
||||||
|
#Restart=on-failure
|
||||||
|
#RestartPreventExitStatus=23
|
||||||
|
#LimitNPROC=10000
|
||||||
|
#LimitNOFILE=1000000
|
||||||
|
#
|
||||||
|
#[Install]
|
||||||
|
#WantedBy=multi-user.target
|
||||||
|
#EOF
|
||||||
|
# systemctl daemon-reload
|
||||||
|
# systemctl enable v2ray.service
|
||||||
|
# echoContent green " ---> 配置V2Ray开机自启成功"
|
||||||
|
# fi
|
||||||
|
#}
|
||||||
|
|
||||||
[Service]
|
安装hysteria开机自启
|
||||||
Type=simple
|
|
||||||
User=root
|
|
||||||
CapabilityBoundingSet=CAP_NET_BIND_SERVICE CAP_NET_RAW
|
|
||||||
NoNewPrivileges=yes
|
|
||||||
ExecStart=${execStart}
|
|
||||||
Restart=on-failure
|
|
||||||
RestartPreventExitStatus=23
|
|
||||||
LimitNPROC=10000
|
|
||||||
LimitNOFILE=1000000
|
|
||||||
|
|
||||||
[Install]
|
|
||||||
WantedBy=multi-user.target
|
|
||||||
EOF
|
|
||||||
systemctl daemon-reload
|
|
||||||
systemctl enable v2ray.service
|
|
||||||
echoContent green " ---> 配置V2Ray开机自启成功"
|
|
||||||
fi
|
|
||||||
}
|
|
||||||
|
|
||||||
# 安装hysteria开机自启
|
|
||||||
installHysteriaService() {
|
installHysteriaService() {
|
||||||
echoContent skyBlue "\n进度 $1/${totalProgress} : 配置Hysteria开机自启"
|
echoContent skyBlue "\n进度 $1/${totalProgress} : 配置Hysteria开机自启"
|
||||||
if [[ -n $(find /bin /usr/bin -name "systemctl") ]]; then
|
if [[ -n $(find /bin /usr/bin -name "systemctl") ]]; then
|
||||||
|
@ -2328,33 +2375,67 @@ EOF
|
||||||
echoContent green " ---> 配置Hysteria开机自启成功"
|
echoContent green " ---> 配置Hysteria开机自启成功"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# 安装Tuic开机自启动
|
# 安装Tuic开机自启动
|
||||||
installTuicService() {
|
#installTuicService() {
|
||||||
echoContent skyBlue "\n进度 $1/${totalProgress} : 配置Tuic开机自启"
|
# echoContent skyBlue "\n进度 $1/${totalProgress} : 配置Tuic开机自启"
|
||||||
|
# if [[ -n $(find /bin /usr/bin -name "systemctl") ]]; then
|
||||||
|
# rm -rf /etc/systemd/system/tuic.service
|
||||||
|
# touch /etc/systemd/system/tuic.service
|
||||||
|
# execStart='/etc/v2ray-agent/tuic/tuic -c /etc/v2ray-agent/tuic/conf/config.json'
|
||||||
|
# cat <<EOF >/etc/systemd/system/tuic.service
|
||||||
|
#[Unit]
|
||||||
|
#Description=Tuic Service
|
||||||
|
#Documentation=https://github.com/EAimTY
|
||||||
|
#After=network.target nss-lookup.target
|
||||||
|
#[Service]
|
||||||
|
#User=root
|
||||||
|
#ExecStart=${execStart}
|
||||||
|
#Restart=on-failure
|
||||||
|
#RestartPreventExitStatus=23
|
||||||
|
#LimitNPROC=10000
|
||||||
|
#LimitNOFILE=1000000
|
||||||
|
#[Install]
|
||||||
|
#WantedBy=multi-user.target
|
||||||
|
#EOF
|
||||||
|
# systemctl daemon-reload
|
||||||
|
# systemctl enable tuic.service
|
||||||
|
# echoContent green " ---> 配置Tuic开机自启成功"
|
||||||
|
# fi
|
||||||
|
#}
|
||||||
|
|
||||||
|
# sing-box 自启动
|
||||||
|
installSingBoxService() {
|
||||||
|
echoContent skyBlue "\n进度 $1/${totalProgress} : 配置sing-box开机自启"
|
||||||
if [[ -n $(find /bin /usr/bin -name "systemctl") ]]; then
|
if [[ -n $(find /bin /usr/bin -name "systemctl") ]]; then
|
||||||
rm -rf /etc/systemd/system/tuic.service
|
rm -rf /etc/systemd/system/sing-box.service
|
||||||
touch /etc/systemd/system/tuic.service
|
touch /etc/systemd/system/sing-box.service
|
||||||
execStart='/etc/v2ray-agent/tuic/tuic -c /etc/v2ray-agent/tuic/conf/config.json'
|
execStart='/etc/v2ray-agent/sing-box/sing-box run -c /etc/v2ray-agent/sing-box/conf/config.json'
|
||||||
cat <<EOF >/etc/systemd/system/tuic.service
|
cat <<EOF >/etc/systemd/system/sing-box.service
|
||||||
[Unit]
|
[Unit]
|
||||||
Description=Tuic Service
|
|
||||||
Documentation=https://github.com/EAimTY
|
|
||||||
After=network.target nss-lookup.target
|
After=network.target nss-lookup.target
|
||||||
|
|
||||||
[Service]
|
[Service]
|
||||||
User=root
|
User=root
|
||||||
|
WorkingDirectory=/root
|
||||||
|
CapabilityBoundingSet=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_SYS_PTRACE CAP_DAC_READ_SEARCH
|
||||||
|
AmbientCapabilities=CAP_NET_ADMIN CAP_NET_BIND_SERVICE CAP_SYS_PTRACE CAP_DAC_READ_SEARCH
|
||||||
ExecStart=${execStart}
|
ExecStart=${execStart}
|
||||||
|
ExecReload=/bin/kill -HUP $MAINPID
|
||||||
Restart=on-failure
|
Restart=on-failure
|
||||||
RestartPreventExitStatus=23
|
RestartSec=10
|
||||||
LimitNPROC=10000
|
LimitNPROC=512
|
||||||
LimitNOFILE=1000000
|
LimitNOFILE=infinity
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
WantedBy=multi-user.target
|
WantedBy=multi-user.target
|
||||||
EOF
|
EOF
|
||||||
systemctl daemon-reload
|
systemctl daemon-reload
|
||||||
systemctl enable tuic.service
|
systemctl enable sing-box.service
|
||||||
echoContent green " ---> 配置Tuic开机自启成功"
|
echoContent green " ---> 配置sing-box开机自启成功"
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# Xray开机自启
|
# Xray开机自启
|
||||||
installXrayService() {
|
installXrayService() {
|
||||||
echoContent skyBlue "\n进度 $1/${totalProgress} : 配置Xray开机自启"
|
echoContent skyBlue "\n进度 $1/${totalProgress} : 配置Xray开机自启"
|
||||||
|
@ -2384,35 +2465,35 @@ EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
# 操作V2Ray
|
# 操作V2Ray
|
||||||
handleV2Ray() {
|
#handleV2Ray() {
|
||||||
# shellcheck disable=SC2010
|
# # shellcheck disable=SC2010
|
||||||
if find /bin /usr/bin | grep -q systemctl && ls /etc/systemd/system/ | grep -q v2ray.service; then
|
# if find /bin /usr/bin | grep -q systemctl && ls /etc/systemd/system/ | grep -q v2ray.service; then
|
||||||
if [[ -z $(pgrep -f "v2ray/v2ray") ]] && [[ "$1" == "start" ]]; then
|
# if [[ -z $(pgrep -f "v2ray/v2ray") ]] && [[ "$1" == "start" ]]; then
|
||||||
systemctl start v2ray.service
|
# systemctl start v2ray.service
|
||||||
elif [[ -n $(pgrep -f "v2ray/v2ray") ]] && [[ "$1" == "stop" ]]; then
|
# elif [[ -n $(pgrep -f "v2ray/v2ray") ]] && [[ "$1" == "stop" ]]; then
|
||||||
systemctl stop v2ray.service
|
# systemctl stop v2ray.service
|
||||||
fi
|
# fi
|
||||||
fi
|
# fi
|
||||||
sleep 0.8
|
# sleep 0.8
|
||||||
|
#
|
||||||
if [[ "$1" == "start" ]]; then
|
# if [[ "$1" == "start" ]]; then
|
||||||
if [[ -n $(pgrep -f "v2ray/v2ray") ]]; then
|
# if [[ -n $(pgrep -f "v2ray/v2ray") ]]; then
|
||||||
echoContent green " ---> V2Ray启动成功"
|
# echoContent green " ---> V2Ray启动成功"
|
||||||
else
|
# else
|
||||||
echoContent red "V2Ray启动失败"
|
# echoContent red "V2Ray启动失败"
|
||||||
echoContent red "请手动执行【/etc/v2ray-agent/v2ray/v2ray -confdir /etc/v2ray-agent/v2ray/conf】,查看错误日志"
|
# echoContent red "请手动执行【/etc/v2ray-agent/v2ray/v2ray -confdir /etc/v2ray-agent/v2ray/conf】,查看错误日志"
|
||||||
exit 0
|
# exit 0
|
||||||
fi
|
# fi
|
||||||
elif [[ "$1" == "stop" ]]; then
|
# elif [[ "$1" == "stop" ]]; then
|
||||||
if [[ -z $(pgrep -f "v2ray/v2ray") ]]; then
|
# if [[ -z $(pgrep -f "v2ray/v2ray") ]]; then
|
||||||
echoContent green " ---> V2Ray关闭成功"
|
# echoContent green " ---> V2Ray关闭成功"
|
||||||
else
|
# else
|
||||||
echoContent red "V2Ray关闭失败"
|
# echoContent red "V2Ray关闭失败"
|
||||||
echoContent red "请手动执行【ps -ef|grep -v grep|grep v2ray|awk '{print \$2}'|xargs kill -9】"
|
# echoContent red "请手动执行【ps -ef|grep -v grep|grep v2ray|awk '{print \$2}'|xargs kill -9】"
|
||||||
exit 0
|
# exit 0
|
||||||
fi
|
# fi
|
||||||
fi
|
# fi
|
||||||
}
|
#}
|
||||||
|
|
||||||
# 操作Hysteria
|
# 操作Hysteria
|
||||||
handleHysteria() {
|
handleHysteria() {
|
||||||
|
@ -2444,36 +2525,69 @@ handleHysteria() {
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# 操作Tuic
|
# 操作Tuic
|
||||||
handleTuic() {
|
#handleTuic() {
|
||||||
|
# # shellcheck disable=SC2010
|
||||||
|
# if find /bin /usr/bin | grep -q systemctl && ls /etc/systemd/system/ | grep -q tuic.service; then
|
||||||
|
# if [[ -z $(pgrep -f "tuic/tuic") ]] && [[ "$1" == "start" ]]; then
|
||||||
|
# systemctl start tuic.service
|
||||||
|
# elif [[ -n $(pgrep -f "tuic/tuic") ]] && [[ "$1" == "stop" ]]; then
|
||||||
|
# systemctl stop tuic.service
|
||||||
|
# fi
|
||||||
|
# fi
|
||||||
|
# sleep 0.8
|
||||||
|
#
|
||||||
|
# if [[ "$1" == "start" ]]; then
|
||||||
|
# if [[ -n $(pgrep -f "tuic/tuic") ]]; then
|
||||||
|
# echoContent green " ---> Tuic启动成功"
|
||||||
|
# else
|
||||||
|
# echoContent red "Tuic启动失败"
|
||||||
|
# echoContent red "请手动执行【/etc/v2ray-agent/tuic/tuic -c /etc/v2ray-agent/tuic/conf/config.json】,查看错误日志"
|
||||||
|
# exit 0
|
||||||
|
# fi
|
||||||
|
# elif [[ "$1" == "stop" ]]; then
|
||||||
|
# if [[ -z $(pgrep -f "tuic/tuic") ]]; then
|
||||||
|
# echoContent green " ---> Tuic关闭成功"
|
||||||
|
# else
|
||||||
|
# echoContent red "Tuic关闭失败"
|
||||||
|
# echoContent red "请手动执行【ps -ef|grep -v grep|grep tuic|awk '{print \$2}'|xargs kill -9】"
|
||||||
|
# exit 0
|
||||||
|
# fi
|
||||||
|
# fi
|
||||||
|
#}
|
||||||
|
|
||||||
|
# 操作sing-box
|
||||||
|
handleSingBox() {
|
||||||
# shellcheck disable=SC2010
|
# shellcheck disable=SC2010
|
||||||
if find /bin /usr/bin | grep -q systemctl && ls /etc/systemd/system/ | grep -q tuic.service; then
|
if find /bin /usr/bin | grep -q systemctl && ls /etc/systemd/system/ | grep -q sing-box.service; then
|
||||||
if [[ -z $(pgrep -f "tuic/tuic") ]] && [[ "$1" == "start" ]]; then
|
if [[ -z $(pgrep -f "sing-box") ]] && [[ "$1" == "start" ]]; then
|
||||||
systemctl start tuic.service
|
systemctl start sing-box.service
|
||||||
elif [[ -n $(pgrep -f "tuic/tuic") ]] && [[ "$1" == "stop" ]]; then
|
elif [[ -n $(pgrep -f "sing-box") ]] && [[ "$1" == "stop" ]]; then
|
||||||
systemctl stop tuic.service
|
systemctl stop sing-box.service
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
sleep 0.8
|
sleep 0.8
|
||||||
|
|
||||||
if [[ "$1" == "start" ]]; then
|
if [[ "$1" == "start" ]]; then
|
||||||
if [[ -n $(pgrep -f "tuic/tuic") ]]; then
|
if [[ -n $(pgrep -f "sing-box") ]]; then
|
||||||
echoContent green " ---> Tuic启动成功"
|
echoContent green " ---> sing-box 启动成功"
|
||||||
else
|
else
|
||||||
echoContent red "Tuic启动失败"
|
echoContent red "sing-box 启动失败"
|
||||||
echoContent red "请手动执行【/etc/v2ray-agent/tuic/tuic -c /etc/v2ray-agent/tuic/conf/config.json】,查看错误日志"
|
echoContent red "请手动执行【/etc/v2ray-agent/sing-box/sing-box run -c /etc/v2ray-agent/sing-box/conf/config.json】,查看错误日志"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
elif [[ "$1" == "stop" ]]; then
|
elif [[ "$1" == "stop" ]]; then
|
||||||
if [[ -z $(pgrep -f "tuic/tuic") ]]; then
|
if [[ -z $(pgrep -f "sing-box") ]]; then
|
||||||
echoContent green " ---> Tuic关闭成功"
|
echoContent green " ---> sing-box 关闭成功"
|
||||||
else
|
else
|
||||||
echoContent red "Tuic关闭失败"
|
echoContent red "sing-box 关闭失败"
|
||||||
echoContent red "请手动执行【ps -ef|grep -v grep|grep tuic|awk '{print \$2}'|xargs kill -9】"
|
echoContent red "请手动执行【ps -ef|grep -v grep|grep sing-box|awk '{print \$2}'|xargs kill -9】"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
# 操作xray
|
# 操作xray
|
||||||
handleXray() {
|
handleXray() {
|
||||||
if [[ -n $(find /bin /usr/bin -name "systemctl") ]] && [[ -n $(find /etc/systemd/system/ -name "xray.service") ]]; then
|
if [[ -n $(find /bin /usr/bin -name "systemctl") ]] && [[ -n $(find /etc/systemd/system/ -name "xray.service") ]]; then
|
||||||
|
@ -2516,12 +2630,12 @@ initXrayClients() {
|
||||||
currentClients=$(echo "${currentClients}" | jq -r ". +=[${newUser}]")
|
currentClients=$(echo "${currentClients}" | jq -r ". +=[${newUser}]")
|
||||||
fi
|
fi
|
||||||
local users=
|
local users=
|
||||||
if [[ "${type}" == "9" ]]; then
|
users=[]
|
||||||
users={}
|
# if [[ "${type}" == "9" ]]; then
|
||||||
else
|
# users={}
|
||||||
users=[]
|
# else
|
||||||
fi
|
# users=[]
|
||||||
|
# fi
|
||||||
while read -r user; do
|
while read -r user; do
|
||||||
uuid=$(echo "${user}" | jq -r .id)
|
uuid=$(echo "${user}" | jq -r .id)
|
||||||
email=$(echo "${user}" | jq -r .email | awk -F "[-]" '{print $1}')
|
email=$(echo "${user}" | jq -r .email | awk -F "[-]" '{print $1}')
|
||||||
|
@ -2582,7 +2696,9 @@ initXrayClients() {
|
||||||
fi
|
fi
|
||||||
# tuic
|
# tuic
|
||||||
if echo "${type}" | grep -q "9"; then
|
if echo "${type}" | grep -q "9"; then
|
||||||
users=$(echo "${users}" | jq -r ".\"${uuid}\"=\"${uuid}\"")
|
currentUser="{\"uuid\":\"${uuid}\",\"password\":\"${uuid}\",\"name\":\"${email}-singbox_tuic\"}"
|
||||||
|
|
||||||
|
users=$(echo "${users}" | jq -r ". +=[${currentUser}]")
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done < <(echo "${currentClients}" | jq -c '.[]')
|
done < <(echo "${currentClients}" | jq -c '.[]')
|
||||||
|
@ -2955,38 +3071,77 @@ initTuicProtocol() {
|
||||||
}
|
}
|
||||||
|
|
||||||
# 初始化tuic配置
|
# 初始化tuic配置
|
||||||
initTuicConfig() {
|
#initTuicConfig() {
|
||||||
|
# echoContent skyBlue "\n进度 $1/${totalProgress} : 初始化Tuic配置"
|
||||||
|
#
|
||||||
|
# initTuicPort
|
||||||
|
# initTuicProtocol
|
||||||
|
# cat <<EOF >/etc/v2ray-agent/tuic/conf/config.json
|
||||||
|
#{
|
||||||
|
# "server": "[::]:${tuicPort}",
|
||||||
|
# "users": $(initXrayClients 9),
|
||||||
|
# "certificate": "/etc/v2ray-agent/tls/${currentHost}.crt",
|
||||||
|
# "private_key": "/etc/v2ray-agent/tls/${currentHost}.key",
|
||||||
|
# "congestion_control":"${tuicAlgorithm}",
|
||||||
|
# "alpn": ["h3"],
|
||||||
|
# "log_level": "warn"
|
||||||
|
#}
|
||||||
|
#EOF
|
||||||
|
#}
|
||||||
|
|
||||||
|
# 初始化 sing-box Tuic 配置
|
||||||
|
initSingBoxTuicConfig() {
|
||||||
echoContent skyBlue "\n进度 $1/${totalProgress} : 初始化Tuic配置"
|
echoContent skyBlue "\n进度 $1/${totalProgress} : 初始化Tuic配置"
|
||||||
|
|
||||||
initTuicPort
|
initTuicPort
|
||||||
initTuicProtocol
|
initTuicProtocol
|
||||||
cat <<EOF >/etc/v2ray-agent/tuic/conf/config.json
|
cat <<EOF >/etc/v2ray-agent/sing-box/conf/config/tuic.json
|
||||||
{
|
{
|
||||||
"server": "[::]:${tuicPort}",
|
"inbounds": [
|
||||||
"users": $(initXrayClients 9),
|
{
|
||||||
"certificate": "/etc/v2ray-agent/tls/${currentHost}.crt",
|
"type": "tuic",
|
||||||
"private_key": "/etc/v2ray-agent/tls/${currentHost}.key",
|
"listen": "::",
|
||||||
"congestion_control":"${tuicAlgorithm}",
|
"tag": "singbox-tuic-in",
|
||||||
"alpn": ["h3"],
|
"listen_port": ${tuicPort},
|
||||||
"log_level": "warn"
|
"users": $(initXrayClients 9),
|
||||||
|
"congestion_control": "${tuicAlgorithm}",
|
||||||
|
"tls": {
|
||||||
|
"enabled": true,
|
||||||
|
"alpn": [
|
||||||
|
"h3"
|
||||||
|
],
|
||||||
|
"certificate_path": "/etc/v2ray-agent/tls/${currentHost}.crt",
|
||||||
|
"key_path": "/etc/v2ray-agent/tls/${currentHost}.key"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
]
|
||||||
}
|
}
|
||||||
EOF
|
EOF
|
||||||
}
|
}
|
||||||
|
|
||||||
# Tuic安装
|
# singBox Tuic安装
|
||||||
tuicCoreInstall() {
|
# todo 123
|
||||||
|
singBoxTuicInstall() {
|
||||||
if ! echo "${currentInstallProtocolType}" | grep -q "0" || [[ -z "${coreInstallType}" ]]; then
|
if ! echo "${currentInstallProtocolType}" | grep -q "0" || [[ -z "${coreInstallType}" ]]; then
|
||||||
echoContent red "\n ---> 由于环境依赖,如安装Tuic,请先安装Xray-core的VLESS_TCP_TLS_Vision"
|
echoContent red "\n ---> 由于证书环境依赖,如安装Tuic,请先安装Xray-core的VLESS_TCP_TLS_Vision"
|
||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
totalProgress=5
|
totalProgress=5
|
||||||
installTuic 1
|
# installTuic 1
|
||||||
initTuicConfig 2
|
installSingBox 1
|
||||||
installTuicService 3
|
initSingBoxTuicConfig 2
|
||||||
|
singBoxMergeConfig
|
||||||
|
installSingBoxService 3
|
||||||
reloadCore
|
reloadCore
|
||||||
showAccounts 4
|
showAccounts 4
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# 合并config
|
||||||
|
singBoxMergeConfig() {
|
||||||
|
rm /etc/v2ray-agent/sing-box/conf/config.json >/dev/null 2>&1
|
||||||
|
/etc/v2ray-agent/sing-box/sing-box merge config.json -C /etc/v2ray-agent/sing-box/conf/config/ -D /etc/v2ray-agent/sing-box/conf/ >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
# 初始化V2Ray 配置文件
|
# 初始化V2Ray 配置文件
|
||||||
initV2RayConfig() {
|
initV2RayConfig() {
|
||||||
echoContent skyBlue "\n进度 $2/${totalProgress} : 初始化V2Ray配置"
|
echoContent skyBlue "\n进度 $2/${totalProgress} : 初始化V2Ray配置"
|
||||||
|
@ -4070,9 +4225,9 @@ EOF
|
||||||
echoContent yellow " ---> Hysteria(TLS)"
|
echoContent yellow " ---> Hysteria(TLS)"
|
||||||
|
|
||||||
echoContent green " hysteria2://${id}@${currentHost}:${hysteriaPort}?peer=${currentHost}&insecure=0&sni=${currentHost}&alpn=h3#hysteria2\n"
|
echoContent green " hysteria2://${id}@${currentHost}:${hysteriaPort}?peer=${currentHost}&insecure=0&sni=${currentHost}&alpn=h3#hysteria2\n"
|
||||||
# cat <<EOF >>"/etc/v2ray-agent/subscribe_local/default/${user}"
|
# cat <<EOF >>"/etc/v2ray-agent/subscribe_local/default/${user}"
|
||||||
#hysteria2://${id}@${currentHost}:${hysteriaPort}?peer=${currentHost}&insecure=0&sni=${currentHost}&alpn=h3#hysteria2
|
#hysteria2://${id}@${currentHost}:${hysteriaPort}?peer=${currentHost}&insecure=0&sni=${currentHost}&alpn=h3#hysteria2
|
||||||
#EOF
|
#EOF
|
||||||
echoContent yellow " ---> v2rayN(hysteria+TLS)"
|
echoContent yellow " ---> v2rayN(hysteria+TLS)"
|
||||||
cat <<EOF >"/etc/v2ray-agent/hysteria/conf/client.json"
|
cat <<EOF >"/etc/v2ray-agent/hysteria/conf/client.json"
|
||||||
{
|
{
|
||||||
|
@ -4088,14 +4243,14 @@ EOF
|
||||||
v2rayNConf="$(cat /etc/v2ray-agent/hysteria/conf/client.json)"
|
v2rayNConf="$(cat /etc/v2ray-agent/hysteria/conf/client.json)"
|
||||||
echoContent green "${v2rayNConf}\n"
|
echoContent green "${v2rayNConf}\n"
|
||||||
|
|
||||||
# cat <<EOF >>"/etc/v2ray-agent/subscribe_local/clashMeta/${user}"
|
# cat <<EOF >>"/etc/v2ray-agent/subscribe_local/clashMeta/${user}"
|
||||||
# - name: hysteria2
|
# - name: hysteria2
|
||||||
# type: hysteria2
|
# type: hysteria2
|
||||||
# server: ${currentHost}
|
# server: ${currentHost}
|
||||||
# port: ${hysteriaPort}
|
# port: ${hysteriaPort}
|
||||||
# password: ${id}
|
# password: ${id}
|
||||||
# sni: ${currentHost}
|
# sni: ${currentHost}
|
||||||
#EOF
|
#EOF
|
||||||
echoContent yellow " ---> 二维码 Hysteria(TLS)"
|
echoContent yellow " ---> 二维码 Hysteria(TLS)"
|
||||||
echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=hysteria2%3A%2F%2F${id}%40${currentHost}%3A${hysteriaPort}%3Fpeer%3D${currentHost}%26insecure%3D0%26sni%3D${currentHost}%26alpn%3Dh3%23hysteria2\n"
|
echoContent green " https://api.qrserver.com/v1/create-qr-code/?size=400x400&data=hysteria2%3A%2F%2F${id}%40${currentHost}%3A${hysteriaPort}%3Fpeer%3D${currentHost}%26insecure%3D0%26sni%3D${currentHost}%26alpn%3Dh3%23hysteria2\n"
|
||||||
elif [[ "${type}" == "vlessReality" ]]; then
|
elif [[ "${type}" == "vlessReality" ]]; then
|
||||||
|
@ -4162,31 +4317,13 @@ EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
echoContent yellow " ---> 格式化明文(Tuic+TLS)"
|
echoContent yellow " ---> 格式化明文(Tuic+TLS)"
|
||||||
echoContent green " 协议类型:Tuic,地址:${currentHost},端口:${tuicPort},uuid:${id},password:${id},congestion-controller:${tuicAlgorithm},alpn: h3,账户名:${email}_tuic\n"
|
echoContent green " 协议类型:Tuic,地址:${currentHost},端口:${tuicPort},uuid:${id},password:${id},congestion-controller:${tuicAlgorithm},alpn: h3,账户名:${email}\n"
|
||||||
|
|
||||||
echoContent yellow " ---> v2rayN(Tuic+TLS)"
|
echoContent yellow " ---> v2rayN(Tuic+TLS)"
|
||||||
cat <<EOF >"/etc/v2ray-agent/tuic/conf/v2rayN.json"
|
echo "{\"relay\": {\"server\": \"${currentHost}:${tuicPort}\",\"uuid\": \"${id}\",\"password\": \"${id}\",\"ip\": \"$(getPublicIP)\",\"congestion_control\": \"${tuicAlgorithm}\",\"alpn\": [\"h3\"]},\"local\": {\"server\": \"127.0.0.1:7798\"},\"log_level\": \"warn\"}" | jq
|
||||||
{
|
|
||||||
"relay": {
|
|
||||||
"server": "${currentHost}:${tuicPort}",
|
|
||||||
"uuid": "${id}",
|
|
||||||
"password": "${id}",
|
|
||||||
"ip": "$(getPublicIP)",
|
|
||||||
"congestion_control": "${tuicAlgorithm}",
|
|
||||||
"alpn": ["h3"]
|
|
||||||
},
|
|
||||||
"local": {
|
|
||||||
"server": "127.0.0.1:7798"
|
|
||||||
},
|
|
||||||
"log_level": "warn"
|
|
||||||
}
|
|
||||||
EOF
|
|
||||||
local v2rayNConf=
|
|
||||||
v2rayNConf="$(cat /etc/v2ray-agent/tuic/conf/v2rayN.json)"
|
|
||||||
echoContent green "${v2rayNConf}"
|
|
||||||
|
|
||||||
cat <<EOF >>"/etc/v2ray-agent/subscribe_local/clashMeta/${email}"
|
cat <<EOF >>"/etc/v2ray-agent/subscribe_local/clashMeta/${user}"
|
||||||
- name: "${email}_tuic"
|
- name: "${email}"
|
||||||
server: ${currentHost}
|
server: ${currentHost}
|
||||||
type: tuic
|
type: tuic
|
||||||
port: ${tuicPort}
|
port: ${tuicPort}
|
||||||
|
@ -4197,14 +4334,7 @@ EOF
|
||||||
congestion-controller: ${tuicAlgorithm}
|
congestion-controller: ${tuicAlgorithm}
|
||||||
disable-sni: true
|
disable-sni: true
|
||||||
reduce-rtt: true
|
reduce-rtt: true
|
||||||
fast-open: true
|
sni: ${email}
|
||||||
heartbeat-interval: 8000
|
|
||||||
request-timeout: 8000
|
|
||||||
max-udp-relay-packet-size: 1500
|
|
||||||
max-open-streams: 100
|
|
||||||
ip-version: dual
|
|
||||||
smux:
|
|
||||||
enabled: false
|
|
||||||
EOF
|
EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -4343,25 +4473,9 @@ showAccounts() {
|
||||||
fi
|
fi
|
||||||
if echo ${currentInstallProtocolType} | grep -q 6; then
|
if echo ${currentInstallProtocolType} | grep -q 6; then
|
||||||
echoContent skyBlue "\n================================ Hysteria TLS ================================\n"
|
echoContent skyBlue "\n================================ Hysteria TLS ================================\n"
|
||||||
# echoContent red "\n --->Hysteria速度依赖与本地的网络环境,如果被QoS使用体验会非常差。IDC也有可能认为是攻击,请谨慎使用"
|
jq -r .auth.password "${hysteriaConfigPath}config.json" | while read -r user; do
|
||||||
|
|
||||||
jq -r .auth.password ${hysteriaConfigPath}config.json | while read -r user; do
|
|
||||||
# local defaultUser=
|
|
||||||
# local uuidType=
|
|
||||||
# uuidType=".id"
|
|
||||||
#
|
|
||||||
# if [[ "${frontingType}" == "02_trojan_TCP_inbounds" ]]; then
|
|
||||||
# uuidType=".password"
|
|
||||||
# fi
|
|
||||||
|
|
||||||
# defaultUser=$(jq '.inbounds[0].settings.clients[]|select('${uuidType}'=="'"${user}"'")' ${configPath}${frontingType}.json)
|
|
||||||
# local email=
|
|
||||||
# email=$(echo "${defaultUser}" | jq -r .email)
|
|
||||||
# local hysteriaEmail=
|
|
||||||
# hysteriaEmail=$(echo "${email}" | awk -F "[_]" '{print $1}')_hysteria
|
|
||||||
|
|
||||||
if [[ -n ${user} ]]; then
|
if [[ -n ${user} ]]; then
|
||||||
# echoContent skyBlue "\n ---> 账号:$(echo "${hysteriaEmail}" | awk -F "[-]" '{print $1"_hysteria"}')"
|
|
||||||
echoContent skyBlue "\n ---> 账号:hysteria2"
|
echoContent skyBlue "\n ---> 账号:hysteria2"
|
||||||
echo
|
echo
|
||||||
defaultBase64Code hysteria hysteria2 "${user}"
|
defaultBase64Code hysteria hysteria2 "${user}"
|
||||||
|
@ -4401,18 +4515,10 @@ showAccounts() {
|
||||||
# tuic
|
# tuic
|
||||||
if echo ${currentInstallProtocolType} | grep -q 9; then
|
if echo ${currentInstallProtocolType} | grep -q 9; then
|
||||||
echoContent skyBlue "\n================================ Tuic TLS ================================\n"
|
echoContent skyBlue "\n================================ Tuic TLS ================================\n"
|
||||||
echoContent yellow "\n --->Tuic相对于Hysteria会更加温 使用体验可能会更流畅。"
|
jq -r -c '.inbounds[]|select(.type=="tuic")|.users[]' "${singBoxConfigPath}config.json" | while read -r user; do
|
||||||
|
echoContent skyBlue "\n ---> 账号:$(echo "${user}" | jq -r .name)"
|
||||||
jq -r .users[] "${tuicConfigPath}config.json" | while read -r id; do
|
echo
|
||||||
local tuicEmail=
|
defaultBase64Code tuic "$(echo "${user}" | jq -r .name)" "$(echo "${user}" | jq -r .uuid)"
|
||||||
tuicEmail=$(jq -r '.inbounds[0].settings.clients[]|select(.id=="'"${id}"'")|.email' ${configPath}${frontingType}.json | awk -F "[-]" '{print $1}')
|
|
||||||
|
|
||||||
if [[ -n ${tuicEmail} ]]; then
|
|
||||||
echoContent skyBlue "\n ---> 账号:${tuicEmail}_tuic"
|
|
||||||
echo
|
|
||||||
defaultBase64Code tuic "${tuicEmail}" "${id}"
|
|
||||||
fi
|
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
@ -4694,11 +4800,11 @@ unInstall() {
|
||||||
rm -rf /etc/systemd/system/xray.service
|
rm -rf /etc/systemd/system/xray.service
|
||||||
echoContent green " ---> 删除Xray开机自启完成"
|
echoContent green " ---> 删除Xray开机自启完成"
|
||||||
|
|
||||||
elif [[ "${coreInstallType}" == "2" ]]; then
|
# elif [[ "${coreInstallType}" == "2" ]]; then
|
||||||
|
#
|
||||||
handleV2Ray stop
|
# handleV2Ray stop
|
||||||
rm -rf /etc/systemd/system/v2ray.service
|
# rm -rf /etc/systemd/system/v2ray.service
|
||||||
echoContent green " ---> 删除V2Ray开机自启完成"
|
# echoContent green " ---> 删除V2Ray开机自启完成"
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
@ -4951,8 +5057,8 @@ addUserXray() {
|
||||||
local clients=
|
local clients=
|
||||||
clients=$(initXrayClients 6 "${uuid}" "${email}")
|
clients=$(initXrayClients 6 "${uuid}" "${email}")
|
||||||
|
|
||||||
clients=$(jq -r ".auth.config = ${clients}" ${hysteriaConfigPath}config.json)
|
clients=$(jq -r ".auth.config = ${clients}" "${hysteriaConfigPath}config.json")
|
||||||
echo "${clients}" | jq . >${hysteriaConfigPath}config.json
|
echo "${clients}" | jq . >"${hysteriaConfigPath}config.json"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if echo ${currentInstallProtocolType} | grep -q 9; then
|
if echo ${currentInstallProtocolType} | grep -q 9; then
|
||||||
|
@ -5074,8 +5180,8 @@ addUser() {
|
||||||
|
|
||||||
if echo ${currentInstallProtocolType} | grep -q 6; then
|
if echo ${currentInstallProtocolType} | grep -q 6; then
|
||||||
local hysteriaResult
|
local hysteriaResult
|
||||||
hysteriaResult=$(jq -r ".auth.config += [\"${uuid}\"]" ${hysteriaConfigPath}config.json)
|
hysteriaResult=$(jq -r ".auth.config += [\"${uuid}\"]" "${hysteriaConfigPath}config.json")
|
||||||
echo "${hysteriaResult}" | jq . >${hysteriaConfigPath}config.json
|
echo "${hysteriaResult}" | jq . >"${hysteriaConfigPath}config.json"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
@ -5146,8 +5252,8 @@ removeUser() {
|
||||||
|
|
||||||
if echo ${currentInstallProtocolType} | grep -q 6; then
|
if echo ${currentInstallProtocolType} | grep -q 6; then
|
||||||
local hysteriaResult
|
local hysteriaResult
|
||||||
hysteriaResult=$(jq -r 'del(.auth.config['${delUserIndex}'])' ${hysteriaConfigPath}config.json)
|
hysteriaResult=$(jq -r 'del(.auth.config['${delUserIndex}'])' "${hysteriaConfigPath}config.json")
|
||||||
echo "${hysteriaResult}" | jq . >${hysteriaConfigPath}config.json
|
echo "${hysteriaResult}" | jq . >"${hysteriaConfigPath}config.json"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if echo ${currentInstallProtocolType} | grep -q 7; then
|
if echo ${currentInstallProtocolType} | grep -q 7; then
|
||||||
|
@ -6324,9 +6430,9 @@ reloadCore() {
|
||||||
if [[ "${coreInstallType}" == "1" ]]; then
|
if [[ "${coreInstallType}" == "1" ]]; then
|
||||||
handleXray stop
|
handleXray stop
|
||||||
handleXray start
|
handleXray start
|
||||||
elif [[ "${coreInstallType}" == "2" ]]; then
|
# elif [[ "${coreInstallType}" == "2" ]]; then
|
||||||
handleV2Ray stop
|
# handleV2Ray stop
|
||||||
handleV2Ray start
|
# handleV2Ray start
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "${hysteriaConfigPath}" ]]; then
|
if [[ -n "${hysteriaConfigPath}" ]]; then
|
||||||
|
@ -6334,10 +6440,21 @@ reloadCore() {
|
||||||
handleHysteria start
|
handleHysteria start
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [[ -n "${tuicConfigPath}" ]]; then
|
# if [[ -n "${tuicConfigPath}" ]]; then
|
||||||
handleTuic stop
|
# handleTuic stop
|
||||||
handleTuic start
|
# handleTuic start
|
||||||
|
# fi
|
||||||
|
|
||||||
|
if [[ -n "${singBoxConfigPath}" ]] && [[ -f "/etc/v2ray-agent/sing-box/conf/config.json" ]] && grep -q 'hysteria' </etc/v2ray-agent/sing-box/conf/config.json; then
|
||||||
|
handleSingBox stop
|
||||||
|
handleSingBox start
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
if [[ -n "${singBoxConfigPath}" ]] && [[ -f "/etc/v2ray-agent/sing-box/conf/config.json" ]] && grep -q 'tuic' </etc/v2ray-agent/sing-box/conf/config.json; then
|
||||||
|
handleSingBox stop
|
||||||
|
handleSingBox start
|
||||||
|
fi
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
# dns分流
|
# dns分流
|
||||||
|
@ -7788,11 +7905,12 @@ manageTuic() {
|
||||||
echoContent skyBlue "\n进度 1/1 : Tuic管理"
|
echoContent skyBlue "\n进度 1/1 : Tuic管理"
|
||||||
echoContent red "\n=============================================================="
|
echoContent red "\n=============================================================="
|
||||||
local tuicStatus=
|
local tuicStatus=
|
||||||
if [[ -n "${tuicConfigPath}" ]]; then
|
# if [[ -n "${tuicConfigPath}" ]]; then
|
||||||
|
if [[ -n "${singBoxConfigPath}" ]] && [[ -f "/etc/v2ray-agent/sing-box/conf/config.json" ]] && grep -q 'tuic' </etc/v2ray-agent/sing-box/conf/config.json; then
|
||||||
|
echoContent yellow " 依赖第三方sing-box\n"
|
||||||
echoContent yellow "1.重新安装"
|
echoContent yellow "1.重新安装"
|
||||||
echoContent yellow "2.卸载"
|
echoContent yellow "2.卸载"
|
||||||
echoContent yellow "3.core管理"
|
echoContent yellow "3.sing-box core管理"
|
||||||
echoContent yellow "4.查看日志"
|
|
||||||
tuicStatus=true
|
tuicStatus=true
|
||||||
else
|
else
|
||||||
echoContent yellow "1.安装"
|
echoContent yellow "1.安装"
|
||||||
|
@ -7801,15 +7919,31 @@ manageTuic() {
|
||||||
echoContent red "=============================================================="
|
echoContent red "=============================================================="
|
||||||
read -r -p "请选择:" installTuicStatus
|
read -r -p "请选择:" installTuicStatus
|
||||||
if [[ "${installTuicStatus}" == "1" ]]; then
|
if [[ "${installTuicStatus}" == "1" ]]; then
|
||||||
tuicCoreInstall
|
singBoxTuicInstall
|
||||||
elif [[ "${installTuicStatus}" == "2" && "${tuicStatus}" == "true" ]]; then
|
elif [[ "${installTuicStatus}" == "2" && "${tuicStatus}" == "true" ]]; then
|
||||||
unInstallTuicCore
|
unInstallTuicCore
|
||||||
elif [[ "${installTuicStatus}" == "3" && "${tuicStatus}" == "true" ]]; then
|
elif [[ "${installTuicStatus}" == "3" && "${tuicStatus}" == "true" ]]; then
|
||||||
tuicVersionManageMenu 1
|
singBoxVersionManageMenu 1
|
||||||
elif [[ "${installTuicStatus}" == "4" && "${tuicStatus}" == "true" ]]; then
|
|
||||||
journalctl -fu tuic
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
# sing-box log日志
|
||||||
|
singBoxLog() {
|
||||||
|
cat <<EOF >/etc/v2ray-agent/sing-box/conf/config/log.json
|
||||||
|
{
|
||||||
|
"log": {
|
||||||
|
"disabled": $1,
|
||||||
|
"level": "debug",
|
||||||
|
"output": "/etc/v2ray-agent/sing-box/box.log",
|
||||||
|
"timestamp": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EOF
|
||||||
|
|
||||||
|
singBoxMergeConfig
|
||||||
|
|
||||||
|
handleSingBox stop
|
||||||
|
handleSingBox start
|
||||||
|
}
|
||||||
# hysteria版本管理
|
# hysteria版本管理
|
||||||
hysteriaVersionManageMenu() {
|
hysteriaVersionManageMenu() {
|
||||||
echoContent skyBlue "\n进度 $1/${totalProgress} : Hysteria版本管理"
|
echoContent skyBlue "\n进度 $1/${totalProgress} : Hysteria版本管理"
|
||||||
|
@ -7839,6 +7973,50 @@ hysteriaVersionManageMenu() {
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# sing-box 版本管理
|
||||||
|
singBoxVersionManageMenu() {
|
||||||
|
echoContent skyBlue "\n进度 $1/${totalProgress} : sing-box 版本管理"
|
||||||
|
if [[ ! -f "/etc/v2ray-agent/sing-box/sing-box" ]]; then
|
||||||
|
echoContent red " ---> 没有检测到安装程序,请执行脚本安装内容"
|
||||||
|
menu
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
echoContent red "\n=============================================================="
|
||||||
|
echoContent yellow "1.升级 sing-box"
|
||||||
|
echoContent yellow "2.关闭 sing-box"
|
||||||
|
echoContent yellow "3.打开 sing-box"
|
||||||
|
echoContent yellow "4.重启 sing-box"
|
||||||
|
echoContent yellow "=============================================================="
|
||||||
|
local logStatus=
|
||||||
|
if [[ -n "${singBoxConfigPath}" && "$(jq -r .log.disabled ${singBoxConfigPath}config.json)" == "true" ]]; then
|
||||||
|
echoContent yellow "5.关闭日志"
|
||||||
|
logStatus=false
|
||||||
|
else
|
||||||
|
echoContent yellow "5.启用日志"
|
||||||
|
logStatus=true
|
||||||
|
fi
|
||||||
|
|
||||||
|
echoContent yellow "6.查看日志"
|
||||||
|
echoContent red "=============================================================="
|
||||||
|
|
||||||
|
read -r -p "请选择:" selectTuicType
|
||||||
|
if [[ "${selectTuicType}" == "1" ]]; then
|
||||||
|
installSingBox 1
|
||||||
|
handleSingBox start
|
||||||
|
elif [[ "${selectTuicType}" == "2" ]]; then
|
||||||
|
handleSingBox stop
|
||||||
|
elif [[ "${selectTuicType}" == "3" ]]; then
|
||||||
|
handleSingBox start
|
||||||
|
elif [[ "${selectTuicType}" == "4" ]]; then
|
||||||
|
handleSingBox stop
|
||||||
|
handleSingBox start
|
||||||
|
elif [[ "${selectTuicType}" == "5" ]]; then
|
||||||
|
singBoxLog ${logStatus}
|
||||||
|
elif [[ "${selectTuicType}" == "6" ]]; then
|
||||||
|
tail -f "${singBoxConfigPath}../box.log"
|
||||||
|
fi
|
||||||
|
}
|
||||||
|
|
||||||
# Tuic版本管理
|
# Tuic版本管理
|
||||||
tuicVersionManageMenu() {
|
tuicVersionManageMenu() {
|
||||||
echoContent skyBlue "\n进度 $1/${totalProgress} : Tuic版本管理"
|
echoContent skyBlue "\n进度 $1/${totalProgress} : Tuic版本管理"
|
||||||
|
@ -7872,7 +8050,7 @@ menu() {
|
||||||
cd "$HOME" || exit
|
cd "$HOME" || exit
|
||||||
echoContent red "\n=============================================================="
|
echoContent red "\n=============================================================="
|
||||||
echoContent green "作者:mack-a"
|
echoContent green "作者:mack-a"
|
||||||
echoContent green "当前版本:v2.10.22"
|
echoContent green "当前版本:v2.10.23"
|
||||||
echoContent green "Github:https://github.com/mack-a/v2ray-agent"
|
echoContent green "Github:https://github.com/mack-a/v2ray-agent"
|
||||||
echoContent green "描述:八合一共存脚本\c"
|
echoContent green "描述:八合一共存脚本\c"
|
||||||
showInstallStatus
|
showInstallStatus
|
||||||
|
|
Loading…
Reference in New Issue