Skip to content

TooonyChen/Sing-Box-Dynamic-Config

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

27 Commits
 
 
 
 
 
 
 
 

Repository files navigation

动态 Sing-Box 配置

基于 SBSMSing-Box 的动态配置方案,可实现 Sing-Box 订阅的手动/自动更新。


先决条件

  • 一台 Linux 主机(Debian/Ubuntu/Armbian/OpenWrt 等),具备 root 权限
  • 已安装 curl
  • 推荐使用 systemd 管理 sing-box 服务

快速开始

  1. 部署并获取订阅链接

自行部署 SBSM,部署完成后复制 share config link,通常形如:

https://sbsm-worker.example.com/api/config?config_id=<uuid>&share=<uuid>
  1. 安装 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 
  1. 配置更新脚本
  • 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 分享链接

  1. 启动/更新配置并运行 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 服务
  1. 配置定时任务(可选)

使用 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 文件。

About

基于 SBSM 和 Sing-Box 实现的动态 Sing-Box 配置文件

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published