add non-interactive flags to apt.
This replaces 'apt-get' calls with 'apt_get' function that just ensures that each call has flags to be non-interactive. This prevents potential prompts for conf file overwrites and such.
This commit is contained in:
parent
199d76e253
commit
ee1b495dc9
1 changed files with 15 additions and 7 deletions
22
stack.sh
22
stack.sh
|
@ -90,8 +90,8 @@ if [[ $EUID -eq 0 ]]; then
|
||||||
|
|
||||||
# since this script runs as a normal user, we need to give that user
|
# since this script runs as a normal user, we need to give that user
|
||||||
# ability to run sudo
|
# ability to run sudo
|
||||||
apt-get update
|
apt_get update
|
||||||
apt-get install -y sudo
|
apt_get install sudo
|
||||||
|
|
||||||
if ! getent passwd stack >/dev/null; then
|
if ! getent passwd stack >/dev/null; then
|
||||||
echo "Creating a user called stack"
|
echo "Creating a user called stack"
|
||||||
|
@ -143,6 +143,14 @@ if [ ! -n "$HOST_IP" ]; then
|
||||||
HOST_IP=`LC_ALL=C /sbin/ifconfig | grep -m 1 'inet addr:'| cut -d: -f2 | awk '{print $1}'`
|
HOST_IP=`LC_ALL=C /sbin/ifconfig | grep -m 1 'inet addr:'| cut -d: -f2 | awk '{print $1}'`
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
# apt-get wrapper to just get arguments set correctly
|
||||||
|
function apt_get() {
|
||||||
|
local sudo="sudo"
|
||||||
|
[ "$(id -u)" = "0" ] && sudo=""
|
||||||
|
$sudo DEBIAN_FRONTEND=noninteractive apt-get \
|
||||||
|
--option "Dpkg::Options::=--force-confold" --assume-yes "$@"
|
||||||
|
}
|
||||||
|
|
||||||
# Generic helper to configure passwords
|
# Generic helper to configure passwords
|
||||||
function read_password {
|
function read_password {
|
||||||
set +o xtrace
|
set +o xtrace
|
||||||
|
@ -283,8 +291,8 @@ fi
|
||||||
|
|
||||||
|
|
||||||
# install apt requirements
|
# install apt requirements
|
||||||
sudo apt-get update
|
apt_get update
|
||||||
sudo apt-get install -qqy `cat $FILES/apts/* | cut -d\# -f1 | grep -Ev "mysql-server|rabbitmq-server"`
|
apt_get install `cat $FILES/apts/* | cut -d\# -f1 | grep -Ev "mysql-server|rabbitmq-server"`
|
||||||
|
|
||||||
# install python requirements
|
# install python requirements
|
||||||
sudo PIP_DOWNLOAD_CACHE=/var/cache/pip pip install `cat $FILES/pips/*`
|
sudo PIP_DOWNLOAD_CACHE=/var/cache/pip pip install `cat $FILES/pips/*`
|
||||||
|
@ -353,7 +361,7 @@ if [[ "$ENABLED_SERVICES" =~ "rabbit" ]]; then
|
||||||
# Install and start rabbitmq-server
|
# Install and start rabbitmq-server
|
||||||
# the temp file is necessary due to LP: #878600
|
# the temp file is necessary due to LP: #878600
|
||||||
tfile=$(mktemp)
|
tfile=$(mktemp)
|
||||||
sudo apt-get install -y -q rabbitmq-server > "$tfile" 2>&1
|
apt_get install rabbitmq-server > "$tfile" 2>&1
|
||||||
cat "$tfile"
|
cat "$tfile"
|
||||||
rm -f "$tfile"
|
rm -f "$tfile"
|
||||||
# change the rabbit password since the default is "guest"
|
# change the rabbit password since the default is "guest"
|
||||||
|
@ -387,7 +395,7 @@ EOF
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Install and start mysql-server
|
# Install and start mysql-server
|
||||||
sudo apt-get -y -q install mysql-server
|
apt_get install mysql-server
|
||||||
# Update the DB to give user ‘$MYSQL_USER’@’%’ full control of the all databases:
|
# Update the DB to give user ‘$MYSQL_USER’@’%’ full control of the all databases:
|
||||||
sudo mysql -uroot -p$MYSQL_PASSWORD -e "GRANT ALL PRIVILEGES ON *.* TO '$MYSQL_USER'@'%' identified by '$MYSQL_PASSWORD';"
|
sudo mysql -uroot -p$MYSQL_PASSWORD -e "GRANT ALL PRIVILEGES ON *.* TO '$MYSQL_USER'@'%' identified by '$MYSQL_PASSWORD';"
|
||||||
|
|
||||||
|
@ -490,7 +498,7 @@ if [[ "$ENABLED_SERVICES" =~ "n-cpu" ]]; then
|
||||||
# splitting a system into many smaller parts. LXC uses cgroups and chroot
|
# splitting a system into many smaller parts. LXC uses cgroups and chroot
|
||||||
# to simulate multiple systems.
|
# to simulate multiple systems.
|
||||||
if [[ "$LIBVIRT_TYPE" == "lxc" ]]; then
|
if [[ "$LIBVIRT_TYPE" == "lxc" ]]; then
|
||||||
sudo apt-get install lxc -y
|
apt_get install lxc
|
||||||
# lxc uses cgroups (a kernel interface via virtual filesystem) configured
|
# lxc uses cgroups (a kernel interface via virtual filesystem) configured
|
||||||
# and mounted to ``/cgroup``
|
# and mounted to ``/cgroup``
|
||||||
sudo mkdir -p /cgroup
|
sudo mkdir -p /cgroup
|
||||||
|
|
Loading…
Reference in a new issue