|
|
@ -33,8 +33,40 @@ mirrors=( |
|
|
|
# function |
|
|
|
# function |
|
|
|
###################################################################################################### |
|
|
|
###################################################################################################### |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function shutdown() { |
|
|
|
|
|
|
|
tput cnorm # reset cursor |
|
|
|
|
|
|
|
ps -ef | grep "$0" | awk '{print $2}' | xargs kill -9 '{}' >/dev/null 2>&1 |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
trap shutdown EXIT |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function spinner() { |
|
|
|
|
|
|
|
# make sure we use non-unicode character type locale |
|
|
|
|
|
|
|
# (that way it works for any locale as long as the font supports the characters) |
|
|
|
|
|
|
|
local LC_CTYPE=C |
|
|
|
|
|
|
|
speed_test "$@" & |
|
|
|
|
|
|
|
sleep 1 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local pid=$(ps -ef | grep -E '[w]get.*-4O /dev/null -T300' | awk '{print $2}') # Process Id of the previous running command |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local spin='◐◓◑◒' |
|
|
|
|
|
|
|
local charwidth=3 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
local i=0 |
|
|
|
|
|
|
|
tput civis # cursor invisible |
|
|
|
|
|
|
|
while kill -0 $pid 2>/dev/null; do |
|
|
|
|
|
|
|
local i=$(((i + $charwidth) % ${#spin})) |
|
|
|
|
|
|
|
printf "%s" "${spin:$i:$charwidth}" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
echo -en "\033[1D" |
|
|
|
|
|
|
|
sleep .1 |
|
|
|
|
|
|
|
done |
|
|
|
|
|
|
|
tput cnorm |
|
|
|
|
|
|
|
wait |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
speed_test() { |
|
|
|
speed_test() { |
|
|
|
local output=$(LANG=C wget --header="$3" -4O /dev/null -T300 "$1" 2>&1) |
|
|
|
local output=$(LANG=C wget ${3:+"--header="}"$3" -4O /dev/null -T300 "$1" 2>&1) |
|
|
|
local speed=$(printf '%s' "$output" | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}') |
|
|
|
local speed=$(printf '%s' "$output" | awk '/\/dev\/null/ {speed=$3 $4} END {gsub(/\(|\)/,"",speed); print speed}') |
|
|
|
local ipaddress=$(printf '%s' "$output" | awk -F'|' '/Connecting to .*\|([^\|]+)\|/ {print $2}'| tail -1) |
|
|
|
local ipaddress=$(printf '%s' "$output" | awk -F'|' '/Connecting to .*\|([^\|]+)\|/ {print $2}'| tail -1) |
|
|
|
local time=$(printf '%s' "$output" | awk -F= '/100% / {print $2}') |
|
|
|
local time=$(printf '%s' "$output" | awk -F= '/100% / {print $2}') |
|
|
@ -80,7 +112,9 @@ for mirror in ${!mirrors[*]}; do |
|
|
|
image_manifests=$(curl -s "${mirror}/v2/library/${image_name}/manifests/${image_tag}" | awk -F'"' '/"blobSum":/ {print $4}') |
|
|
|
image_manifests=$(curl -s "${mirror}/v2/library/${image_name}/manifests/${image_tag}" | awk -F'"' '/"blobSum":/ {print $4}') |
|
|
|
image_layer=$( echo $resp | tr ' ' '\n' | sort -u | head -1) |
|
|
|
image_layer=$( echo $resp | tr ' ' '\n' | sort -u | head -1) |
|
|
|
fi |
|
|
|
fi |
|
|
|
speed_test "${mirrors[$mirror]}/v2/${image_name}/blobs/${image_layer}" ${mirror} |
|
|
|
spinner "${mirrors[$mirror]}/v2/${image_name}/blobs/${image_layer}" ${mirror} |
|
|
|
done |
|
|
|
done |
|
|
|
speed_test "https://registry-1.docker.io/v2/${image_name}/blobs/${image_layer}" "docker" "Authorization: Bearer $docker_token" |
|
|
|
|
|
|
|
|
|
|
|
spinner "https://registry-1.docker.io/v2/${image_name}/blobs/${image_layer}" "docker" "Authorization: Bearer $docker_token" |
|
|
|
echo |
|
|
|
echo |
|
|
|
|
|
|
|
|
|
|
|