summaryrefslogtreecommitdiff
path: root/tcwg-cleanup-stale-containers.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tcwg-cleanup-stale-containers.sh')
-rwxr-xr-xtcwg-cleanup-stale-containers.sh8
1 files changed, 6 insertions, 2 deletions
diff --git a/tcwg-cleanup-stale-containers.sh b/tcwg-cleanup-stale-containers.sh
index 86fc04b8..cc748c5c 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\}\$" | cat))
+rm_volumes=($(echo "${rm_volumes[@]}" | tr " " "\n" | grep "^[a-f0-9]\{64\}\$" | cat))
if [ ${#rm_volumes[@]} != 0 ]; then
echo "Removing dangling volumes"
@@ -200,6 +200,10 @@ fi
if [ "$cleanup_ssh_agent_hours" -gt "0" ]; then
res=0; killall --older-than ${cleanup_ssh_agent_hours}h -u $USER ssh-agent &
wait $! || res=$?
+ if [ $res != 0 ]; then
+ echo "WARNING: could not kill stale ssh-agent processes"
+ status=$(($status|16))
+ fi
fi
# Check if we have more containers than max_containers
@@ -207,7 +211,7 @@ nb_containers=$($DOCKER ps -a | wc -l)
if [ ${max_containers} -gt 0 -a ${nb_containers} -gt ${max_containers} ]; then
echo "ERROR: Too many containers left after cleanup: ${nb_containers} (max: ${max_containers})"
- status=$(($status|16))
+ status=$(($status|32))
fi
exit $status