logo
0
0
WeChat Login
lihejia<lihejia@gmail.com>
fix: 修复 systemd 服务文件 heredoc 语法错误

Clash Install

一键安装 Clash 代理工具及其配置。

目录结构

clash-install/ ├── install.sh # 安装脚本 ├── gnome-proxy.sh # GNOME 系统代理控制脚本 ├── bashrc_additions.txt # .bashrc 配置片段 └── clash/ ├── clash # clash 二进制文件 ├── config.yaml # clash 配置文件 (需手动配置) ├── Country.mmdb # GeoIP 数据库 ├── LICENSE └── README.md

安装步骤

1. 下载并执行安装脚本

# 下载并解压本仓库 cd clash-install # 执行安装 bash install.sh

2. 配置 .bashrc

# 将配置添加到 ~/.bashrc cat bashrc_additions.txt >> ~/.bashrc # 重新加载 source ~/.bashrc

3. 配置 Clash

复制你的 Clash 配置文件到正确位置:

cp -f clash/config.yaml ~/.config/clash/config.yaml

注意: config.yaml 包含代理账户信息,请使用你自己的配置文件覆盖。

4. 启动 Clash

# 前台运行 clash # 或后台运行 clash &

5. 启用代理

# 开启代理 gproxy on # 关闭代理 gproxy off # 查看状态 gproxy status

使用方法

终端代理命令

proxy_on # 开启终端代理 proxy_off # 关闭终端代理 proxy_status # 查看代理状态

GNOME 系统代理命令

~/gnome-proxy.sh on # 开启系统代理 ~/gnome-proxy.sh off # 关闭系统代理 ~/gnome-proxy.sh status # 查看状态 ~/gnome-proxy.sh toggle # 切换状态 ~/gnome-proxy.sh install # 安装开机自启服务 ~/gnome-proxy.sh uninstall # 卸载开机自启服务 # 或使用快捷命令 (需先配置 .bashrc) gproxy on gproxy off gproxy status gproxy toggle # 开机自启管理命令 (安装后可用) gproxy-setup enable # 启用开机自启 gproxy-setup disable # 禁用开机自启 gproxy-setup status # 查看服务状态 gproxy-setup start # 立即启动服务 gproxy-setup stop # 停止服务

开机自启服务

安装服务

~/gnome-proxy.sh install

安装过程中会:

  1. 检测 Clash 和配置目录
  2. 创建 Systemd 用户服务
  3. 生成管理命令 gproxy-setup

管理服务

# 启用/禁用开机自启 gproxy-setup enable gproxy-setup disable # 控制服务 gproxy-setup start # 启动服务 gproxy-setup stop # 停止服务 gproxy-setup status # 查看状态 # 查看日志 journalctl --user -u clash.service -f

卸载服务

~/gnome-proxy.sh uninstall

注意事项

  1. 配置文件: clash/config.yaml 是模板文件,包含示例配置。安装后需要替换为你自己的配置文件。
  2. 首次使用: 确保先执行 install.sh 安装,再配置 config.yaml
  3. GNOME 桌面: gnome-proxy.sh 依赖 gsettings,仅适用于 GNOME 桌面环境。
  4. 开机自启: 需要 systemd 支持,适用于 Ubuntu 16.04+ 等现代 Linux 发行版。

卸载

手动删除以下内容:

rm -f ~/.local/bin/clash rm -f ~/gnome-proxy.sh # ~/.config/clash/ 目录可根据需要保留或删除

About

No description, topics, or website provided.
Language
Shell100%