Browse code

add IF EXISTS to DROP DATABASE statememnts, make sure sudo is installed (prevents errors on miminal LXC installs),

root authored on 2011/09/21 03:06:14
Showing 1 changed files
... ...
@@ -7,7 +7,7 @@
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
-# You can grab the most recent version of this script and files from Rackspace 
10
+# You can grab the most recent version of this script and files from Rackspace
11 11
 # Cloud Builders at https://github.com/cloudbuilders/devstack
12 12
 
13 13
 # Sanity Check
... ...
@@ -23,9 +23,13 @@ if ! grep -q natty /etc/lsb-release; then
23 23
     fi
24 24
 fi
25 25
 
26
-# stack.sh keeps the list of **apt** and **pip** dependencies in external 
26
+#The following makes fresh mininmal installs (i.e. LXCs) happy
27
+apt-get update
28
+apt-get install -y sudo
29
+
30
+# stack.sh keeps the list of **apt** and **pip** dependencies in external
27 31
 # files, along with config templates and other useful files.  You can find these
28
-# in the ``files`` directory (next to this script).  We will reference this 
32
+# in the ``files`` directory (next to this script).  We will reference this
29 33
 # directory using the ``FILES`` variable in this script.
30 34
 FILES=`pwd`/files
31 35
 if [ ! -d $FILES ]; then
... ...
@@ -51,7 +55,7 @@ fi
51 51
 # first error that occured.
52 52
 set -o errexit
53 53
 
54
-# Print the commands being run so that we can see the command that triggers 
54
+# Print the commands being run so that we can see the command that triggers
55 55
 # an error.  It is also useful for following allowing as the install occurs.
56 56
 set -o xtrace
57 57
 
... ...
@@ -91,7 +95,7 @@ FLAT_NETWORK_BRIDGE=${FLAT_NETWORK_BRIDGE:-br100}
91 91
 # ip or you risk breaking things.
92 92
 # FLAT_INTERFACE=eth0
93 93
 
94
-# Nova hypervisor configuration.  We default to **kvm** but will drop back to 
94
+# Nova hypervisor configuration.  We default to **kvm** but will drop back to
95 95
 # **qemu** if we are unable to load the kvm module.
96 96
 LIBVIRT_TYPE=${LIBVIRT_TYPE:-kvm}
97 97
 
... ...
@@ -113,7 +117,7 @@ GLANCE_HOSTPORT=${GLANCE_HOSTPORT:-$HOST_IP:9292}
113 113
 #
114 114
 # Openstack uses a fair number of other projects.
115 115
 
116
-# Seed configuration with mysql password so that apt-get install doesn't 
116
+# Seed configuration with mysql password so that apt-get install doesn't
117 117
 # prompt us for a password upon install.
118 118
 cat <<MYSQL_PRESEED | sudo debconf-set-selections
119 119
 mysql-server-5.1 mysql-server/root_password password $MYSQL_PASS
... ...
@@ -148,11 +152,11 @@ git_clone https://github.com/cloudbuilders/keystone.git $KEYSTONE_DIR
148 148
 git_clone https://github.com/cloudbuilders/noVNC.git $NOVNC_DIR
149 149
 # django powered web control panel for openstack
150 150
 git_clone https://github.com/cloudbuilders/openstack-dashboard.git $DASH_DIR
151
-# add nixon, will use this to show munin graphs in dashboard 
151
+# add nixon, will use this to show munin graphs in dashboard
152 152
 git_clone https://github.com/cloudbuilders/nixon.git $NIXON_DIR
153 153
 # python client library to nova that dashboard (and others) use
154 154
 git_clone https://github.com/cloudbuilders/python-novaclient.git $NOVACLIENT_DIR
155
-# openstackx is a collection of extensions to openstack.compute & nova 
155
+# openstackx is a collection of extensions to openstack.compute & nova
156 156
 # that is *deprecated*.  The code is being moved into python-novaclient & nova.
157 157
 git_clone https://github.com/cloudbuilders/openstackx.git $API_DIR
158 158
 # openstack-munin is a collection of munin plugins for monitoring the stack
... ...
@@ -173,7 +177,7 @@ cd $DASH_DIR/django-openstack; sudo python setup.py develop
173 173
 cd $DASH_DIR/openstack-dashboard; sudo python setup.py develop
174 174
 
175 175
 # Add a useful screenrc.  This isn't required to run openstack but is we do
176
-# it since we are going to run the services in screen for simple 
176
+# it since we are going to run the services in screen for simple
177 177
 cp $FILES/screenrc ~/.screenrc
178 178
 
179 179
 ## TODO: update current user to allow sudo for all commands in files/sudo/*
... ...
@@ -208,15 +212,15 @@ fi
208 208
 
209 209
 if [[ "$ENABLED_SERVICES" =~ "dash" ]]; then
210 210
 
211
-    # Dash currently imports quantum even if you aren't using it.  Instead 
212
-    # of installing quantum we can create a simple module that will pass the 
211
+    # Dash currently imports quantum even if you aren't using it.  Instead
212
+    # of installing quantum we can create a simple module that will pass the
213 213
     # initial imports
214 214
     sudo mkdir -p  $DASH_DIR/openstack-dashboard/quantum || true
215 215
     sudo touch $DASH_DIR/openstack-dashboard/quantum/__init__.py
216 216
     sudo touch $DASH_DIR/openstack-dashboard/quantum/client.py
217 217
 
218 218
     cd $DASH_DIR/openstack-dashboard
219
-    
219
+
220 220
     # Includes settings for Nixon, to expose munin charts.
221 221
     sudo cp $FILES/dash_settings.py local/local_settings.py
222 222
 
... ...
@@ -229,8 +233,8 @@ if [[ "$ENABLED_SERVICES" =~ "dash" ]]; then
229 229
     sudo cp $FILES/000-default.template /etc/apache2/sites-enabled/000-default
230 230
     sudo sed -e "s,%DASH_DIR%,$DASH_DIR,g" -i /etc/apache2/sites-enabled/000-default
231 231
 
232
-    # ``python setup.py develop`` left some files owned by root in ``DASH_DIR`` 
233
-    # and others are owned by the user you are using to run this script.  
232
+    # ``python setup.py develop`` left some files owned by root in ``DASH_DIR``
233
+    # and others are owned by the user you are using to run this script.
234 234
     # We need to change the owner to apache for dashboard to run.
235 235
     sudo chown -R www-data:www-data $DASH_DIR
236 236
 fi
... ...
@@ -275,7 +279,7 @@ if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then
275 275
     mkdir -p $GLANCE_IMAGE_DIR
276 276
 
277 277
     # (re)create glance database
278
-    mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'DROP DATABASE glance;' || true
278
+    mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'DROP DATABASE IF EXISTS glance;'
279 279
     mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'CREATE DATABASE glance;'
280 280
     # Copy over our glance-registry.conf
281 281
     GLANCE_CONF=$GLANCE_DIR/etc/glance-registry.conf
... ...
@@ -294,8 +298,8 @@ fi
294 294
 
295 295
 if [[ "$ENABLED_SERVICES" =~ "n-cpu" ]]; then
296 296
 
297
-    # attempt to load modules: nbd (network block device - used to manage 
298
-    # qcow images) and kvm (hardware based virtualization).  If unable to 
297
+    # attempt to load modules: nbd (network block device - used to manage
298
+    # qcow images) and kvm (hardware based virtualization).  If unable to
299 299
     # load kvm, set the libvirt type to qemu.
300 300
     sudo modprobe nbd || true
301 301
     if ! -e /dev/kvm; then
... ...
@@ -361,7 +365,7 @@ fi
361 361
 
362 362
 if [[ "$ENABLED_SERVICES" =~ "mysql" ]]; then
363 363
     # (re)create nova database
364
-    mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'DROP DATABASE nova;' || true
364
+    mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'DROP DATABASE IF EXISTS nova;'
365 365
     mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'CREATE DATABASE nova;'
366 366
     $NOVA_DIR/bin/nova-manage db sync
367 367
 
... ...
@@ -378,7 +382,7 @@ fi
378 378
 
379 379
 if [[ "$ENABLED_SERVICES" =~ "key" ]]; then
380 380
     # (re)create keystone database
381
-    mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'DROP DATABASE keystone;' || true
381
+    mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'DROP DATABASE IF EXISTS keystone;'
382 382
     mysql -u$MYSQL_USER -p$MYSQL_PASS -e 'CREATE DATABASE keystone;'
383 383
 
384 384
     # FIXME (anthony) keystone should use keystone.conf.example
... ...
@@ -441,10 +445,10 @@ if [[ "$ENABLED_SERVICES" =~ "n-api" ]]; then
441 441
         sleep 1
442 442
     done
443 443
 fi
444
-# Launching nova-compute should be as simple as running ``nova-compute`` but 
445
-# have to do a little more than that in our script.  Since we add the group 
444
+# Launching nova-compute should be as simple as running ``nova-compute`` but
445
+# have to do a little more than that in our script.  Since we add the group
446 446
 # ``libvirtd`` to our user in this script, when nova-compute is run it is
447
-# within the context of our original shell (so our groups won't be updated). 
447
+# within the context of our original shell (so our groups won't be updated).
448 448
 # We can send the command nova-compute to the ``newgrp`` command to execute
449 449
 # in a specific context.
450 450
 screen_it n-cpu "cd $NOVA_DIR && echo $NOVA_DIR/bin/nova-compute | newgrp libvirtd"
... ...
@@ -458,7 +462,7 @@ screen_it dash "cd $DASH_DIR && sudo /etc/init.d/apache2 restart; sudo tail -f /
458 458
 # ==============
459 459
 
460 460
 if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then
461
-    # Downloads a tty image (ami/aki/ari style), then extracts it.  Upon extraction 
461
+    # Downloads a tty image (ami/aki/ari style), then extracts it.  Upon extraction
462 462
     # we upload to glance with the glance cli tool.
463 463
     if [ ! -f $FILES/tty.tgz ]; then
464 464
         wget -c http://images.ansolabs.com/tty.tgz -O $FILES/tty.tgz
... ...
@@ -468,10 +472,10 @@ if [[ "$ENABLED_SERVICES" =~ "g-reg" ]]; then
468 468
     mkdir -p $FILES/images
469 469
     tar -zxf $FILES/tty.tgz -C $FILES/images
470 470
 
471
-    # add images to glance 
471
+    # add images to glance
472 472
     # FIXME: kernel/ramdisk is hardcoded - use return result from add
473
-    glance add -A 999888777666 name="tty-kernel" is_public=true container_format=aki disk_format=aki < $FILES/images/aki-tty/image 
474
-    glance add -A 999888777666 name="tty-ramdisk" is_public=true container_format=ari disk_format=ari < $FILES/images/ari-tty/image 
473
+    glance add -A 999888777666 name="tty-kernel" is_public=true container_format=aki disk_format=aki < $FILES/images/aki-tty/image
474
+    glance add -A 999888777666 name="tty-ramdisk" is_public=true container_format=ari disk_format=ari < $FILES/images/ari-tty/image
475 475
     glance add -A 999888777666 name="tty" is_public=true container_format=ami disk_format=ami kernel_id=1 ramdisk_id=2 < $FILES/images/ami-tty/image
476 476
 fi
477 477
 
... ...
@@ -479,7 +483,7 @@ fi
479 479
 # ===============
480 480
 
481 481
 # If you installed the dashboard on this server, then you should be able
482
-# to access the site using your browser.  
482
+# to access the site using your browser.
483 483
 if [[ "$ENABLED_SERVICES" =~ "dash" ]]; then
484 484
     echo "dashboard is now available at http://$HOST_IP/"
485 485
 fi