diff options
author | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2018-06-05 14:41:02 +0000 |
---|---|---|
committer | Maxim Kuvyrkov <maxim.kuvyrkov@linaro.org> | 2018-06-05 14:41:02 +0000 |
commit | 609744cb3b7990126f91e1a8a84adf839dfcd03f (patch) | |
tree | 65dbc7620f107d603112bbb1239f013dd005f87b /tcwg-cleanup-stale-containers.sh | |
parent | 2e4fdbae2316426664cad36deb296e8386e732d6 (diff) |
tcwg-cleanup-stale-containers.sh: Handle non-zero return codes
... when no matches for "grep" or "killall" are found.
Change-Id: I800f06607e01c3a1d167ebdf9a2c3eaeb75559a1
Diffstat (limited to 'tcwg-cleanup-stale-containers.sh')
-rwxr-xr-x | tcwg-cleanup-stale-containers.sh | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/tcwg-cleanup-stale-containers.sh b/tcwg-cleanup-stale-containers.sh index d757cc5e..03281dc0 100755 --- a/tcwg-cleanup-stale-containers.sh +++ b/tcwg-cleanup-stale-containers.sh @@ -148,7 +148,7 @@ status=$(($status|(2*$res))) rm_volumes=($($DOCKER volume ls -q -f dangling=true)) # Filter-out named volumes like host-home and home-$USER. Leave only volumes # named like a sha1 hash. -rm_volumes=($(echo "${rm_volumes[@]}" | grep "^[a-f0-9]\{64\}\$")) +rm_volumes=($(echo "${rm_volumes[@]}" | grep "^[a-f0-9]\{64\}\$" | cat)) if [ ${#rm_volumes[@]} != 0 ]; then echo "Removing dangling volumes" @@ -198,7 +198,8 @@ fi # This cleanup has nothing to do with docker containers, but creating # a separate script/job for a one-liner doesn't seem to worth it. if [ "$cleanup_ssh_agent_hours" -gt "0" ]; then - killall --older-than ${cleanup_ssh_agent_hours}h -u $USER ssh-agent + res=0; killall --older-than ${cleanup_ssh_agent_hours}h -u $USER ssh-agent & + wait $! || res=$? fi # Check if we have more containers than max_containers |