Browse code

Merge branch 'master' into nixon

Jake Dahn authored on 2011/09/16 14:32:46
Showing 1 changed files
... ...
@@ -7,8 +7,33 @@
7 7
 # put the list of *apt* and *pip* dependencies and other configuration files in
8 8
 # this repo.  So start by grabbing this script and the dependencies.
9 9
 
10
-# Settings/Options
11
-# ================
10
+
11
+# Sanity Check
12
+# ============
13
+
14
+# Warn users who aren't on natty, but allow they to override check and attempt
15
+# installation with ``FORCE=yes ./stack``
16
+#
17
+if ! grep -q natty /etc/lsb-release; then
18
+    echo "WARNING: this script has only been tested on natty"
19
+    if [[ "$FORCE" != "yes" ]]; then
20
+        echo "If you wish to run this script anyway run with FORCE=yes"
21
+        exit 1
22
+    fi
23
+fi
24
+
25
+# stack.sh keeps the list of **apt** and **pip** dependencies in files.  
26
+# Additionally we have a few config templates and other useful files useful 
27
+# installation.  They are needed to be located at ``apts``, ``files`` and 
28
+# ``pips`` in the same directory as this script.
29
+DEVSTACK=`pwd`
30
+if [ ! -d $DEVSTACK/apts ] || [ ! -d $DEVSTACK/files ] || [ ! -d $DEVSTACK/pips ]; then
31
+    echo "ERROR: missing devstack files - did you grab more than just stack.sh?"
32
+    exit 1
33
+fi
34
+
35
+# Settings
36
+# ========
12 37
 
13 38
 # This script is customizable through setting environment variables.  If you
14 39
 # want to override a setting you can either::
... ...
@@ -16,29 +41,21 @@
16 16
 #     export MYSQL_PASS=anothersecret
17 17
 #     ./stack.sh
18 18
 #
19
-# or run on a single line ``MYSQL_PASS=simple ./stack.sh``
20
-# or simply ``./stack.sh``
19
+# You can also pass options on a single line ``MYSQL_PASS=simple ./stack.sh``
20
+#
21
+# We try to have sensible defaults, so you should be able to run ``./stack.sh``
22
+# in most cases.
21 23
 
22
-# This script exits on an error so that errors don't compound and you see 
23
-# only the first error that occured.
24
+# So that errors don't compound we exit on any errors so you see only the
25
+# first error that occured.
24 26
 set -o errexit
25 27
 
26 28
 # Print the commands being run so that we can see the command that triggers 
27 29
 # an error.  It is also useful for following allowing as the install occurs.
28 30
 set -o xtrace
29 31
 
30
-# Warn users who aren't on natty
31
-## TODO: alter flow to exit unless the user sets environment FORCE=true
32
-## TODO: warn user if apts, pips and other files don't exist that they
33
-## need more than just this script
34
-if ! grep -q natty /etc/lsb-release; then
35
-    echo "WARNING: this script has only been tested on natty"
36
-fi
37
-
38
-# Important paths: ``DIR`` is where we are executing from and ``DEST`` is 
39
-# where we are installing openstack.
40
-DIR=`pwd`
41
-DEST=/opt
32
+# Destination path for installation ``DEST``
33
+DEST=${DEST:-/opt}
42 34
 
43 35
 # Set the destination directories for openstack projects
44 36
 NOVA_DIR=$DEST/nova
... ...
@@ -101,10 +118,10 @@ mysql-server-5.1 mysql-server/start_on_boot boolean true
101 101
 MYSQL_PRESEED
102 102
 
103 103
 # install apt requirements
104
-sudo apt-get install -y -q `cat $DIR/apts/* | cut -d\# -f1`
104
+sudo apt-get install -y -q `cat $DEVSTACK/apts/* | cut -d\# -f1`
105 105
 
106 106
 # install python requirements
107
-sudo PIP_DOWNLOAD_CACHE=/var/cache/pip pip install `cat $DIR/pips/*`
107
+sudo PIP_DOWNLOAD_CACHE=/var/cache/pip pip install `cat $DEVSTACK/pips/*`
108 108
 
109 109
 # git clone only if directory doesn't exist already
110 110
 function git_clone {
... ...
@@ -146,10 +163,11 @@ cd $API_DIR; sudo python setup.py develop
146 146
 cd $DASH_DIR/django-openstack; sudo python setup.py develop
147 147
 cd $DASH_DIR/openstack-dashboard; sudo python setup.py develop
148 148
 
149
-# add useful screenrc
150
-cp $DIR/files/screenrc ~/.screenrc
149
+# Add a useful screenrc.  This isn't required to run openstack but is we do
150
+# it since we are going to run the services in screen for simple 
151
+cp $DEVSTACK/files/screenrc ~/.screenrc
151 152
 
152
-# TODO: update current user to allow sudo for all commands in files/sudo/*
153
+## TODO: update current user to allow sudo for all commands in files/sudo/*
153 154
 
154 155
 
155 156
 # Mysql
... ...
@@ -188,7 +206,7 @@ if [[ "$ENABLED_SERVICES" =~ "dash" ]]; then
188 188
     sudo mkdir -p $DASH_DIR/.blackhole
189 189
 
190 190
     ## Configure apache's 000-default to run dashboard
191
-    sudo cp $DIR/files/000-default.template /etc/apache2/sites-enabled/000-default
191
+    sudo cp $DEVSTACK/files/000-default.template /etc/apache2/sites-enabled/000-default
192 192
     sudo sed -e "s,%DASH_DIR%,$DASH_DIR,g" -i /etc/apache2/sites-enabled/000-default
193 193
 
194 194
     # ``python setup.py develop`` left some files owned by root in ``DASH_DIR`` and
... ...
@@ -243,7 +261,7 @@ if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then
243 243
     mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'CREATE DATABASE glance;'
244 244
     # Copy over our glance-registry.conf
245 245
     GLANCE_CONF=$GLANCE_DIR/etc/glance-registry.conf
246
-    cp $DIR/files/glance-registry.conf $GLANCE_CONF
246
+    cp $DEVSTACK/files/glance-registry.conf $GLANCE_CONF
247 247
     sudo sed -e "s,%SQL_CONN%,$BASE_SQL_CONN/glance,g" -i $GLANCE_CONF
248 248
 fi
249 249
 
... ...
@@ -339,11 +357,11 @@ if [[ "$ENABLED_SERVICES" =~ "key" ]]; then
339 339
 
340 340
     # FIXME (anthony) keystone should use keystone.conf.example
341 341
     KEYSTONE_CONF=$KEYSTONE_DIR/etc/keystone.conf
342
-    cp $DIR/files/keystone.conf $KEYSTONE_CONF
342
+    cp $DEVSTACK/files/keystone.conf $KEYSTONE_CONF
343 343
     sudo sed -e "s,%SQL_CONN%,$BASE_SQL_CONN/keystone,g" -i $KEYSTONE_CONF
344 344
 
345 345
     # initialize keystone with default users/endpoints
346
-    BIN_DIR=$KEYSTONE_DIR/bin bash $DIR/files/keystone_data.sh
346
+    BIN_DIR=$KEYSTONE_DIR/bin bash $DEVSTACK/files/keystone_data.sh
347 347
 fi
348 348
 
349 349