summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorScott Dodson <sdodson@redhat.com>2016-06-29 15:54:58 -0400
committerGitHub <noreply@github.com>2016-06-29 15:54:58 -0400
commit49b286608a060cdc5fca45008d01ac3c535ce314 (patch)
treee65c5bc3da444c2d00590d96842d10488e4c7e3f
parenta9076e9bec8454251c3fc74dcc47b0b1f94db169 (diff)
parent56d77b5c62a1389b644ecc44871516562b9a1aa3 (diff)
downloadopenshift-49b286608a060cdc5fca45008d01ac3c535ce314.tar.gz
openshift-49b286608a060cdc5fca45008d01ac3c535ce314.tar.bz2
openshift-49b286608a060cdc5fca45008d01ac3c535ce314.tar.xz
openshift-49b286608a060cdc5fca45008d01ac3c535ce314.zip
Merge pull request #2096 from liangxia/master
Update conditional expression to save steps
-rw-r--r--playbooks/byo/openshift-cluster/upgrades/docker/files/nuke_images.sh16
1 files changed, 8 insertions, 8 deletions
diff --git a/playbooks/byo/openshift-cluster/upgrades/docker/files/nuke_images.sh b/playbooks/byo/openshift-cluster/upgrades/docker/files/nuke_images.sh
index 9a5ee2276..6b155f7fa 100644
--- a/playbooks/byo/openshift-cluster/upgrades/docker/files/nuke_images.sh
+++ b/playbooks/byo/openshift-cluster/upgrades/docker/files/nuke_images.sh
@@ -1,22 +1,22 @@
#!/bin/bash
# Stop any running containers
-running_container_count=`docker ps -q | wc -l`
-if test $running_container_count -gt 0
+running_container_ids=`docker ps -q`
+if test -n "$running_container_ids"
then
- docker stop $(docker ps -q)
+ docker stop $running_container_ids
fi
# Delete all containers
-container_count=`docker ps -a -q | wc -l`
-if test $container_count -gt 0
+container_ids=`docker ps -a -q`
+if test -n "$container_ids"
then
- docker rm -f -v $(docker ps -a -q)
+ docker rm -f -v $container_ids
fi
# Delete all images (forcefully)
-image_count=`docker images -q | wc -l`
-if test $image_count -gt 0
+image_ids=`docker images -q`
+if test -n "$image_ids"
then
# Taken from: https://gist.github.com/brianclements/f72b2de8e307c7b56689#gistcomment-1443144
docker rmi $(docker images | grep "$2/\|/$2 \| $2 \|$2 \|$2-\|$2_" | awk '{print $1 ":" $2}') 2>/dev/null || echo "No images matching \"$2\" left to purge."