Re-order stack.sh 2: target dir setup

Part 2 of a series

Re-order the setup and check bits in the top portion of stack.sh to
have a logical flow with similar things done together.

No behaviour changes are intended aside from the order of execution.
Any such changes are bugs.

* Consolidate DEST dir setup
* Move rpc & database init to just before project init

Change-Id: I2af1d4ed32ec34417c04592bf94fe645bb97f831
This commit is contained in:
Dean Troyer 2014-07-25 10:33:21 -05:00
parent d3bf9bdbda
commit 0e8dcedf71

View File

@ -109,7 +109,7 @@ fi
# Global Settings # Global Settings
# =============== # ---------------
# Check for a ``localrc`` section embedded in ``local.conf`` and extract if # Check for a ``localrc`` section embedded in ``local.conf`` and extract if
# ``localrc`` does not already exist # ``localrc`` does not already exist
@ -165,20 +165,11 @@ source $TOP_DIR/stackrc
# Make sure the proxy config is visible to sub-processes # Make sure the proxy config is visible to sub-processes
export_proxy_variables export_proxy_variables
# Destination path for installation ``DEST``
DEST=${DEST:-/opt/stack}
# Import common services (database, message queue) configuration
source $TOP_DIR/lib/database
source $TOP_DIR/lib/rpc_backend
# Remove services which were negated in ENABLED_SERVICES # Remove services which were negated in ENABLED_SERVICES
# using the "-" prefix (e.g., "-rabbit") instead of # using the "-" prefix (e.g., "-rabbit") instead of
# calling disable_service(). # calling disable_service().
disable_negated_services disable_negated_services
# Look for obsolete stuff # Look for obsolete stuff
if [[ ,${ENABLED_SERVICES}, =~ ,"swift", ]]; then if [[ ,${ENABLED_SERVICES}, =~ ,"swift", ]]; then
echo "FATAL: 'swift' is not supported as a service name" echo "FATAL: 'swift' is not supported as a service name"
@ -187,6 +178,8 @@ if [[ ,${ENABLED_SERVICES}, =~ ,"swift", ]]; then
exit 1 exit 1
fi fi
# Set up logging level
VERBOSE=$(trueorfalse True $VERBOSE)
# Configure sudo # Configure sudo
# -------------- # --------------
@ -209,8 +202,9 @@ chmod 0440 $TEMPFILE
sudo chown root:root $TEMPFILE sudo chown root:root $TEMPFILE
sudo mv $TEMPFILE /etc/sudoers.d/50_stack_sh sudo mv $TEMPFILE /etc/sudoers.d/50_stack_sh
# Additional repos
# ---------------- # Configure Distro Repositories
# -----------------------------
# For debian/ubuntu make apt attempt to retry network ops on it's own # For debian/ubuntu make apt attempt to retry network ops on it's own
if is_ubuntu; then if is_ubuntu; then
@ -252,8 +246,12 @@ if [[ is_fedora && $DISTRO =~ (rhel) ]]; then
fi fi
# Filesystem setup
# ---------------- # Configure Target Directories
# ----------------------------
# Destination path for installation ``DEST``
DEST=${DEST:-/opt/stack}
# Create the destination directory and ensure it is writable by the user # 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) # and read/executable by everybody for daemons (e.g. apache run for horizon)
@ -264,6 +262,12 @@ safe_chmod 0755 $DEST
# a basic test for $DEST path permissions (fatal on error unless skipped) # a basic test for $DEST path permissions (fatal on error unless skipped)
check_path_perm_sanity ${DEST} check_path_perm_sanity ${DEST}
# Destination path for service data
DATA_DIR=${DATA_DIR:-${DEST}/data}
sudo mkdir -p $DATA_DIR
safe_chown -R $STACK_USER $DATA_DIR
# Configure proper hostname
# Certain services such as rabbitmq require that the local hostname resolves # Certain services such as rabbitmq require that the local hostname resolves
# correctly. Make sure it exists in /etc/hosts so that is always true. # correctly. Make sure it exists in /etc/hosts so that is always true.
LOCAL_HOSTNAME=`hostname -s` LOCAL_HOSTNAME=`hostname -s`
@ -271,11 +275,6 @@ 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 sudo sed -i "s/\(^127.0.0.1.*\)/\1 $LOCAL_HOSTNAME/" /etc/hosts
fi 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 # Common Configuration
# -------------------- # --------------------
@ -327,6 +326,14 @@ SERVICE_TIMEOUT=${SERVICE_TIMEOUT:-60}
SSL_BUNDLE_FILE="$DATA_DIR/ca-bundle.pem" SSL_BUNDLE_FILE="$DATA_DIR/ca-bundle.pem"
rm -f $SSL_BUNDLE_FILE rm -f $SSL_BUNDLE_FILE
# Import common services (database, message queue) configuration
source $TOP_DIR/lib/database
source $TOP_DIR/lib/rpc_backend
# Make sure we only have one rpc backend enabled,
# and the specified rpc backend is available on your platform.
check_rpc_backend
# Configure Projects # Configure Projects
# ================== # ==================