From 4ed69cbae59e39fecfb71d6c30d49cc1e2b886d8 Mon Sep 17 00:00:00 2001 From: Joshua Tauberer Date: Mon, 25 Aug 2014 07:54:11 -0400 Subject: [PATCH] replace '-t 0' test with an environment variable since '-t 0' is false when standard input has been redirected and doesn't tell us whether or not we can use dialog for input, but Vagrant must be non-interactive --- Vagrantfile | 1 + setup/start.sh | 9 +++++---- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/Vagrantfile b/Vagrantfile index ea8464dd..2a21dd08 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -18,6 +18,7 @@ Vagrant.configure("2") do |config| # machine figure out its own public IP and it'll take a # subdomain on our justtesting.email domain so we can get # started quickly. + export NONINTERACTIVE=1 export PUBLIC_IP=auto export PUBLIC_IPV6=auto export PRIMARY_HOSTNAME=auto-easy diff --git a/setup/start.sh b/setup/start.sh index 8260ca38..ab9c5f25 100755 --- a/setup/start.sh +++ b/setup/start.sh @@ -36,11 +36,12 @@ if [ ! -d /vagrant ]; then fi fi -if [ -t 0 ]; then - # In an interactive shell... +if [ -z "$NONINTERACTIVE" ]; then # Install 'dialog' so we can ask the user questions. The original motivation for # this was being able to ask the user for input even if stdin has been redirected, - # e.g. if we piped a bootstrapping install script to bash to get started. + # e.g. if we piped a bootstrapping install script to bash to get started. In that + # case, the nifty '[ -t 0 ]' test won't work. But with Vagrant we must suppress so we + # use a shell flag instead. apt_install dialog message_box "Mail-in-a-Box Installation" \ "Hello and thanks for deploying a Mail-in-a-Box! @@ -317,7 +318,7 @@ if [ -z "`tools/mail.py user`" ]; then # If we didn't ask for an email address at the start, do so now. if [ -z "$EMAIL_ADDR" ]; then # In an interactive shell, ask the user for an email address. - if [ -t 0 ]; then + if [ -z "$NONINTERACTIVE" ]; then input_box "Mail Account" \ "Let's create your first mail account. \n\nWhat email address do you want?" \