diff --git a/README.md b/README.md
index 0424094..987cc31 100644
--- a/README.md
+++ b/README.md
@@ -1,8 +1,8 @@
# 项目介绍
+本项目基于[clash-for-linux](https://github.com/wnlen/clash-for-linux)再次开发,增加了 fish 的功能支持。
此项目是通过使用开源项目[clash](https://github.com/Dreamacro/clash)作为核心程序,再结合脚本实现简单的代理功能。
-主要是为了解决我们在服务器上下载GitHub等一些国外资源速度慢的问题。
# 使用须知
@@ -108,9 +108,6 @@ $ proxy_off
然后检查程序端口、进程以及环境变量`http_proxy|https_proxy`,若都没则说明服务正常关闭。
-
-
-
## Clash Dashboard
- 访问 Clash Dashboard
@@ -127,9 +124,6 @@ $ proxy_off
此 Clash Dashboard 使用的是[yacd](https://github.com/haishanh/yacd)项目,详细使用方法请移步到yacd上查询。
-
-
-
# 常见问题
1. 部分Linux系统默认的 shell `/bin/sh` 被更改为 `dash`,运行脚本会出现报错(报错内容一般会有 `-en [ OK ]`)。建议使用 `bash xxx.sh` 运行脚本。
diff --git a/scripts/get_cpu_arch.sh b/scripts/get_cpu_arch.sh
index 65d677f..4463c84 100755
--- a/scripts/get_cpu_arch.sh
+++ b/scripts/get_cpu_arch.sh
@@ -47,4 +47,4 @@ else
exitWithError "Unsupported Linux distribution"
fi
-echo "CPU architecture: $CpuArch"
+# echo "CPU architecture: $CpuArch"
diff --git a/start.sh b/start.sh
index c8fbc70..3d7f12b 100755
--- a/start.sh
+++ b/start.sh
@@ -33,8 +33,6 @@ export Temp_Dir
# 获取 CLASH_SECRET 值,如果不存在则生成一个随机数
Secret=${CLASH_SECRET:-$(openssl rand -hex 32)}
-
-
#################### 函数定义 ####################
# 自定义action函数,实现通用action功能
@@ -73,8 +71,6 @@ if_success() {
fi
}
-
-
#################### 任务执行 ####################
## 获取CPU架构信息
@@ -98,7 +94,7 @@ unset NO_PROXY
# create logs folder
if [ -d $Server_Dir"/logs" ]; then
- echo ""
+ echo "" > /dev/null
else
echo -e "\nlogs 文件夹缺失,正在创建..."
mkdir logs
@@ -106,20 +102,17 @@ fi
Actual_Conf="$Conf_Dir/config.yaml"
-# 获取文件的修改时间(秒级时间戳)
-modified_time=$(stat -c %Y "$Actual_Conf")
-
-# 获取当前时间(秒级时间戳)
-current_time=$(date +%s)
-
-# 计算文件修改时间距离现在的时间差(秒)
-time_diff=$((current_time - modified_time))
-
-# 计算24小时对应的秒数
-tf_hours=$((24 * 60 * 60))
-
if [ -f $Actual_Conf ]; then
- echo -e "\n正在检查先前配置文件"
+ # 获取文件的修改时间(秒级时间戳)
+ modified_time=$(stat -c %Y "$Actual_Conf")
+ # 获取当前时间(秒级时间戳)
+ current_time=$(date +%s)
+ # 计算文件修改时间距离现在的时间差(秒)
+ time_diff=$((current_time - modified_time))
+ # 计算24小时对应的秒数
+ tf_hours=$((24 * 60 * 60))
+
+ echo -e "正在检查先前配置文件"
if [ "$time_diff" -lt "$tf_hours" ]; then
echo -e "\n当前配置文件有效,跳过更新"
else
@@ -141,16 +134,16 @@ PID=`ps -ef | grep [c]lash-linux-a | awk '{print $2}'`
## Prevent clash instance is started again
if [ -z "$PID" ]; then
- echo -e "Clash isn't running"
+ echo -e "\nClash 未在运行"
else
- echo "Running clash detected."
- echo "Killing clash now. PID:"$PID
+ echo -e "\n已检测到正在运行的 Clash 实例"
+ echo -e "\n正在停止 Clash... PID:"$PID
sudo kill -9 $PID
fi
## 启动Clash服务
-echo -e '\n正在启动Clash服务...'
+echo -e '\n正在启动 Clash 服务...'
Text5="服务启动成功!"
Text6="服务启动失败!"
if [[ $CpuArch =~ "x86_64" || $CpuArch =~ "amd64" ]]; then
@@ -172,7 +165,7 @@ fi
# Output Dashboard access address and Secret
echo ''
-echo -e "Clash Dashboard 访问地址: http://:9090/ui"
+echo -e "Clash Dashboard 访问地址: http://localhost:9090/ui"
echo -e "Secret: ${Secret}"
echo ''
diff --git a/update.sh b/update.sh
index 6d78f35..825cde1 100644
--- a/update.sh
+++ b/update.sh
@@ -1,19 +1,55 @@
#!/bin/bash
+# 自定义action函数,实现通用action功能
+success() {
+ echo -en "\\033[60G[\\033[1;32m OK \\033[0;39m]\r"
+ return 0
+}
+
+failure() {
+ local rc=$?
+ echo -en "\\033[60G[\\033[1;31mFAILED\\033[0;39m]\r"
+ [ -x /bin/plymouth ] && /bin/plymouth --details
+ return $rc
+}
+
+action() {
+ local STRING rc
+
+ STRING=$1
+ echo -n "$STRING "
+ shift
+ "$@" && success $"$STRING" || failure $"$STRING"
+ rc=$?
+ echo
+ return $rc
+}
+
+# 函数,判断命令是否正常执行
+if_success() {
+ local ReturnStatus=$3
+ if [ $ReturnStatus -eq 0 ]; then
+ action "$1" /bin/true
+ else
+ action "$2" /bin/false
+ exit 1
+ fi
+}
+
## Clash 订阅地址检测及配置文件下载
# 检查url是否有效
echo -e '\n正在检测订阅地址...'
-Text1="Clash订阅地址可访问!"
-Text2="Clash订阅地址不可访问!"
+Text1="Clash 订阅地址可访问!"
+Text2="Clash 订阅地址不可访问!"
#curl -o /dev/null -s -m 10 --connect-timeout 10 -w %{http_code} $URL | grep '[23][0-9][0-9]' &>/dev/null
curl -o /dev/null -L -k -sS --retry 5 -m 10 --connect-timeout 10 -w "%{http_code}" $URL | grep -E '^[23][0-9]{2}$' &>/dev/null
ReturnStatus=$?
if_success $Text1 $Text2 $ReturnStatus
# 拉取更新config.yml文件
-echo -e '\n正在下载Clash配置文件...'
-Text3="配置文件config.yaml下载成功!"
-Text4="配置文件config.yaml下载失败,退出启动!"
+echo -e '\n正在下载 Clash 配置文件...'
+Text3="配置文件 config.yaml 下载成功!"
+Text4="配置文件 config.yaml 下载失败,退出启动!"
# 尝试使用curl进行下载
curl -L -k -sS --retry 5 -m 10 -o $Temp_Dir/clash.yaml $URL