Optimize the system proxy opening method.

This commit is contained in:
wanhebin 2022-12-09 16:26:48 +08:00
parent e289381339
commit 2d533ecb1e
3 changed files with 34 additions and 10 deletions

View File

@ -39,16 +39,22 @@ $ cd clash-for-linux
```bash ```bash
$ sh start.sh $ sh start.sh
Clash订阅地址可访问 [ OK ]
配置文件config.yaml下载成功 [ OK ] 配置文件config.yaml下载成功 [ OK ]
服务启动成功! [ OK ] 服务启动成功! [ OK ]
系统代理http_proxy/https_proxy设置成功请在当前窗口执行以下命令加载环境变量:
source /etc/profile.d/clash.sh Clash Dashboard 访问地址http://IP:9090/ui
Secretxxxxxxxxxxxxx
请执行以下命令加载环境变量: source /etc/profile.d/clash.sh
请执行以下命令开启系统代理: proxy_on
``` ```
```bash ```bash
$ source /etc/profile.d/clash.sh $ source /etc/profile.d/clash.sh
$ proxy_on
``` ```
- 检查服务端口 - 检查服务端口
@ -86,14 +92,13 @@ $ cd clash-for-linux
```bash ```bash
$ sh shutdown.sh $ sh shutdown.sh
服务关闭成功,请在已打开的窗口执行以下命令:
unset http_proxy 服务关闭成功请执行以下命令关闭系统代理proxy_off
unset https_proxy
``` ```
```bash ```bash
$ unset http_proxy $ proxy_off
$ unset https_proxy
``` ```
然后检查程序端口、进程以及环境变量`http_proxy|https_proxy`,若都没则说明服务正常关闭。 然后检查程序端口、进程以及环境变量`http_proxy|https_proxy`,若都没则说明服务正常关闭。

View File

@ -11,4 +11,4 @@ fi
# 清除环境变量 # 清除环境变量
> /etc/profile.d/clash.sh > /etc/profile.d/clash.sh
echo -e "服务关闭成功,请在已打开的窗口执行以下命令:\nunset http_proxy\nunset https_proxy\nunset no_proxy" echo -e "\n服务关闭成功请执行以下命令关闭系统代理proxy_off\n"

View File

@ -100,5 +100,24 @@ echo -e "Secret${Secret}"
echo '' echo ''
# 添加环境变量(root权限) # 添加环境变量(root权限)
echo -e "export http_proxy=http://127.0.0.1:7890\nexport https_proxy=http://127.0.0.1:7890\nexport no_proxy=127.0.0.1,localhost" > /etc/profile.d/clash.sh cat>/etc/profile.d/clash.sh<<EOF
echo -e "系统代理http_proxy/https_proxy/no_proxy设置成功请在当前窗口执行以下命令加载环境变量:\n\nsource /etc/profile.d/clash.sh\n" # 开启系统代理
function proxy_on() {
export http_proxy=http://127.0.0.1:7890
export https_proxy=http://127.0.0.1:7890
export no_proxy=127.0.0.1,localhost
echo -e "\033[32m[√] 已开启代理\033[0m"
}
# 关闭系统代理
function proxy_off(){
unset http_proxy
unset https_proxy
unset no_proxy
echo -e "\033[31m[×] 已关闭代理\033[0m"
}
EOF
echo -e "请执行以下命令加载环境变量: source /etc/profile.d/clash.sh\n"
echo -e "请执行以下命令开启系统代理: proxy_on\n"