prevent apt from asking the user any questions

Add additional options to really prevent apt from asking questions, which causes setup to hang because stdin/out have been redirected.

fixes #270, #291
This commit is contained in:
Joshua Tauberer 2015-02-13 13:41:52 +00:00
parent e096144713
commit d775f90f0c
5 changed files with 20 additions and 13 deletions

View File

@ -34,6 +34,7 @@ Setup:
* Install cron if it isn't already installed. * Install cron if it isn't already installed.
* Fix a units problem in the minimum memory check. * Fix a units problem in the minimum memory check.
* If you override the STORAGE_ROOT, your setting will now persist if you re-run setup. * If you override the STORAGE_ROOT, your setting will now persist if you re-run setup.
* Hangs due to apt wanting the user to resolve a conflict should now be fixed (apt will just clobber the problematic file now).
v0.06 (January 4, 2015) v0.06 (January 4, 2015)
----------------------- -----------------------

View File

@ -22,6 +22,20 @@ function hide_output {
rm -f $OUTPUT rm -f $OUTPUT
} }
function apt_get_quiet {
# Run apt-get in a totally non-interactive mode.
#
# Somehow all of these options are needed to get it to not ask the user
# questions about a) whether to proceed (-y), b) package options (noninteractive),
# and c) what to do about files changed locally (we don't cause that to happen but
# some VM providers muck with their images; -o).
#
# Although we could pass -qq to apt-get to make output quieter, many packages write to stdout
# and stderr things that aren't really important. Use our hide_output function to capture
# all of that and only show it if there is a problem (i.e. if apt_get returns a failure exit status).
DEBIAN_FRONTEND=noninteractive hide_output apt-get -y -o Dpkg::Options::="--force-confdef" -o Dpkg::Options::="--force-confnew" "$@"
}
function apt_install { function apt_install {
# Report any packages already installed. # Report any packages already installed.
PACKAGES=$@ PACKAGES=$@
@ -46,18 +60,10 @@ function apt_install {
echo installing $TO_INSTALL... echo installing $TO_INSTALL...
fi fi
# 'DEBIAN_FRONTEND=noninteractive' is to prevent dbconfig-common from asking you questions. # We still include the whole original package list in the apt-get command in
#
# Although we could pass -qq to apt-get to make output quieter, many packages write to stdout
# and stderr things that aren't really important. Use our hide_output function to capture
# all of that and only show it if there is a problem (i.e. if apt_get returns a failure exit status).
#
# Also note that we still include the whole original package list in the apt-get command in
# case it wants to upgrade anything, I guess? Maybe we can remove it. Doesn't normally make # case it wants to upgrade anything, I guess? Maybe we can remove it. Doesn't normally make
# a difference. # a difference.
DEBIAN_FRONTEND=noninteractive \ apt_get_quiet install $PACKAGES
hide_output \
apt-get -y install $PACKAGES
} }
function get_default_hostname { function get_default_hostname {

View File

@ -1,6 +1,6 @@
# Install the 'host', 'sed', and and 'nc' tools. This script is run before # Install the 'host', 'sed', and and 'nc' tools. This script is run before
# the rest of the system setup so we may not yet have things installed. # the rest of the system setup so we may not yet have things installed.
hide_output apt-get -y install bind9-host sed netcat-openbsd apt_get_quiet install bind9-host sed netcat-openbsd
# Stop if the PRIMARY_HOSTNAME is listed in the Spamhaus Domain Block List. # Stop if the PRIMARY_HOSTNAME is listed in the Spamhaus Domain Block List.
# The user might have chosen a name that was previously in use by a spammer # The user might have chosen a name that was previously in use by a spammer

View File

@ -4,7 +4,7 @@ if [ -z "$NONINTERACTIVE" ]; then
# e.g. if we piped a bootstrapping install script to bash to get started. In that # 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 # case, the nifty '[ -t 0 ]' test won't work. But with Vagrant we must suppress so we
# use a shell flag instead. Really supress any output from installing dialog. # use a shell flag instead. Really supress any output from installing dialog.
hide_output apt-get -y install dialog apt_get_quiet install dialog
message_box "Mail-in-a-Box Installation" \ message_box "Mail-in-a-Box Installation" \
"Hello and thanks for deploying a Mail-in-a-Box! "Hello and thanks for deploying a Mail-in-a-Box!
\n\nI'm going to ask you a few questions. \n\nI'm going to ask you a few questions.

View File

@ -9,7 +9,7 @@ source setup/functions.sh # load our functions
echo Updating system packages... echo Updating system packages...
hide_output apt-get update hide_output apt-get update
hide_output apt-get -y upgrade apt_get_quiet upgrade
# Install basic utilities. # Install basic utilities.
# #