Skip to content

Commit

Permalink
feat(脚本): 修改warp、IPv6分流引起的配置文件错误问题
Browse files Browse the repository at this point in the history
  • Loading branch information
mack-a committed Dec 26, 2023
1 parent 018b62f commit fff1e83
Showing 1 changed file with 23 additions and 22 deletions.
45 changes: 23 additions & 22 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ readInstallType() {
if [[ -f "${configPath}07_VLESS_vision_reality_inbounds.json" ]]; then
realityStatus=1
fi
if [[ -f "/etc/v2ray-agent/sing-box/conf/config/06_hysteria2_inbounds.json" || -f "/etc/v2ray-agent/sing-box/conf/config/09_tuic_inbounds.json" ]]; then
if [[ -f "/etc/v2ray-agent/sing-box/sing-box" ]] && [[ -f "/etc/v2ray-agent/sing-box/conf/config/06_hysteria2_inbounds.json" || -f "/etc/v2ray-agent/sing-box/conf/config/09_tuic_inbounds.json" ]]; then
singBoxConfigPath=/etc/v2ray-agent/sing-box/conf/config/
fi
fi
Expand Down Expand Up @@ -1820,7 +1820,7 @@ installCronTLS() {
}
# 定时任务更新geo文件
installCronUpdateGeo() {
if [[ -n "${configPath}" ]]; then
if [[ "${coreInstallType}" == "1" ]]; then
if crontab -l | grep -q "UpdateGeo"; then
echoContent red "\n ---> 已添加自动更新定时任务,请不要重复添加"
exit 0
Expand Down Expand Up @@ -5498,7 +5498,7 @@ ipv6Routing() {

if [[ -n "${singBoxConfigPath}" ]]; then
echoContent yellow "sing-box:"
jq -r -c '.route.rules[]|select (.outbound=="IPv6_out")|.geosite' "${singBoxConfigPath}IPv6_out_route.json" | jq -r
jq -r -c '.route.rules[]|select (.outbound=="IPv6_out")' "${singBoxConfigPath}IPv6_out_route.json" | jq -r
fi

exit 0
Expand All @@ -5519,7 +5519,7 @@ ipv6Routing() {
echo "${outbounds}" | jq . >${configPath}10_ipv4_outbounds.json
fi

if [[ "${coreInstallType}" == "2" ]]; then
if [[ -n "${singBoxConfigPath}" ]]; then
configurationSingBoxRoute add IPv6_out "${domainList}"
addSingBoxOutbound IPv6_out
addSingBoxOutbound IPv4_out
Expand Down Expand Up @@ -5552,11 +5552,13 @@ ipv6Routing() {
EOF
rm ${configPath}09_routing.json >/dev/null 2>&1
fi
if [[ "${coreInstallType}" == "2" ]]; then
if [[ -n "${singBoxConfigPath}" ]]; then
configurationSingBoxRoute delete wireguard_out_IPv4
configurationSingBoxRoute delete wireguard_out_IPv6

removeSingBoxOutbound IPv4_out
removeSingBoxOutbound wireguard_out_IPv4
removeSingBoxOutbound wireguard_out_IPv6
removeSingBoxOutbound wireguard_outbound

addSingBoxOutbound IPv6_out
Expand All @@ -5570,18 +5572,21 @@ EOF
fi

elif [[ "${ipv6Status}" == "4" ]]; then
if [[ "${coreInstallType}" == "1" ]]; then
unInstallRouting IPv6_out outboundTag

unInstallRouting IPv6_out outboundTag

unInstallOutbounds IPv6_out

configurationSingBoxRoute delete IPv6_out
unInstallOutbounds IPv6_out
if ! grep -q "IPv4_out" <"${configPath}10_ipv4_outbounds.json"; then
outbounds=$(jq -r '.outbounds += [{"protocol":"freedom","settings": {"domainStrategy": "UseIPv4"},"tag":"IPv4_out"}]' ${configPath}10_ipv4_outbounds.json)

if ! grep -q "IPv4_out" <"${configPath}10_ipv4_outbounds.json"; then
outbounds=$(jq -r '.outbounds += [{"protocol":"freedom","settings": {"domainStrategy": "UseIPv4"},"tag":"IPv4_out"}]' ${configPath}10_ipv4_outbounds.json)
echo "${outbounds}" | jq . >${configPath}10_ipv4_outbounds.json
fi
fi

echo "${outbounds}" | jq . >${configPath}10_ipv4_outbounds.json
if [[ -n "${singBoxConfigPath}" ]]; then
configurationSingBoxRoute delete IPv6_out
fi

echoContent green " ---> IPv6分流卸载成功"
else
echoContent red " ---> 选择错误"
Expand Down Expand Up @@ -6058,7 +6063,7 @@ addWireGuardRoute() {
# 卸载wireGuard
unInstallWireGuard() {
local type=$1
if [[ -n "${configPath}" ]]; then
if [[ "${coreInstallType}" == "1" ]]; then

if [[ "${type}" == "IPv4" ]]; then
if ! grep -q "wireguard_out_IPv6" <${configPath}10_ipv4_outbounds.json; then
Expand All @@ -6081,9 +6086,7 @@ unInstallWireGuard() {
# 移除WireGuard分流
removeWireGuardRoute() {
local type=$1
# local tag=$2
# xray
if [[ -n "${configPath}" ]]; then
if [[ "${coreInstallType}" == "1" ]]; then

unInstallRouting wireguard_out_"${type}" outboundTag

Expand Down Expand Up @@ -6116,8 +6119,6 @@ removeWireGuardRoute() {
}
EOF
fi

echoContent green " ---> WARP分流卸载成功"
fi

# sing-box
Expand Down Expand Up @@ -6235,9 +6236,9 @@ EOF
fi

elif [[ "${warpStatus}" == "4" ]]; then

removeWireGuardRoute "${type}"
removeSingBoxOutbound "wireguard_out_${type}"
echoContent green " ---> 卸载WARP ${type}分流成功"
else
echoContent red " ---> 选择错误"
exit 0
Expand Down Expand Up @@ -6817,7 +6818,7 @@ customSingBoxInstall() {

if [[ "${selectCustomInstallType}" =~ ^[0-9]+$ ]]; then
# checkBTPanel
totalProgress=17
totalProgress=9
installTools 1
# 申请tls
if echo "${selectCustomInstallType}" | grep -q -E "0|6|9"; then
Expand Down Expand Up @@ -8289,7 +8290,7 @@ menu() {
cd "$HOME" || exit
echoContent red "\n=============================================================="
echoContent green "作者:mack-a"
echoContent green "当前版本:v3.1.17"
echoContent green "当前版本:v3.1.18"
echoContent green "Github:https://github.com/mack-a/v2ray-agent"
echoContent green "描述:八合一共存脚本\c"
showInstallStatus
Expand Down

0 comments on commit fff1e83

Please sign in to comment.