基于 SBSM 与 Sing-Box 的动态配置方案,可实现 Sing-Box 订阅的手动/自动更新。
- 一台 Linux 主机(Debian/Ubuntu/Armbian/OpenWrt 等),具备 root 权限
- 已安装
curl - 推荐使用
systemd管理sing-box服务
- 部署并获取订阅链接
自行部署 SBSM,部署完成后复制 share config link,通常形如:
https://sbsm-worker.example.com/api/config?config_id=<uuid>&share=<uuid>
- 安装 Sing-Box
- 方案 A(官方安装脚本,最新稳定版):
curl -fsSL https://sing-box.app/install.sh | sh
- 方案 B(使用本仓库脚本,中国大陆用户推荐使用):
- 执行本仓库的
scripts/install.sh,安装最新稳定版:
- 执行本仓库的
curl -fsSL https://ghfast.top/https://raw.githubusercontent.com/TooonyChen/Sing-Box-Dynamic-Config/refs/heads/main/scripts/install.sh | sh
- 配置更新脚本
-
Debian/Ubuntu/Armbian 系统:将本仓库的
scripts/tun.sh复制到服务器(例如/root/tun.sh)curl -fsSL https://ghfast.top/https://raw.githubusercontent.com/TooonyChen/Sing-Box-Dynamic-Config/refs/heads/main/scripts/tun.sh -o /root/tun.sh -
OpenWrt 系统:将本仓库的
scripts/tun-openwrt.sh复制到服务器(例如/root/tun.sh)curl -fsSL https://ghfast.top/https://raw.githubusercontent.com/TooonyChen/Sing-Box-Dynamic-Config/refs/heads/main/scripts/tun-openwrt.sh -o /root/tun.sh -
编辑脚本中的
FULL_URL,将其替换为步骤 1 获取的 SBSM 分享链接
- 启动/更新配置并运行 sing-box
chmod +x /root/tun.sh
/root/tun.sh
脚本将:
- 备份当前
/etc/sing-box/config.json为/etc/sing-box/config.json.backup - 下载远端配置并通过
sing-box check校验 - 自动启动
sing-box服务
- 配置定时任务(可选)
使用 crontab 每天凌晨 5 点自动更新订阅:
0 5 * * * /root/tun.sh
Debian/Ubuntu/Armbian
systemctl status sing-box.service
journalctl -u sing-box --output cat -f
sing-box check -c /etc/sing-box/config.json
sing-box run -c /etc/sing-box/config.json
OpenWrt
/etc/init.d/sing-box status
logread -f | grep sing-box
sing-box check -c /etc/sing-box/config.json
sing-box run -c /etc/sing-box/config.json
/etc/init.d/sing-box restart
见本仓库根目录的 LICENSE 文件。