Skip to content

Commit 5dfd0cd

Browse files
committed
fix: resolve loss of UUID when adding/removing protocols in sb -r
fix: 修复 sb -r 添加或删除协议时 UUID 丢失的问题
1 parent 53ce0dc commit 5dfd0cd

2 files changed

Lines changed: 24 additions & 21 deletions

File tree

docker_init.sh

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
#!/usr/bin/env bash
2-
# 脚本更新日期 2026.06.05
2+
# 脚本更新日期 2026.06.27
33
set -e
44

55
WORK_DIR=/sing-box
@@ -8,8 +8,8 @@ SUBSCRIBE_TEMPLATE="https://raw.githubusercontent.com/fscarmen/client_template/m
88

99
# 自定义字体彩色,read 函数
1010
warning() { echo -e "\033[31m\033[01m$*\033[0m"; } # 红色
11-
info() { echo -e "\033[32m\033[01m$*\033[0m"; } # 绿色
12-
hint() { echo -e "\033[33m\033[01m$*\033[0m"; } # 黄色
11+
info() { echo -e "\033[32m\033[01m$*\033[0m"; } # 绿色
12+
hint() { echo -e "\033[33m\033[01m$*\033[0m"; } # 黄色
1313

1414
# 判断系统架构,以下载相应的应用
1515
case "$ARCH" in
@@ -30,13 +30,16 @@ check_latest_sing-box() {
3030
local FORCE_VERSION=$(wget --no-check-certificate --tries=2 --timeout=3 -qO- https://raw.githubusercontent.com/fscarmen/sing-box/refs/heads/main/force_version | sed 's/^[vV]//g')
3131

3232
# 没有强制指定版本时,获取最新版本
33-
grep -q '.' <<< "$FORCE_VERSION" || local FORCE_VERSION=$(wget --no-check-certificate --tries=2 --timeout=3 -qO- https://api.github.com/repos/SagerNet/sing-box/releases | awk -F '["v-]' '/tag_name/{print $5}' | sort -Vr | sed -n '1p')
34-
35-
# 获取最终版本号
36-
local VERSION=$(wget --no-check-certificate --tries=2 --timeout=3 -qO- https://api.github.com/repos/SagerNet/sing-box/releases | awk -F '["v]' -v var="tag_name.*$FORCE_VERSION" '$0 ~ var {print $5; exit}')
37-
VERSION=${VERSION:-'1.13.0-rc.4'}
33+
if grep -q '.' <<< "$FORCE_VERSION"; then
34+
echo "$FORCE_VERSION"
35+
return
36+
else
37+
local VERSION_LIST=$(wget --no-check-certificate --tries=2 --timeout=3 -qO- https://api.github.com/repos/SagerNet/sing-box/releases | sed -n '/tag_name/ s/^[ ]*//gp')
38+
local LATEST_VERSION=$(awk -F '["v-]' '/tag_name/{print $5}' <<< "$VERSION_LIST" | sort -Vr | sed -n '1p')
3839

39-
echo "$VERSION"
40+
# 获取最终版本号
41+
awk -F '["v]' -v var="tag_name.*$LATEST_VERSION" '$0 ~ var {print $5; exit}' <<< "$VERSION_LIST"
42+
fi
4043
}
4144

4245
# 安装 sing-box 容器

sing-box.sh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/usr/bin/env bash
22

33
# 当前脚本版本号
4-
VERSION='v1.3.14 (2026.06.20)'
4+
VERSION='v1.3.14 (2026.06.27)'
55

66
# Github 反代加速代理
77
GITHUB_PROXY=('https://hub.glowp.xyz/' 'https://proxy.vvvv.ee/')
@@ -56,8 +56,8 @@ E[7]="Install dependence-list:"
5656
C[7]="安装依赖列表:"
5757
E[8]="All dependencies already exist and do not need to be installed additionally."
5858
C[8]="所有依赖已存在,不需要额外安装"
59-
E[9]="To upgrade, press [y]. No upgrade by default:"
60-
C[9]="升级请按 [y],默认不升级:"
59+
E[9]="Whether to upgrade [y/N] (default is N):"
60+
C[9]="是否升级 [y/N] (默认为 N):"
6161
E[10]="Please enter VPS IP (Default: \${SERVER_IP_DEFAULT}):"
6262
C[10]="请输入 VPS IP (默认为: \${SERVER_IP_DEFAULT}):"
6363
E[11]="Please enter the starting port number. Must be \${MIN_PORT} - \${MAX_PORT}, consecutive \${NUM} free ports are required (Default: \${START_PORT_DEFAULT}):"
@@ -204,8 +204,8 @@ E[81]="Adaptive Clash / V2rayN / Throne / ShadowRocket / SFI / SFA / SFM Clients
204204
C[81]="自适应 Clash / V2rayN / Throne / ShadowRocket / SFI / SFA / SFM 客户端"
205205
E[82]="template"
206206
C[82]="模版"
207-
E[83]="To uninstall Nginx press [y], it is not uninstalled by default:"
208-
C[83]="如要卸载 Nginx 请按 [y],默认不卸载:"
207+
E[83]="Whether to uninstall Nginx [y/N] (default is N):"
208+
C[83]="是否卸载 Nginx [y/N] (默认为 N):"
209209
E[84]="Set SElinux: enforcing --> disabled"
210210
C[84]="设置 SElinux: enforcing --> disabled"
211211
E[85]="Please enter Argo Token, Argo Json or Cloudflare API\n\n [*] Token: Visit https://dash.cloudflare.com/ , Zero Trust > Networks > Connectors > Create a tunnel > Select Cloudflared\n\n [*] Json: Users can easily obtain it through the following website: https://fscarmen.cloudflare.now.cc\n\n [*] Cloudflare API: Visit https://dash.cloudflare.com/profile/api-tokens > Create Token > Create Custom Token > Add the following permissions:\n - Account > Cloudflare One Connectors: cloudflared > Edit\n - Zone > DNS > Edit\n\n - Account Resources: Include > Required Account\n - Zone Resources: Include > Specific zone > Argo Root Domain"
@@ -278,8 +278,8 @@ E[118]="Please enter [Token, Json, API] value:"
278278
C[118]="请输入 [Token, Json, API] 的值:"
279279
E[119]="Using Cloudflare API to create Tunnel and handle DNS config..."
280280
C[119]="使用 Cloudflare API 创建 Tunnel 和处理 DNS 配置..."
281-
E[120]="Found existing tunnel with the same name. Tunnel ID: \$EXISTING_TUNNEL_ID. Status: \$EXISTING_TUNNEL_STATUS. Overwrite? [y/N] (default y):"
282-
C[120]="发现同名隧道已创建,隧道 ID: \$EXISTING_TUNNEL_ID,状态: \$EXISTING_TUNNEL_STATUS。是否覆盖? [y/N] (默认为 y):"
281+
E[120]="Found existing tunnel with the same name. Tunnel ID: \$EXISTING_TUNNEL_ID. Status: \$EXISTING_TUNNEL_STATUS. Overwrite? [Y/n] (default is Y):"
282+
C[120]="发现同名隧道已创建,隧道 ID: \$EXISTING_TUNNEL_ID,状态: \$EXISTING_TUNNEL_STATUS。是否覆盖? [Y/n] (默认为 Y):"
283283
E[121]="Change node configuration (sb -d)"
284284
C[121]="修改节点配置 (sb -d)"
285285
E[122]="Invalid access token. Please roll at https://dash.cloudflare.com/profile/api-tokens to re-generate."
@@ -332,8 +332,8 @@ E[145]="UFW is not active. PortHopping forwarding rules were written, but you sh
332332
C[145]="UFW 未处于激活状态。PortHopping 转发规则已写入,但建议手动启用 UFW 以确保策略生效"
333333
E[146]="Failed to update UFW PortHopping forwarding rules. Please check UFW configuration files manually."
334334
C[146]="更新 UFW 的 PortHopping 转发规则失败,请手动检查 UFW 配置文件"
335-
E[147]="Hysteria2 Realm is useful for China-back routing or machines without public inbound access. It is not recommended when the server already has a public inbound IP/port. Enable Realm? [y/N]:"
336-
C[147]="Hysteria2 Realm 适用于回国或者没有公网入口的机器;有公网入口时不建议使用。是否启用?[y/N]:"
335+
E[147]="Hysteria2 Realm is useful for China-back routing or machines without public inbound access. It is not recommended when the server already has a public inbound IP/port. Enable Realm? [y/N] (default is N):"
336+
C[147]="Hysteria2 Realm 适用于回国或者没有公网入口的机器;有公网入口时不建议使用。是否启用?[y/N] (默认为 N):"
337337
E[148]="WARP-assisted hole punching is useful in strict NAT environments. When direct hole punching fails, Cloudflare WARP can provide a CF egress path to improve success. Enable it? [y/N]:"
338338
C[148]="WARP 辅助打洞(适用于 NAT 严格环境):当 NAT 类型较严格(如对称 NAT)导致直连打洞失败时,可借助 Cloudflare WARP 获取一个 CF 出口 IP 作为中转,提升打洞成功率。是否启用?[y/N]:"
339339
E[150]="Custom warp-ep outbounds rules (rules: \${CUSTOM_ROUTE_COUNT:-0})"
@@ -417,7 +417,7 @@ calc_install_steps() {
417417
# 检测是否需要启用 Github CDN,如能直接连通 api.github.com,则不使用
418418
check_cdn() {
419419
local PROXY CODE PID CMD
420-
local _WAIT_COUNT=120
420+
local _WAIT_COUNT=40
421421
local PIDS=()
422422
local API_URL='https://api.github.com/repos/SagerNet/sing-box/releases'
423423

@@ -2128,7 +2128,7 @@ get_sing_box_version() {
21282128
local API_RESPONSE=$(wget --no-check-certificate --server-response --tries=2 --timeout=3 -qO- "${GH_PROXY}https://api.github.com/repos/SagerNet/sing-box/releases" 2>&1 | grep -E '^[ ]+HTTP/|tag_name')
21292129
if grep -q 'HTTP.* 200' <<< "$API_RESPONSE"; then
21302130
local VERSION_LATEST=$(awk -F '["v-]' '/tag_name/{print $5}' <<< "$API_RESPONSE" | sort -Vr | sed -n '1p')
2131-
local RESULT_VERSION=$(wget --no-check-certificate --tries=2 --timeout=3 -qO- ${GH_PROXY}https://api.github.com/repos/SagerNet/sing-box/releases | awk -F '["v]' -v var="tag_name.*$VERSION_LATEST" '$0 ~ var {print $5; exit}')
2131+
local RESULT_VERSION=$(awk -F '["v]' -v var="tag_name.*$VERSION_LATEST" '$0 ~ var {print $5; exit}' <<< "$API_RESPONSE")
21322132
else
21332133
local RESULT_VERSION="$DEFAULT_NEWEST_VERSION"
21342134
fi
@@ -5249,7 +5249,7 @@ change_protocols() {
52495249

52505250
# 用于新节点的配置信息
52515251
if [ "${#UUID[@]}" -gt 0 ]; then
5252-
UUID_CONFIRM="${UUID[0]}"
5252+
UUID_CONFIRM="$(printf "%s\n" "${UUID[@]}" | grep -m 1 . )"
52535253
elif grep -q '.' <<< "${TROJAN_PASSWORD}"; then
52545254
UUID_CONFIRM="${TROJAN_PASSWORD}"
52555255
else

0 commit comments

Comments
 (0)