diff --git a/CLAUDE.md b/CLAUDE.md index 51abb5f..dfaf51c 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -6,7 +6,7 @@ This file provides guidance to Claude Code (claude.ai/code) when working with co Personal collection of self-use shell scripts (个人收藏的自用脚本). Each top-level directory is an independent script project — there is no shared build system, package manager, test suite, or CI. Editing happens on Windows; the scripts themselves are deployed and executed on Linux VPS targets. -**Repo URL:** `https://git.suhang.me/suhang/scripts`. When writing docs/READMEs that contain `wget` / `curl` one-liners to fetch a script onto a server, point them at this repo's raw URL (e.g. `https://git.suhang.me/suhang/scripts/raw/branch/main/singbox/singbox.sh`) rather than upstream third-party URLs. This way users get the version actually maintained here. +**Repo URL:** `https://git.suhang.me/suhang/scripts`. **Default branch is `release`** (not `main`). When writing docs/READMEs that contain `wget` / `curl` one-liners to fetch a script onto a server, point them at this repo's raw URL on the `release` branch (e.g. `https://git.suhang.me/suhang/scripts/raw/branch/release/singbox/singbox.sh`) rather than upstream third-party URLs. This way users get the version actually maintained here. ## Layout diff --git a/singbox/README.md b/singbox/README.md index 5efb9a2..9fdb4a2 100644 --- a/singbox/README.md +++ b/singbox/README.md @@ -1,52 +1,25 @@ # singbox.sh -基于 [sing-box](https://github.com/SagerNet/sing-box) 的一键安装与管理脚本,提供交互式菜单来搭建、管理多种代理协议节点。 - -> 脚本作者:Mr. xiao([原项目地址](https://github.com/TinrLin))。本目录用于本地保存与备份,便于在不同 VPS 上快速部署。 -> -> 本仓库地址:,下方所有 `wget` / `curl` 命令均从该仓库直接拉取。 - -## 功能概览 - -支持的入站协议: - -- SOCKS / HTTP / Direct -- VMess / VLESS(含 Reality)/ Trojan -- Hysteria / Hysteria2 -- TUIC / Juicity -- ShadowTLS / NaiveProxy / Shadowsocks -- WireGuard(出站,用于解锁流媒体等) - -管理功能: - -- 查看已搭建节点信息(含分享链接 / Clash 配置) -- 更新内核(Latest / Beta / 编译安装完整功能版) -- 更新脚本自身 -- 申请 / 续签 TLS 证书(基于 acme.sh,支持 Let's Encrypt、ZeroSSL,HTTP-01 与 Cloudflare DNS-01) -- 重启 / 卸载服务 -- 节点管理(添加 / 删除单个用户或入站) -- 自动配置防火墙(ufw / iptables / firewalld) -- 自动开启 BBR +交互式管理脚本。下方仅记录安装与运行方式。 ## 系统要求 - Linux x86_64 / ARMv7 / ARM64 / AMD64v3 / s390x - 使用 systemd 的发行版(Debian 10+ / Ubuntu 20.04+ / CentOS 8+ / Rocky / AlmaLinux 等) -- 需要 root 权限 -- 公网 IPv4 或 IPv6(部分协议要求 80/443 端口可用于证书签发) +- root 权限 ## 依赖安装 -脚本运行时会调用以下命令,**请先确保已安装**(多数发行版默认包含 `bash` `tar` `systemctl` `iptables` 等): +脚本运行依赖以下命令(多数发行版默认包含 `bash` `tar` `systemctl` `iptables` 等): | 依赖 | 用途 | | --- | --- | -| `curl` / `wget` | 下载内核、调用 GitHub / Cloudflare API | -| `jq` | 解析 GitHub Release / Cloudflare API 的 JSON | -| `openssl` | 生成随机密钥、自签证书、TLS 探测 | -| `tar` | 解压内核压缩包 | -| `systemd` | 管理 sing-box / juicity 服务 | -| `cron` (`cronie` / `crontabs`) | 自动续签证书的定时任务 | +| `curl` / `wget` | 下载与 API 调用 | +| `jq` | 解析 JSON | +| `openssl` | 生成密钥、自签证书 | +| `tar` | 解压 | +| `systemd` | 服务管理 | +| `cron` (`cronie` / `crontabs`) | 定时任务 | ### Debian / Ubuntu @@ -69,87 +42,26 @@ pacman -Sy --noconfirm curl wget jq openssl tar cronie systemctl enable --now cronie ``` -> 选择「编译安装 sing-box(完整功能版本)」时,脚本会自动下载并安装 Go 编译器,无需额外安装。 -> -> 申请证书时若系统未安装 acme.sh,脚本会自动通过 `curl https://get.acme.sh | sh` 安装。 - -## 使用方式 - -### 1. 下载脚本 - -从本仓库直接下载到服务器(推荐放到 `/root/`): +## 一键执行 ```bash -# 方式一:直接下载脚本 -wget -O /root/singbox.sh https://git.suhang.me/suhang/scripts/raw/branch/main/singbox/singbox.sh -chmod +x /root/singbox.sh - -# 方式二:克隆整个仓库 -git clone https://git.suhang.me/suhang/scripts.git /root/scripts -chmod +x /root/scripts/singbox/singbox.sh +bash <(curl -fsSL https://git.suhang.me/suhang/scripts/raw/branch/release/singbox/singbox.sh) ``` -> 也可以使用 `curl`: -> ```bash -> curl -fsSL -o /root/singbox.sh https://git.suhang.me/suhang/scripts/raw/branch/main/singbox/singbox.sh && chmod +x /root/singbox.sh -> ``` - -### 2. 运行交互式菜单 +或使用 `wget`: ```bash -bash /root/singbox.sh +bash <(wget -qO- https://git.suhang.me/suhang/scripts/raw/branch/release/singbox/singbox.sh) ``` -进入菜单后按编号选择操作: +## 定时任务 -``` -[1] SOCKS [2] Direct -[3] HTTP [4] VMess -[5] VLESS [6] TUIC -[7] Juicity [8] Trojan -[9] Hysteria [10] Hysteria2 -[11] ShadowTLS [12] NaiveProxy -[13] Shadowsocks [14] WireGuard -[15] 查看节点信息 [16] 更新内核 -[17] 更新脚本 [18] 更新证书 -[19] 重启服务 [20] 节点管理 -[21] 卸载 [0] 退出 -``` - -### 3. 命令行参数 - -目前脚本仅支持一个非交互参数,用于定时任务续签证书: - -```bash -bash /root/singbox.sh 18 # 等同于菜单 [18] 更新证书 -``` - -脚本会自动写入 crontab,每周一凌晨 2 点执行该命令续签: +脚本会自动写入 crontab,每周一凌晨 2 点执行 `18`(续签证书): ```cron 0 2 * * 1 /bin/bash /root/singbox.sh >> /usr/local/etc/certificate.log 2>&1 ``` -## 路径与文件 - -| 路径 | 说明 | -| --- | --- | -| `/usr/local/bin/sing-box` | sing-box 主程序 | -| `/usr/local/bin/juicity-server` | Juicity 主程序(仅 Juicity 模式) | -| `/usr/local/etc/sing-box/config.json` | sing-box 配置文件 | -| `/usr/local/etc/sing-box/clash.yaml` | 自动生成的 Clash 订阅 | -| `/usr/local/etc/juicity/config.json` | Juicity 配置文件 | -| `/etc/ssl/private/` | TLS 证书与私钥 | -| `/etc/systemd/system/sing-box.service` | systemd 服务单元 | -| `/usr/local/etc/certificate.log` | 续签日志 | - -## 常见问题 - -- **菜单乱码**:终端使用 UTF-8(`export LANG=en_US.UTF-8` 或 `zh_CN.UTF-8`)。 -- **证书申请失败**:检查 80 端口是否被占用(HTTP-01),或使用 Cloudflare DNS API(需 API Token + Zone ID + Email)。 -- **节点不通**:脚本已自动放行所选端口,如使用云厂商安全组,请同步在面板放行 TCP/UDP。 -- **内核更新后无法启动**:`journalctl -u sing-box -n 100 --no-pager` 查看日志,多数为配置与新版内核字段不兼容,可重新搭建或回退版本。 - ## 卸载 -菜单选择 `[21] 卸载`,会停止并移除 sing-box / juicity 的二进制、配置目录与 systemd 服务。 +进入菜单后选择卸载选项即可移除二进制、配置目录与 systemd 服务。