Skip to content

Commit

Permalink
Merge "Preinstall yum-utils; move sudo check before install"
Browse files Browse the repository at this point in the history
  • Loading branch information
Jenkins authored and openstack-gerrit committed Feb 28, 2014
2 parents 3208d7a + 531aeb7 commit 9bd5b93
Showing 1 changed file with 46 additions and 45 deletions.
91 changes: 46 additions & 45 deletions stack.sh
Expand Up @@ -165,9 +165,42 @@ fi
# Set up logging level
VERBOSE=$(trueorfalse True $VERBOSE)

# root Access
# -----------

# OpenStack is designed to be run as a non-root user; Horizon will fail to run
# as **root** since Apache will not serve content from **root** user).
# ``stack.sh`` must not be run as **root**. It aborts and suggests one course of
# action to create a suitable user account.

if [[ $EUID -eq 0 ]]; then
echo "You are running this script as root."
echo "Cut it out."
echo "Really."
echo "If you need an account to run DevStack, do this (as root, heh) to create $STACK_USER:"
echo "$TOP_DIR/tools/create-stack-user.sh"
exit 1
fi

# We're not **root**, make sure ``sudo`` is available
is_package_installed sudo || install_package sudo

# UEC images ``/etc/sudoers`` does not have a ``#includedir``, add one
sudo grep -q "^#includedir.*/etc/sudoers.d" /etc/sudoers ||
echo "#includedir /etc/sudoers.d" | sudo tee -a /etc/sudoers

# Set up devstack sudoers
TEMPFILE=`mktemp`
echo "$STACK_USER ALL=(root) NOPASSWD:ALL" >$TEMPFILE
# Some binaries might be under /sbin or /usr/sbin, so make sure sudo will
# see them by forcing PATH
echo "Defaults:$STACK_USER secure_path=/sbin:/usr/sbin:/usr/bin:/bin:/usr/local/sbin:/usr/local/bin" >> $TEMPFILE
chmod 0440 $TEMPFILE
sudo chown root:root $TEMPFILE
sudo mv $TEMPFILE /etc/sudoers.d/50_stack_sh

# Additional repos
# ================
# ----------------

# Some distros need to add repos beyond the defaults provided by the vendor
# to pick up required packages.
Expand Down Expand Up @@ -200,45 +233,13 @@ if [[ is_fedora && $DISTRO =~ (rhel6) ]]; then
fi

# ... and also optional to be enabled
is_package_installed yum-utils || install_package yum-utils
sudo yum-config-manager --enable rhel-6-server-optional-rpms

fi


# root Access
# -----------

# OpenStack is designed to be run as a non-root user; Horizon will fail to run
# as **root** since Apache will not serve content from **root** user).
# ``stack.sh`` must not be run as **root**. It aborts and suggests one course of
# action to create a suitable user account.

if [[ $EUID -eq 0 ]]; then
echo "You are running this script as root."
echo "Cut it out."
echo "Really."
echo "If you need an account to run DevStack, do this (as root, heh) to create $STACK_USER:"
echo "$TOP_DIR/tools/create-stack-user.sh"
exit 1
fi

# We're not **root**, make sure ``sudo`` is available
is_package_installed sudo || install_package sudo

# UEC images ``/etc/sudoers`` does not have a ``#includedir``, add one
sudo grep -q "^#includedir.*/etc/sudoers.d" /etc/sudoers ||
echo "#includedir /etc/sudoers.d" | sudo tee -a /etc/sudoers

# Set up devstack sudoers
TEMPFILE=`mktemp`
echo "$STACK_USER ALL=(root) NOPASSWD:ALL" >$TEMPFILE
# Some binaries might be under /sbin or /usr/sbin, so make sure sudo will
# see them by forcing PATH
echo "Defaults:$STACK_USER secure_path=/sbin:/usr/sbin:/usr/bin:/bin:/usr/local/sbin:/usr/local/bin" >> $TEMPFILE
chmod 0440 $TEMPFILE
sudo chown root:root $TEMPFILE
sudo mv $TEMPFILE /etc/sudoers.d/50_stack_sh

# Filesystem setup
# ----------------

# Create the destination directory and ensure it is writable by the user
# and read/executable by everybody for daemons (e.g. apache run for horizon)
Expand All @@ -256,6 +257,15 @@ if [ -z "`grep ^127.0.0.1 /etc/hosts | grep $LOCAL_HOSTNAME`" ]; then
sudo sed -i "s/\(^127.0.0.1.*\)/\1 $LOCAL_HOSTNAME/" /etc/hosts
fi

# Destination path for service data
DATA_DIR=${DATA_DIR:-${DEST}/data}
sudo mkdir -p $DATA_DIR
safe_chown -R $STACK_USER $DATA_DIR


# Common Configuration
# --------------------

# Set ``OFFLINE`` to ``True`` to configure ``stack.sh`` to run cleanly without
# Internet access. ``stack.sh`` must have been previously run with Internet
# access to install prerequisites and fetch repositories.
Expand All @@ -269,15 +279,6 @@ ERROR_ON_CLONE=`trueorfalse False $ERROR_ON_CLONE`
# Whether to enable the debug log level in OpenStack services
ENABLE_DEBUG_LOG_LEVEL=`trueorfalse True $ENABLE_DEBUG_LOG_LEVEL`

# Destination path for service data
DATA_DIR=${DATA_DIR:-${DEST}/data}
sudo mkdir -p $DATA_DIR
safe_chown -R $STACK_USER $DATA_DIR


# Common Configuration
# ====================

# Set fixed and floating range here so we can make sure not to use addresses
# from either range when attempting to guess the IP to use for the host.
# Note that setting FIXED_RANGE may be necessary when running DevStack
Expand Down

0 comments on commit 9bd5b93

Please sign in to comment.