log output of stack.sh to logfile in current dir

use the variable LOGFILE to log stack.sh output for debugging
main
Scott Moser 13 years ago committed by Scott Moser
parent c4e47ab858
commit 7c481189bd

@ -40,6 +40,52 @@ if [ ! -d $FILES ]; then
exit 1
fi
# Settings
# ========
# This script is customizable through setting environment variables. If you
# want to override a setting you can either::
#
# export MYSQL_PASS=anothersecret
# ./stack.sh
#
# You can also pass options on a single line ``MYSQL_PASS=simple ./stack.sh``
#
# Additionally, you can put any local variables into a ``localrc`` file, like::
#
# MYSQL_PASS=anothersecret
# MYSQL_USER=hellaroot
#
# We try to have sensible defaults, so you should be able to run ``./stack.sh``
# in most cases.
#
# We our settings from ``stackrc``. This file is distributed with devstack and
# contains locations for what repositories to use. If you want to use other
# repositories and branches, you can add your own settings with another file
# called ``localrc``
#
# If ``localrc`` exists, then ``stackrc`` will load those settings. This is
# useful for changing a branch or repostiory to test other versions. Also you
# can store your other settings like **MYSQL_PASS** or **ADMIN_PASSWORD** instead
# of letting devstack generate random ones for you.
source ./stackrc
LOGFILE=${LOGFILE:-"$PWD/stack.sh.$$.log"}
(
# So that errors don't compound we exit on any errors so you see only the
# first error that occured.
trap failed ERR
failed() {
local r=$?
set +o xtrace
[ -n "$LOGFILE" ] && echo "${0##*/} failed: full log in $LOGFILE"
exit $r
}
# Print the commands being run so that we can see the command that triggers
# an error. It is also useful for following along as the install occurs.
set -o xtrace
# OpenStack is designed to be run as a regular user (Dashboard will fail to run
# as root, since apache refused to startup serve content from root user). If
# stack.sh is run as root, it automatically creates a stack user with
@ -51,7 +97,7 @@ if [[ $EUID -eq 0 ]]; then
# since this script runs as a normal user, we need to give that user
# ability to run sudo
apt-get update
apt-get install -qqy sudo
apt-get install -y sudo
if ! getent passwd | grep -q stack; then
echo "Creating a user called stack"
@ -67,51 +113,13 @@ if [[ $EUID -eq 0 ]]; then
echo "Running the script as stack in 3 seconds..."
sleep 3
if [[ "$SHELL_AFTER_RUN" != "no" ]]; then
exec su -c "cd /home/stack/$THIS_DIR/; bash stack.sh; bash" stack
exec su -c "cd /home/stack/$THIS_DIR/; bash stack.sh; bash" stack
else
exec su -c "cd /home/stack/$THIS_DIR/; bash stack.sh" stack
exec su -c "cd /home/stack/$THIS_DIR/; bash stack.sh" stack
fi
exit 0
fi
# So that errors don't compound we exit on any errors so you see only the
# first error that occured.
set -o errexit
# Print the commands being run so that we can see the command that triggers
# an error. It is also useful for following allowing as the install occurs.
set -o xtrace
# Settings
# ========
# This script is customizable through setting environment variables. If you
# want to override a setting you can either::
#
# export MYSQL_PASS=anothersecret
# ./stack.sh
#
# You can also pass options on a single line ``MYSQL_PASS=simple ./stack.sh``
#
# Additionally, you can put any local variables into a ``localrc`` file, like::
#
# MYSQL_PASS=anothersecret
# MYSQL_USER=hellaroot
#
# We try to have sensible defaults, so you should be able to run ``./stack.sh``
# in most cases.
#
# We our settings from ``stackrc``. This file is distributed with devstack and
# contains locations for what repositories to use. If you want to use other
# repositories and branches, you can add your own settings with another file
# called ``localrc``
#
# If ``localrc`` exists, then ``stackrc`` will load those settings. This is
# useful for changing a branch or repostiory to test other versions. Also you
# can store your other settings like **MYSQL_PASS** or **ADMIN_PASSWORD** instead
# of letting devstack generate random ones for you.
source ./stackrc
# Destination path for installation ``DEST``
DEST=${DEST:-/opt/stack}
sudo mkdir -p $DEST
@ -663,5 +671,16 @@ fi
# Fin
# ===
) 2>&1 | tee "${LOGFILE}"
# because of the way pipes work, the left side of the pipe may
# have failed, but 'tee' will succeed. We need to check that.
for ret in "${PIPESTATUS[@]}"; do
[ $ret -eq 0 ] || exit $ret
done
# indicate how long this took to run (bash maintained variable 'SECONDS')
echo "stack.sh completed in $SECONDS seconds."
echo "stack.sh completed in $SECONDS seconds." | tee -a "${LOGFILE}"
exit 0

Loading…
Cancel
Save