update with sanity checks

This commit is contained in:
Jesse Andrews 2011-09-15 22:19:42 -07:00
parent 7dd13d03f1
commit 6edd17f7c1

View file

@ -7,8 +7,33 @@
# put the list of *apt* and *pip* dependencies and other configuration files in # put the list of *apt* and *pip* dependencies and other configuration files in
# this repo. So start by grabbing this script and the dependencies. # this repo. So start by grabbing this script and the dependencies.
# Settings/Options
# ================ # Sanity Check
# ============
# Warn users who aren't on natty, but allow they to override check and attempt
# installation with ``FORCE=yes ./stack``
#
if ! grep -q natty /etc/lsb-release; then
echo "WARNING: this script has only been tested on natty"
if [[ "$FORCE" != "yes" ]]; then
echo "If you wish to run this script anyway run with FORCE=yes"
exit 1
fi
fi
# stack.sh keeps the list of **apt** and **pip** dependencies in files.
# Additionally we have a few config templates and other useful files useful
# installation. They are needed to be located at ``apts``, ``files`` and
# ``pips`` in the same directory as this script.
DEVSTACK=`pwd`
if [ ! -d $DEVSTACK/apts ] || [ ! -d $DEVSTACK/files ] || [ ! -d $DEVSTACK/pips ]; then
echo "ERROR: missing devstack files - did you grab more than just stack.sh?"
exit 1
fi
# Settings
# ========
# This script is customizable through setting environment variables. If you # This script is customizable through setting environment variables. If you
# want to override a setting you can either:: # want to override a setting you can either::
@ -16,29 +41,21 @@
# export MYSQL_PASS=anothersecret # export MYSQL_PASS=anothersecret
# ./stack.sh # ./stack.sh
# #
# or run on a single line ``MYSQL_PASS=simple ./stack.sh`` # You can also pass options on a single line ``MYSQL_PASS=simple ./stack.sh``
# or simply ``./stack.sh`` #
# We try to have sensible defaults, so you should be able to run ``./stack.sh``
# in most cases.
# This script exits on an error so that errors don't compound and you see # So that errors don't compound we exit on any errors so you see only the
# only the first error that occured. # first error that occured.
set -o errexit set -o errexit
# Print the commands being run so that we can see the command that triggers # 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. # an error. It is also useful for following allowing as the install occurs.
set -o xtrace set -o xtrace
# Warn users who aren't on natty # Destination path for installation ``DEST``
## TODO: alter flow to exit unless the user sets environment FORCE=true DEST=${DEST:-/opt}
## TODO: warn user if apts, pips and other files don't exist that they
## need more than just this script
if ! grep -q natty /etc/lsb-release; then
echo "WARNING: this script has only been tested on natty"
fi
# Important paths: ``DIR`` is where we are executing from and ``DEST`` is
# where we are installing openstack.
DIR=`pwd`
DEST=/opt
# Set the destination directories for openstack projects # Set the destination directories for openstack projects
NOVA_DIR=$DEST/nova NOVA_DIR=$DEST/nova
@ -100,10 +117,10 @@ mysql-server-5.1 mysql-server/start_on_boot boolean true
MYSQL_PRESEED MYSQL_PRESEED
# install apt requirements # install apt requirements
sudo apt-get install -y -q `cat $DIR/apts/* | cut -d\# -f1` sudo apt-get install -y -q `cat $DEVSTACK/apts/* | cut -d\# -f1`
# install python requirements # install python requirements
sudo PIP_DOWNLOAD_CACHE=/var/cache/pip pip install `cat $DIR/pips/*` sudo PIP_DOWNLOAD_CACHE=/var/cache/pip pip install `cat $DEVSTACK/pips/*`
# git clone only if directory doesn't exist already # git clone only if directory doesn't exist already
function git_clone { function git_clone {
@ -143,10 +160,11 @@ cd $API_DIR; sudo python setup.py develop
cd $DASH_DIR/django-openstack; sudo python setup.py develop cd $DASH_DIR/django-openstack; sudo python setup.py develop
cd $DASH_DIR/openstack-dashboard; sudo python setup.py develop cd $DASH_DIR/openstack-dashboard; sudo python setup.py develop
# add useful screenrc # Add a useful screenrc. This isn't required to run openstack but is we do
cp $DIR/files/screenrc ~/.screenrc # it since we are going to run the services in screen for simple
cp $DEVSTACK/files/screenrc ~/.screenrc
# TODO: update current user to allow sudo for all commands in files/sudo/* ## TODO: update current user to allow sudo for all commands in files/sudo/*
# Mysql # Mysql
@ -184,7 +202,7 @@ if [[ "$ENABLED_SERVICES" =~ "dash" ]]; then
sudo mkdir -p $DASH_DIR/.blackhole sudo mkdir -p $DASH_DIR/.blackhole
## Configure apache's 000-default to run dashboard ## Configure apache's 000-default to run dashboard
sudo cp $DIR/files/000-default.template /etc/apache2/sites-enabled/000-default sudo cp $DEVSTACK/files/000-default.template /etc/apache2/sites-enabled/000-default
sudo sed -e "s,%DASH_DIR%,$DASH_DIR,g" -i /etc/apache2/sites-enabled/000-default sudo sed -e "s,%DASH_DIR%,$DASH_DIR,g" -i /etc/apache2/sites-enabled/000-default
# ``python setup.py develop`` left some files owned by root in ``DASH_DIR`` and # ``python setup.py develop`` left some files owned by root in ``DASH_DIR`` and
@ -239,7 +257,7 @@ if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then
mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'CREATE DATABASE glance;' mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'CREATE DATABASE glance;'
# Copy over our glance-registry.conf # Copy over our glance-registry.conf
GLANCE_CONF=$GLANCE_DIR/etc/glance-registry.conf GLANCE_CONF=$GLANCE_DIR/etc/glance-registry.conf
cp $DIR/files/glance-registry.conf $GLANCE_CONF cp $DEVSTACK/files/glance-registry.conf $GLANCE_CONF
sudo sed -e "s,%SQL_CONN%,$BASE_SQL_CONN/glance,g" -i $GLANCE_CONF sudo sed -e "s,%SQL_CONN%,$BASE_SQL_CONN/glance,g" -i $GLANCE_CONF
fi fi
@ -335,11 +353,11 @@ if [[ "$ENABLED_SERVICES" =~ "key" ]]; then
# FIXME (anthony) keystone should use keystone.conf.example # FIXME (anthony) keystone should use keystone.conf.example
KEYSTONE_CONF=$KEYSTONE_DIR/etc/keystone.conf KEYSTONE_CONF=$KEYSTONE_DIR/etc/keystone.conf
cp $DIR/files/keystone.conf $KEYSTONE_CONF cp $DEVSTACK/files/keystone.conf $KEYSTONE_CONF
sudo sed -e "s,%SQL_CONN%,$BASE_SQL_CONN/keystone,g" -i $KEYSTONE_CONF sudo sed -e "s,%SQL_CONN%,$BASE_SQL_CONN/keystone,g" -i $KEYSTONE_CONF
# initialize keystone with default users/endpoints # initialize keystone with default users/endpoints
BIN_DIR=$KEYSTONE_DIR/bin bash $DIR/files/keystone_data.sh BIN_DIR=$KEYSTONE_DIR/bin bash $DEVSTACK/files/keystone_data.sh
fi fi