init
This commit is contained in:
commit
e40250f242
8 files changed
+93
No files matched your search
+66
@@ -0,0 +1,66 @@
|
||||
#!/bin/bash
|
||||
|
||||
n1=$(wc -l < ./resource/config.yaml)
|
||||
if [ $n1 -lt 0 ]; then
|
||||
read -p '订阅链接:' url
|
||||
wget --no-check-certificate --timeout=3 -qo ./resource/config.yaml $url
|
||||
n2=$(wc -l < ./resource/config.yaml)
|
||||
if [ $n2 -eq 0 ]; then
|
||||
echo "链接无效,自行粘贴配置到./resource/config.yaml"
|
||||
fi
|
||||
fi
|
||||
|
||||
# gzip解压后不保留原文件
|
||||
cp ./resource/clash-linux-amd64-v3-2023.08.17.gz ./clash_copy
|
||||
# 解压
|
||||
gzip -d ./resource/clash-linux-amd64-v3-2023.08.17.gz
|
||||
# 可执行
|
||||
mv ./resource/clash-linux-amd64-v3-2023.08.17 /usr/local/bin/clash && chmod +x /usr/local/bin/clash
|
||||
mv ./clash_copy ./resource/clash-linux-amd64-v3-2023.08.17.gz
|
||||
|
||||
# clash配置目录
|
||||
mkdir -p /etc/clash
|
||||
tar -xf ./resource/yacd.tar.xz -C /etc/clash/
|
||||
/bin/cp -f ./resource/config.yaml /etc/clash/
|
||||
/bin/cp -f ./resource/Country.mmdb /etc/clash/
|
||||
/bin/cp -rf ./service/ /etc/clash/
|
||||
|
||||
# 创建服务配置文件
|
||||
cat << EOF > /etc/systemd/system/clash.service
|
||||
[Unit]
|
||||
Description=Clash 守护进程, Go 语言实现的基于规则的代理.
|
||||
After=network-online.target
|
||||
|
||||
[Service]
|
||||
Type=simple
|
||||
Restart=always
|
||||
ExecStart=/etc/clash/service/ExecStart.sh
|
||||
ExecStopPost=/etc/clash/service/ExecStopPost.sh
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
EOF
|
||||
|
||||
# 重新加载 systemd
|
||||
systemctl daemon-reload
|
||||
|
||||
# 开机自启clash
|
||||
systemctl enable clash
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "clash 设置自启成功!"
|
||||
else
|
||||
echo "clash 设置自启失败!"
|
||||
fi
|
||||
|
||||
# 启动clash服务
|
||||
systemctl start clash
|
||||
# 检查服务启动状态
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "clash 启动!"
|
||||
else
|
||||
echo "clash 启动失败!"
|
||||
fi
|
||||
|
||||
# ui面板
|
||||
chmod +x ./ui.sh
|
||||
bash ./ui.sh
|
||||
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,11 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 环境变量 设置代理
|
||||
cat << EOF > /etc/profile.d/clash.sh
|
||||
export http_proxy=http://127.0.0.1:7890
|
||||
export https_proxy=http://127.0.0.1:7890
|
||||
EOF
|
||||
source /etc/profile.d/clash.sh
|
||||
|
||||
# clash 启动!
|
||||
/usr/local/bin/clash -d /etc/clash -ext-ui public
|
||||
@@ -0,0 +1,4 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "" > /etc/profile.d/clash.sh;
|
||||
source /etc/profile
|
||||
@@ -0,0 +1,4 @@
|
||||
ip=$(curl -s ifconfig.cc | grep -oE "\b([0-9]{1,3}\.){3}[0-9]{1,3}\b")
|
||||
|
||||
# 输出变量中的IP地址
|
||||
echo "clash面板地址:http://$ip:9090/ui"
|
||||
@@ -0,0 +1,8 @@
|
||||
systemctl stop clash
|
||||
rm -rf /etc/clash
|
||||
rm -f /etc/profile.d/clash.sh
|
||||
source /etc/profile
|
||||
rm -f /etc/systemd/system/clash.service
|
||||
rm -f /usr/local/bin/clash
|
||||
systemctl daemon-reload
|
||||
echo clash已卸载,相关配置已清除!
|
||||
Reference in new issue
Block a user