mirror of
https://github.com/wnlen/clash-for-linux.git
synced 2025-05-06 20:14:44 +08:00
feat: detects existing clash instances before it starts one
This commit is contained in:
parent
725d109594
commit
5530eaf4e4
0
bin/clash-linux-amd64
Normal file → Executable file
0
bin/clash-linux-amd64
Normal file → Executable file
0
bin/clash-linux-arm64
Normal file → Executable file
0
bin/clash-linux-arm64
Normal file → Executable file
0
bin/clash-linux-armv7
Normal file → Executable file
0
bin/clash-linux-armv7
Normal file → Executable file
BIN
conf/cache.db
Normal file
BIN
conf/cache.db
Normal file
Binary file not shown.
9679
conf/config.yaml
9679
conf/config.yaml
File diff suppressed because it is too large
Load Diff
4
restart.sh
Normal file → Executable file
4
restart.sh
Normal file → Executable file
|
@ -36,7 +36,7 @@ if_success() {
|
|||
fi
|
||||
}
|
||||
|
||||
# 定义路劲变量
|
||||
# 定义路径变量
|
||||
Server_Dir=$(cd $(dirname "${BASH_SOURCE[0]}") && pwd)
|
||||
Conf_Dir="$Server_Dir/conf"
|
||||
Log_Dir="$Server_Dir/logs"
|
||||
|
@ -45,7 +45,7 @@ Log_Dir="$Server_Dir/logs"
|
|||
Text1="服务关闭成功!"
|
||||
Text2="服务关闭失败!"
|
||||
# 查询并关闭程序进程
|
||||
PID_NUM=`ps -ef | grep [c]lash-linux-a | wc -l`
|
||||
PID_NUM=`PID_NUM=`ps -ef | grep [c]lash-linux-a | wc -l``
|
||||
PID=`ps -ef | grep [c]lash-linux-a | awk '{print $2}'`
|
||||
if [ $PID_NUM -ne 0 ]; then
|
||||
kill -9 $PID
|
||||
|
|
0
scripts/clash_profile_conversion.sh
Normal file → Executable file
0
scripts/clash_profile_conversion.sh
Normal file → Executable file
0
scripts/get_cpu_arch.sh
Normal file → Executable file
0
scripts/get_cpu_arch.sh
Normal file → Executable file
32
setup.sh
Executable file
32
setup.sh
Executable file
|
@ -0,0 +1,32 @@
|
|||
#!/bin/bash
|
||||
|
||||
echo -e "Run this with root permission!\n"
|
||||
|
||||
# 添加环境变量(root权限)
|
||||
cat>/etc/profile.d/clash.fish<<EOF
|
||||
# 开启系统代理
|
||||
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
|
||||
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"
|
||||
end
|
||||
|
||||
# 关闭系统代理
|
||||
function proxy_off
|
||||
set -e http_proxy
|
||||
set -e https_proxy
|
||||
set -e no_proxy
|
||||
set -e HTTP_PROXY
|
||||
set -e HTTPS_PROXY
|
||||
set -e NO_PROXY
|
||||
echo -e "\033[31m[×] 已关闭代理\033[0m"
|
||||
end
|
||||
EOF
|
||||
|
||||
echo -e "请执行以下命令加载环境变量: source /etc/profile.d/clash.fish\n"
|
||||
echo -e "请执行以下命令开启系统代理: proxy_on\n"
|
||||
echo -e "若要临时关闭系统代理,请执行: proxy_off\n"
|
0
shutdown.sh
Normal file → Executable file
0
shutdown.sh
Normal file → Executable file
38
start.sh
Normal file → Executable file
38
start.sh
Normal file → Executable file
|
@ -155,6 +155,16 @@ Dashboard_Dir="${Work_Dir}/dashboard/public"
|
|||
sed -ri "s@^# external-ui:.*@external-ui: ${Dashboard_Dir}@g" $Conf_Dir/config.yaml
|
||||
sed -r -i '/^secret: /s@(secret: ).*@\1'${Secret}'@g' $Conf_Dir/config.yaml
|
||||
|
||||
PID=`ps -ef | grep [c]lash-linux-a | awk '{print $2}'`
|
||||
|
||||
if [ -z "$PID" ]; then
|
||||
echo -e "Clash isn't running"
|
||||
else
|
||||
echo "Running clash detected."
|
||||
echo "Killing clash now. PID:"$PID
|
||||
|
||||
sudo kill -9 $PID
|
||||
fi
|
||||
|
||||
## 启动Clash服务
|
||||
echo -e '\n正在启动Clash服务...'
|
||||
|
@ -183,31 +193,3 @@ echo -e "Clash Dashboard 访问地址: http://<ip>:9090/ui"
|
|||
echo -e "Secret: ${Secret}"
|
||||
echo ''
|
||||
|
||||
# 添加环境变量(root权限)
|
||||
cat>/etc/profile.d/clash.sh<<EOF
|
||||
# 开启系统代理
|
||||
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
|
||||
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
|
||||
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"
|
||||
echo -e "若要临时关闭系统代理,请执行: proxy_off\n"
|
||||
|
|
|
@ -1,28 +0,0 @@
|
|||
# HTTP 代理端口
|
||||
port: 7890
|
||||
|
||||
# SOCKS5 代理端口
|
||||
socks-port: 7891
|
||||
|
||||
# Linux 和 macOS 的 redir 代理端口
|
||||
redir-port: 7892
|
||||
|
||||
# 允许局域网的连接
|
||||
allow-lan: true
|
||||
|
||||
# 规则模式:Rule(规则) / Global(全局代理)/ Direct(全局直连)
|
||||
mode: rule
|
||||
|
||||
# 设置日志输出级别 (默认级别:silent,即不输出任何内容,以避免因日志内容过大而导致程序内存溢出)。
|
||||
# 5 个级别:silent / info / warning / error / debug。级别越高日志输出量越大,越倾向于调试,若需要请自行开启。
|
||||
log-level: silent
|
||||
# Clash 的 RESTful API
|
||||
external-controller: '0.0.0.0:9090'
|
||||
|
||||
# RESTful API 的口令
|
||||
secret: 'b&ZlKTte5OnEt2Sn'
|
||||
|
||||
# 您可以将静态网页资源(如 clash-dashboard)放置在一个目录中,clash 将会服务于 `RESTful API/ui`
|
||||
# 参数应填写配置目录的相对路径或绝对路径。
|
||||
# external-ui: /code/clash-dashboard
|
||||
|
0
tools/subconverter/subconverter
Normal file → Executable file
0
tools/subconverter/subconverter
Normal file → Executable file
Loading…
Reference in New Issue
Block a user