mirror of
https://github.com/Websoft9/websoft9.git
synced 2024-11-22 07:30:24 +00:00
get fast url
This commit is contained in:
parent
e8da8b42c3
commit
76f952e1c5
1 changed files with 20 additions and 13 deletions
|
@ -311,9 +311,16 @@ function fastest_url() {
|
||||||
fastest_time=0
|
fastest_time=0
|
||||||
|
|
||||||
for url in "${urls[@]}"; do
|
for url in "${urls[@]}"; do
|
||||||
|
total_time=0
|
||||||
|
for i in {1..5}; do
|
||||||
time=$(curl -s -w '%{time_total}\n' -o /dev/null $url)
|
time=$(curl -s -w '%{time_total}\n' -o /dev/null $url)
|
||||||
if (( $(echo "$time < $fastest_time || $fastest_time == 0" | bc -l) )); then
|
total_time=$(echo "$total_time + $time" | bc -l)
|
||||||
fastest_time=$time
|
done
|
||||||
|
|
||||||
|
avg_time=$(echo "$total_time / 5" | bc -l)
|
||||||
|
|
||||||
|
if (( $(echo "$avg_time < $fastest_time || $fastest_time == 0" | bc -l) )); then
|
||||||
|
fastest_time=$avg_time
|
||||||
fastest_url=$url
|
fastest_url=$url
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
@ -321,7 +328,7 @@ function fastest_url() {
|
||||||
echo "$fastest_url"
|
echo "$fastest_url"
|
||||||
}
|
}
|
||||||
|
|
||||||
clone_repo() {
|
function clone_repo() {
|
||||||
url=$1
|
url=$1
|
||||||
path=$2
|
path=$2
|
||||||
for i in {1..5}
|
for i in {1..5}
|
||||||
|
@ -345,7 +352,7 @@ ParpareStaticFiles(){
|
||||||
|
|
||||||
echo "Parpare to install ..."
|
echo "Parpare to install ..."
|
||||||
fasturl=$(fastest_url "${urls[@]}")
|
fasturl=$(fastest_url "${urls[@]}")
|
||||||
echo "Fast url is: "$fasturl
|
echo "curl 5 times, avera fast url is: "$fasturl
|
||||||
|
|
||||||
# download apps
|
# download apps
|
||||||
mkdir -p /data/apps
|
mkdir -p /data/apps
|
||||||
|
|
Loading…
Reference in a new issue