Skip to content

Commit

Permalink
docker-compose setup: make it possible to run in non-interactive way
Browse files Browse the repository at this point in the history
  • Loading branch information
flavio committed Sep 15, 2015
1 parent 529e5dd commit c9dd3e4
Showing 1 changed file with 36 additions and 11 deletions.
47 changes: 36 additions & 11 deletions compose-setup.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,23 +30,48 @@ setup_database() {

clean() {
echo "The setup will destroy the containers used by Portus, removing also their volumes."
while true; do
read -p "Are you sure to delete all the data? (Y/N)" yn
case $yn in
[Yy]* )
docker-compose kill
docker-compose rm -fv
break;;
[Nn]* ) exit 1;;
* ) echo "Please answer yes or no.";;
esac
done
if [ $FORCE -ne 1 ]; then
while true; do
read -p "Are you sure to delete all the data? (Y/N)" yn
case $yn in
[Yy]* )
break;;
[Nn]* ) exit 1;;
* ) echo "Please answer yes or no.";;
esac
done
fi

docker-compose kill
docker-compose rm -fv
}

usage() {
echo "Usage: $0 [-f]"
echo " -f force removal of data"
}

DOCKER_HOST=${DOCKER_HOST=$(hostname -f)}
echo "DOCKER_HOST=${DOCKER_HOST}" > docker/environment

FORCE=0
while getopts "fh" opt; do
case "${opt}" in
f)
FORCE=1
;;
h)
usage
exit 0
;;
*)
echo "Invalid option: -$OPTARG" >&2
usage
exit 1
;;
esac
done

clean
docker-compose up -d

Expand Down

0 comments on commit c9dd3e4

Please sign in to comment.