From 16c0a9d342c139dc4f98f23c269a3c863244eb02 Mon Sep 17 00:00:00 2001 From: Joshua Tauberer Date: Thu, 1 May 2014 22:16:14 -0400 Subject: [PATCH] docker: if container was launched with a tty start bash otherwise loop forever to keep the container going --- containers/docker/start_services.sh | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/containers/docker/start_services.sh b/containers/docker/start_services.sh index 137b9c8e..25639aaa 100644 --- a/containers/docker/start_services.sh +++ b/containers/docker/start_services.sh @@ -8,5 +8,22 @@ service opendkim start service nginx start service php-fastcgi start -echo "Your Mail-in-a-Box is running." -bash +if [ -t 0 ] +then + # This is an interactive shell. You get a command prompt within + # the container. + # + # You get here by running 'docker run -i -t'. + + echo "Welcome to your Mail-in-a-Box." + bash + +else + # This is a non-interactive shell. It loops forever to prevent + # the docker container from stopping. + # + # You get here by omitting '-t' from the docker run arguments. + + echo "Your Mail-in-a-Box is running..." + while true; do sleep 10; done +fi