Skip to content

Commit

Permalink
fix(脚本): 修复sing-box naive无法删除用户问题、修复sing-box卸载dns分流报错问题
Browse files Browse the repository at this point in the history
  • Loading branch information
mack-a committed Apr 9, 2024
1 parent 5830e6b commit 4ae549a
Showing 1 changed file with 31 additions and 8 deletions.
39 changes: 31 additions & 8 deletions install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -4424,6 +4424,7 @@ EOF
removeSingBoxConfig cn_block_route
removeSingBoxConfig 01_direct_outbound
removeSingBoxConfig block_domain_outbound
removeSingBoxConfig dns
}
# 初始化 sing-box订阅配置
initSubscribeLocalConfig() {
Expand Down Expand Up @@ -5590,7 +5591,7 @@ removeUser() {
if [[ "${coreInstallType}" == "1" ]]; then
jq -r -c .inbounds[0].settings.clients[].email ${configPath}${userConfigType}.json | awk '{print NR""":"$0}'
elif [[ "${coreInstallType}" == "2" ]]; then
jq -r -c .inbounds[0].users[].name ${configPath}${userConfigType}.json | awk '{print NR""":"$0}'
jq -r -c .inbounds[0].users[].name//.inbounds[0].users[].username ${configPath}${userConfigType}.json | awk '{print NR""":"$0}'
fi

read -r -p "请选择要删除的用户编号[仅支持单个删除]:" delUserIndex
Expand Down Expand Up @@ -5622,19 +5623,19 @@ removeUser() {

if echo ${currentInstallProtocolType} | grep -q ",3,"; then
local vmessWSResult
vmessWSResult=$(jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}'])' ${configPath}05_VMess_WS_inbounds.json)
vmessWSResult=$(jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}']//.inbounds[0].users['${delUserIndex}'])' ${configPath}05_VMess_WS_inbounds.json)
echo "${vmessWSResult}" | jq . >${configPath}05_VMess_WS_inbounds.json
fi

if echo ${currentInstallProtocolType} | grep -q ",5,"; then
local vlessGRPCResult
vlessGRPCResult=$(jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}'])' ${configPath}06_VLESS_gRPC_inbounds.json)
vlessGRPCResult=$(jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}']//.inbounds[0].users['${delUserIndex}'])' ${configPath}06_VLESS_gRPC_inbounds.json)
echo "${vlessGRPCResult}" | jq . >${configPath}06_VLESS_gRPC_inbounds.json
fi

if echo ${currentInstallProtocolType} | grep -q ",4,"; then
local trojanTCPResult
trojanTCPResult=$(jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}'])' ${configPath}04_trojan_TCP_inbounds.json)
trojanTCPResult=$(jq -r 'del(.inbounds[0].settings.clients['${delUserIndex}']//.inbounds[0].users['${delUserIndex}'])' ${configPath}04_trojan_TCP_inbounds.json)
echo "${trojanTCPResult}" | jq . >${configPath}04_trojan_TCP_inbounds.json
fi

Expand All @@ -5651,14 +5652,19 @@ removeUser() {

if echo ${currentInstallProtocolType} | grep -q ",6,"; then
local hysteriaResult
hysteriaResult=$(jq -r 'del(.inbounds[0].users['${delUserIndex}'])' "${singBoxConfigPath}06_hysteria2_inbounds.json")
hysteriaResult=$(jq -r 'del(.inbounds[0].users['${delUserIndex}']//.inbounds[0].users['${delUserIndex}'])' "${singBoxConfigPath}06_hysteria2_inbounds.json")
echo "${hysteriaResult}" | jq . >"${singBoxConfigPath}06_hysteria2_inbounds.json"
fi
if echo ${currentInstallProtocolType} | grep -q ",9,"; then
local tuicResult
tuicResult=$(jq -r 'del(.inbounds[0].users['${delUserIndex}'])' "${singBoxConfigPath}09_tuic_inbounds.json")
tuicResult=$(jq -r 'del(.inbounds[0].users['${delUserIndex}']//.inbounds[0].users['${delUserIndex}'])' "${singBoxConfigPath}09_tuic_inbounds.json")
echo "${tuicResult}" | jq . >"${singBoxConfigPath}09_tuic_inbounds.json"
fi
if echo ${currentInstallProtocolType} | grep -q ",10,"; then
local naiveResult
naiveResult=$(jq -r 'del(.inbounds[0].users['${delUserIndex}']//.inbounds[0].users['${delUserIndex}'])' "${singBoxConfigPath}10_naive_inbounds.json")
echo "${naiveResult}" | jq . >"${singBoxConfigPath}10_naive_inbounds.json"
fi
reloadCore
fi
manageAccount 1
Expand Down Expand Up @@ -7265,7 +7271,8 @@ setUnlockDNS() {

# 移除 DNS分流
removeUnlockDNS() {
cat <<EOF >${configPath}11_dns.json
if [[ "${coreInstallType}" == "1" && -f "${configPath}11_dns.json" ]]; then
cat <<EOF >${configPath}11_dns.json
{
"dns": {
"servers": [
Expand All @@ -7274,6 +7281,22 @@ removeUnlockDNS() {
}
}
EOF
fi

if [[ "${coreInstallType}" == "2" && -f "${singBoxConfigPath}dns.json" ]]; then
cat <<EOF >${singBoxConfigPath}dns.json
{
"dns": {
"servers":[
{
"address":"local"
}
]
}
}
EOF
fi

reloadCore

echoContent green " ---> 卸载成功"
Expand Down Expand Up @@ -8801,7 +8824,7 @@ menu() {
cd "$HOME" || exit
echoContent red "\n=============================================================="
echoContent green "作者:mack-a"
echoContent green "当前版本:v3.2.37"
echoContent green "当前版本:v3.2.38"
echoContent green "Github:https://github.com/mack-a/v2ray-agent"
echoContent green "描述:八合一共存脚本\c"
showInstallStatus
Expand Down

0 comments on commit 4ae549a

Please sign in to comment.