Browse code

Update for variable dist name

Dean Troyer authored on 2011/11/02 02:36:59
Showing 1 changed files
... ...
@@ -1,25 +1,42 @@
1 1
 #!/bin/bash
2 2
 # build_ramdisk.sh - Build RAM disk images
3 3
 
4
+# exit on error to stop unexpected errors
5
+set -o errexit
6
+
4 7
 if [ ! "$#" -eq "1" ]; then
5
-    echo "$0 builds a gziped natty openstack install"
8
+    echo "$0 builds a gziped Ubuntu OpenStack install"
6 9
     echo "usage: $0 dest"
7 10
     exit 1
8 11
 fi
9 12
 
13
+# Echo commands
14
+set -o xtrace
15
+
10 16
 IMG_FILE=$1
11 17
 
12
-PROGDIR=`dirname $0`
13
-CHROOTCACHE=${CHROOTCACHE:-/var/cache/devstack}
18
+# Keep track of the current directory
19
+TOOLS_DIR=$(cd $(dirname "$0") && pwd)
20
+TOP_DIR=`cd $TOOLS_DIR/..; pwd`
21
+
22
+# Store cwd
23
+CWD=`pwd`
24
+
25
+cd $TOP_DIR
14 26
 
15 27
 # Source params
16 28
 source ./stackrc
17 29
 
18
-# Store cwd
19
-CWD=`pwd`
30
+CACHEDIR=${CACHEDIR:-/var/cache/devstack}
20 31
 
21 32
 DEST=${DEST:-/opt/stack}
22 33
 
34
+# Configure the root password of the vm to be the same as ``ADMIN_PASSWORD``
35
+ROOT_PASSWORD=${ADMIN_PASSWORD:-password}
36
+
37
+# Base image (natty by default)
38
+DIST_NAME=${DIST_NAME:-natty}
39
+
23 40
 # Param string to pass to stack.sh.  Like "EC2_DMZ_HOST=192.168.1.1 MYSQL_USER=nova"
24 41
 STACKSH_PARAMS=${STACKSH_PARAMS:-}
25 42
 
... ...
@@ -31,21 +48,21 @@ modprobe nbd max_part=63
31 31
 NBD=${NBD:-/dev/nbd9}
32 32
 NBD_DEV=`basename $NBD`
33 33
 
34
-# clean install of natty
35
-if [ ! -r $CHROOTCACHE/natty-base.img ]; then
36
-    $PROGDIR/get_uec_image.sh natty $CHROOTCACHE/natty-base.img
34
+# clean install
35
+if [ ! -r $CACHEDIR/$DIST_NAME-base.img ]; then
36
+    $TOOLS_DIR/get_uec_image.sh $DIST_NAME $CACHEDIR/$DIST_NAME-base.img
37 37
 #    # copy kernel modules...
38 38
 #    # NOTE(ja): is there a better way to do this?
39
-#    cp -pr /lib/modules/`uname -r` $CHROOTCACHE/natty-base/lib/modules
39
+#    cp -pr /lib/modules/`uname -r` $CACHEDIR/$DIST_NAME-base/lib/modules
40 40
 #    # a simple password - pass
41
-#    echo root:pass | chroot $CHROOTCACHE/natty-base chpasswd
41
+#    echo root:pass | chroot $CACHEDIR/$DIST_NAME-base chpasswd
42 42
 fi
43 43
 
44
-# prime natty with as many apt/pips as we can
45
-if [ ! -r $CHROOTCACHE/natty-dev.img ]; then
46
-    cp -p $CHROOTCACHE/natty-base.img $CHROOTCACHE/natty-dev.img
44
+# prime image with as many apt/pips as we can
45
+if [ ! -r $CACHEDIR/$DIST_NAME-dev.img ]; then
46
+    cp -p $CACHEDIR/$DIST_NAME-base.img $CACHEDIR/$DIST_NAME-dev.img
47 47
 
48
-    qemu-nbd -c $NBD $CHROOTCACHE/natty-dev.img
48
+    qemu-nbd -c $NBD $CACHEDIR/$DIST_NAME-dev.img
49 49
     if ! timeout 60 sh -c "while ! [ -e /sys/block/$NBD_DEV/pid ]; do sleep 1; done"; then
50 50
         echo "Couldn't connect $NBD"
51 51
         exit 1
... ...
@@ -65,7 +82,7 @@ if [ ! -r $CHROOTCACHE/natty-dev.img ]; then
65 65
     chroot $MNTDIR chown stack $DEST
66 66
 
67 67
     # a simple password - pass
68
-    echo stack:pass | chroot $MNTDIR chpasswd
68
+    echo stack:$ROOT_PASSWORD | chroot $MNTDIR chpasswd
69 69
 
70 70
     # and has sudo ability (in the future this should be limited to only what
71 71
     # stack requires)
... ...
@@ -80,7 +97,7 @@ fi
80 80
 # ======================================
81 81
 
82 82
 if [ ! -r $IMG_FILE ]; then
83
-    qemu-nbd -c $NBD $CHROOTCACHE/natty-dev.img
83
+    qemu-nbd -c $NBD $CACHEDIR/$DIST_NAME-dev.img
84 84
     if ! timeout 60 sh -c "while ! [ -e ${NBD}p1 ]; do sleep 1; done"; then
85 85
         echo "Couldn't connect $NBD"
86 86
         exit 1