mirror of
https://github.com/csznet/goForward.git
synced 2025-09-26 19:31:11 +08:00
get sh
This commit is contained in:
16
get.sh
16
get.sh
@@ -26,8 +26,20 @@ if ! command -v unzip &> /dev/null; then
|
||||
fi
|
||||
fi
|
||||
|
||||
# 获取百度的平均延迟(ping 5次并取平均值)
|
||||
ping_result=$(ping -c 5 -q baidu.com | awk -F'/' 'END{print $5}')
|
||||
|
||||
# 判断延迟是否在100以内
|
||||
if awk -v ping="$ping_result" 'BEGIN{exit !(ping < 100)}'; then
|
||||
echo "服务器位于中国国内,使用代理下载"
|
||||
url="https://mirror.ghproxy.com/https://github.com/csznet/goForward/releases/latest/download/${FILE}"
|
||||
else
|
||||
echo "服务器位于国外,不使用代理下载"
|
||||
url="https://github.com/csznet/goForward/releases/latest/download/${FILE}"
|
||||
fi
|
||||
|
||||
# Download and unzip
|
||||
if ! wget "https://github.com/csznet/goForward/releases/latest/download/$FILE"; then
|
||||
if ! wget $url; then
|
||||
echo -e "\e[41mError\e[0m: Failed to download $FILE. Please check your internet connection or try again later."
|
||||
exit 1
|
||||
fi
|
||||
@@ -43,4 +55,4 @@ rm "$FILE"
|
||||
chmod +x goForward
|
||||
|
||||
# Output success message
|
||||
echo -e "\e[44mSuccess\e[0m: The 'goForward' executable is ready for use."
|
||||
echo -e "\e[44mSuccess\e[0m: The 'goForward' executable is ready for use."
|
Reference in New Issue
Block a user