浏览代码

fasturl improve

qiaofeng1227 2 年之前
父节点
当前提交
1d81684850
共有 2 个文件被更改,包括 13 次插入1 次删除
  1. 6 0
      install/install.sh
  2. 7 1
      install/update.sh

+ 6 - 0
install/install.sh

@@ -322,6 +322,12 @@ function fastest_url() {
   fastest_time=0
 
   for url in "${urls[@]}"; do
+    if curl --output /dev/null --silent --head --fail "$url"; then
+        echo $url" is available"
+    else
+        echo $url" is not available"
+        continue
+    fi 
     time=$(curl --connect-timeout 3 -s -w '%{time_total}\n' -o /dev/null $url)
     if (( $(echo "$time < $fastest_time || $fastest_time == 0" | bc -l) )); then
       fastest_time=$time

+ 7 - 1
install/update.sh

@@ -77,7 +77,13 @@ function fastest_url() {
   fastest_time=0
 
   for url in "${urls[@]}"; do
-    time=$(curl -s -w '%{time_total}\n' -o /dev/null $url)
+    if curl --output /dev/null --silent --head --fail "$url"; then
+        echo $url" is available"
+    else
+        echo $url" is not available"
+        continue
+    fi 
+    time=$(curl --connect-timeout 3 -s -w '%{time_total}\n' -o /dev/null $url)
     if (( $(echo "$time < $fastest_time || $fastest_time == 0" | bc -l) )); then
       fastest_time=$time
       fastest_url=$url