diff --git a/README.md b/README.md index 8cd73b2..1005f43 100644 --- a/README.md +++ b/README.md @@ -94,6 +94,7 @@ OpenWrt 下 root/system 安装会把 `clashctl`、`clashon`、`clashoff` 等命 clashctl ls 📡 查看订阅列表 📌 高级 clashctl tun 🧪 Tun 模式管理 + clashctl boot 🚦 开机代理接管管理 clashctl mixin 🧩 Mixin 配置管理 clashctl relay 🔗 多跳节点管理 clashctl sub 🧩 订阅高级管理(启用 / 禁用 / 重命名 / 删除) @@ -159,6 +160,20 @@ clashctl sub remove <名称> WSL / 普通用户如果无权写入 `/etc/environment`,`clashon` 会自动降级:运行时照常启动,当前 Shell 代理变量生效;系统代理持久接管和开机代理保持不可用。 +### 开机接管(内核 + 代理) + +```bash +clashctl boot status +clashctl boot on +clashctl boot off +clashctl boot runtime on|off|status +clashctl boot proxy on|off|status +``` + +- `boot runtime`:只管理内核开机自启(systemd / systemd-user 可用,script 后端为 `unsupported`)。 +- `boot proxy`:只管理 `/etc/environment` 中的代理持久块(决定开机后是否自动保持代理变量)。 +- `boot`:整体接管开关,等价于同时编排 runtime + proxy 两层状态。 + ### 本地订阅 可以先手动下载 Clash 格式的订阅 YAML 文件到本地,再通过 `file://` 添加: diff --git a/scripts/core/proxy.sh b/scripts/core/proxy.sh index d0dace2..5d7c1d9 100644 --- a/scripts/core/proxy.sh +++ b/scripts/core/proxy.sh @@ -113,8 +113,14 @@ system_proxy_write_block() { mv -f "${tmp}.clean" "$tmp" if [ "$mode" = "on" ]; then - http_url="$(proxy_http_url)" - socks_url="$(proxy_socks_url)" + if ! http_url="$(proxy_http_url 2>/dev/null)"; then + rm -f "$tmp" 2>/dev/null || true + return 1 + fi + if ! socks_url="$(proxy_socks_url 2>/dev/null)"; then + rm -f "$tmp" 2>/dev/null || true + return 1 + fi no_proxy="$(proxy_no_proxy_value)" {