From 699defd0b0d3ba7be79fa30af181e41533810318 Mon Sep 17 00:00:00 2001 From: lework Date: Wed, 18 Mar 2020 14:46:52 +0800 Subject: [PATCH] fix exit --- shell/docker_hub_speed_test.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/shell/docker_hub_speed_test.sh b/shell/docker_hub_speed_test.sh index f62701c..218fd9c 100644 --- a/shell/docker_hub_speed_test.sh +++ b/shell/docker_hub_speed_test.sh @@ -35,10 +35,16 @@ mirrors=( function shutdown() { tput cnorm # reset cursor +} + + +function error() { ps -ef | grep "$0" | awk '{print $2}' | xargs kill -9 '{}' >/dev/null 2>&1 } trap shutdown EXIT +trap error ERR 2 3 + function spinner() { # make sure we use non-unicode character type locale @@ -112,7 +118,7 @@ for mirror in ${!mirrors[*]}; do 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) fi - spinner "${mirrors[$mirror]}/v2/${image_name}/blobs/${image_layer}" ${mirror} + #spinner "${mirrors[$mirror]}/v2/${image_name}/blobs/${image_layer}" ${mirror} done spinner "https://registry-1.docker.io/v2/${image_name}/blobs/${image_layer}" "docker" "Authorization: Bearer $docker_token"