diff --git a/bootstrap/sbin/rebuild_system_from_scratch.sh b/bootstrap/sbin/rebuild_system_from_scratch.sh index 8840c5a11d1863abe2e94cdda6268b9801d14d10..8335ba864b09c3008e1af310e1394d57dc6293fa 100755 --- a/bootstrap/sbin/rebuild_system_from_scratch.sh +++ b/bootstrap/sbin/rebuild_system_from_scratch.sh @@ -1,4 +1,4 @@ -#! /usr/bin/env bash -e +#! /usr/bin/env bash HOME_DIR=${LOFAR20_DIR:-${PWD}} if [ ! -d ${HOME_DIR}/bootstrap ]; then @@ -7,6 +7,25 @@ if [ ! -d ${HOME_DIR}/bootstrap ]; then exit 1 fi +# Check if Docker compose can be found. +DOCKER_COMPOSE="docker compose version" +${DOCKER_COMPOSE} >&/dev/null +ret=${?} +if [ ${ret} -ne 0 ]; then + DOCKER_COMPOSE="docker-compose version" + ${DOCKER_COMPOSE} >&/dev/null + ret=${?} +fi +if [ ${ret} -eq 0 ]; then + echo -e "\tFound Docker Compose: ${DOCKER_COMPOSE}" +else + echo -e "\tThis system appears to not have Docker compose installed. This means that the system cannot be rebuilt with this script." + return 1 +fi + +# Any error should terminate this script. +set -e + # Save for the moment when tango will be cloned. OLD_HOME_DIR=${HOME_DIR}.old @@ -30,7 +49,13 @@ function move_tango_dir_out_of_the_way() function remove_images() { - ${HOME_DIR}/bootstrap/sbin/delete_all_docker_images.sh YES_DELETE_ALL + images="$(for i in $(docker images -q); do printf "%s " ${i}; done)" + if [ ${#images} -eq 0 ]; then + echo -e "\tThere are no images to delete." + else + echo -e "\tWill now delete the Docker images:" + docker rmi -f ${images} + fi } function pull_tango()