优化启动脚本对订阅地址的探测、下载逻辑。
This commit is contained in:
parent
9927b5b1aa
commit
947d8343fc
37
start.sh
37
start.sh
|
@ -30,7 +30,8 @@ action() {
|
||||||
|
|
||||||
# 判断命令是否正常执行 函数
|
# 判断命令是否正常执行 函数
|
||||||
if_success() {
|
if_success() {
|
||||||
if [ $? -eq 0 ]; then
|
ReturnStatus=$3
|
||||||
|
if [ $ReturnStatus -eq 0 ]; then
|
||||||
action "$1" /bin/true
|
action "$1" /bin/true
|
||||||
else
|
else
|
||||||
action "$2" /bin/false
|
action "$2" /bin/false
|
||||||
|
@ -52,15 +53,33 @@ unset no_proxy
|
||||||
# 检查url是否有效
|
# 检查url是否有效
|
||||||
Text1="Clash订阅地址可访问!"
|
Text1="Clash订阅地址可访问!"
|
||||||
Text2="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
|
for i in {1..10}
|
||||||
if_success $Text1 $Text2
|
do
|
||||||
|
curl -o /dev/null -s -m 10 --connect-timeout 10 -w %{http_code} $URL | grep '[23][0-9][0-9]' &>/dev/null
|
||||||
|
ReturnStatus=$?
|
||||||
|
if [ $ReturnStatus -eq 0 ]; then
|
||||||
|
break
|
||||||
|
else
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if_success $Text1 $Text2 $ReturnStatus
|
||||||
|
|
||||||
# 拉取更新config.yml文件
|
# 拉取更新config.yml文件
|
||||||
Text3="配置文件config.yaml下载成功!"
|
Text3="配置文件config.yaml下载成功!"
|
||||||
Text4="配置文件config.yaml下载失败,退出启动!"
|
Text4="配置文件config.yaml下载失败,退出启动!"
|
||||||
# wget -q -O $Temp_Dir/clash.yaml $URL
|
for i in {1..10}
|
||||||
curl -s -o $Temp_Dir/clash.yaml $URL
|
do
|
||||||
if_success $Text3 $Text4
|
# wget -q -O $Temp_Dir/clash.yaml $URL
|
||||||
|
curl -s -o $Temp_Dir/clash.yaml $URL
|
||||||
|
ReturnStatus=$?
|
||||||
|
if [ $ReturnStatus -eq 0 ]; then
|
||||||
|
break
|
||||||
|
else
|
||||||
|
continue
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
if_success $Text3 $Text4 $ReturnStatus
|
||||||
|
|
||||||
# 取出代理相关配置
|
# 取出代理相关配置
|
||||||
sed -n '/^proxies:/,$p' $Temp_Dir/clash.yaml > $Temp_Dir/proxy.txt
|
sed -n '/^proxies:/,$p' $Temp_Dir/clash.yaml > $Temp_Dir/proxy.txt
|
||||||
|
@ -84,10 +103,12 @@ Text6="服务启动失败!"
|
||||||
get_arch=`/bin/arch`
|
get_arch=`/bin/arch`
|
||||||
if [[ $get_arch =~ "x86_64" ]]; then
|
if [[ $get_arch =~ "x86_64" ]]; then
|
||||||
nohup $Server_Dir/bin/clash-linux-amd64 -d $Conf_Dir &> $Log_Dir/clash.log &
|
nohup $Server_Dir/bin/clash-linux-amd64 -d $Conf_Dir &> $Log_Dir/clash.log &
|
||||||
if_success $Text5 $Text6
|
ReturnStatus=$?
|
||||||
|
if_success $Text5 $Text6 $ReturnStatus
|
||||||
elif [[ $get_arch =~ "aarch64" ]]; then
|
elif [[ $get_arch =~ "aarch64" ]]; then
|
||||||
nohup $Server_Dir/bin/clash-linux-armv7 -d $Conf_Dir &> $Log_Dir/clash.log &
|
nohup $Server_Dir/bin/clash-linux-armv7 -d $Conf_Dir &> $Log_Dir/clash.log &
|
||||||
if_success $Text5 $Text6
|
ReturnStatus=$?
|
||||||
|
if_success $Text5 $Text6 $ReturnStatus
|
||||||
else
|
else
|
||||||
echo -e "\033[31m[ERROR] Unsupported CPU Architecture!\033[0m"
|
echo -e "\033[31m[ERROR] Unsupported CPU Architecture!\033[0m"
|
||||||
exit 1
|
exit 1
|
||||||
|
|
Loading…
Reference in New Issue
Block a user