Add update flow, pidfile handling, and systemd unit

This commit is contained in:
wnlen
2026-01-13 23:17:27 +08:00
parent 4861cc40e5
commit 864841ef3c
6 changed files with 392 additions and 37 deletions

View File

@ -16,6 +16,9 @@
- 本项目是基于 [clash](https://github.com/Dreamacro/clash) 、[yacd](https://github.com/haishanh/yacd) 进行的配置整合关于clash、yacd的详细配置请去原项目查看。
- 此项目不提供任何订阅信息请自行准备Clash订阅地址。
- 运行前请手动更改`.env`文件中的`CLASH_URL`变量值,否则无法正常运行。
- 默认将管理面板仅绑定到本机(`127.0.0.1:9090`),如需对外访问请在`.env`中自行配置并确保`CLASH_SECRET`足够复杂。
- 默认开启 TLS 证书校验,若确需跳过校验请在`.env`中设置`ALLOW_INSECURE_TLS=true`(不推荐)。
- 如从旧版本升级,若存在 `/etc/profile.d/clash.sh` 请按需清理或改用新的 `/etc/profile.d/clash-for-linux.sh`
- 当前在RHEL系列和Debian系列Linux系统中测试过其他系列可能需要适当修改脚本。
- 支持 x86_64/aarch64 平台
@ -71,7 +74,7 @@ Clash订阅地址可访问 [ OK ]
Clash Dashboard 访问地址http://<ip>:9090/ui
Secretxxxxxxxxxxxxx
请执行以下命令加载环境变量: source /etc/profile.d/clash.sh
请执行以下命令加载环境变量: source /etc/profile.d/clash-for-linux.sh
请执行以下命令开启系统代理: proxy_on
@ -80,7 +83,7 @@ Secretxxxxxxxxxxxxx
```
```bash
$ source /etc/profile.d/clash.sh
$ source /etc/profile.d/clash-for-linux.sh
$ proxy_on
```
@ -113,6 +116,20 @@ https_proxy=http://127.0.0.1:7890
> **注意:**
> 重启脚本 `restart.sh` 不会更新订阅信息。
如需更新订阅并重启,可执行:
```bash
$ sudo bash restart.sh --update
```
## 更新订阅
如只需更新订阅配置但不重启服务,可执行:
```bash
$ sudo bash update.sh
```
<br>
## 停止程序
@ -138,6 +155,30 @@ $ proxy_off
然后检查程序端口、进程以及环境变量`http_proxy|https_proxy`,若都没则说明服务正常关闭。
<br>
## systemd 服务
将仓库中的 `systemd/clash-for-linux.service` 复制到 `/etc/systemd/system/`,并根据实际路径修改 `WorkingDirectory` 与脚本路径:
```bash
$ sudo cp systemd/clash-for-linux.service /etc/systemd/system/
$ sudo vim /etc/systemd/system/clash-for-linux.service
```
启用并启动服务:
```bash
$ sudo systemctl daemon-reload
$ sudo systemctl enable --now clash-for-linux.service
```
停止服务:
```bash
$ sudo systemctl stop clash-for-linux.service
```
<br>