Jesse Andrews | d31c4ea | 2011-09-28 02:30:57 -0700 | [diff] [blame] | 1 | #!/bin/bash |
| 2 | |
| 3 | if [ ! "$#" -eq "1" ]; then |
| 4 | echo "$0 builds a gziped natty openstack install" |
| 5 | echo "usage: $0 dest" |
| 6 | exit 1 |
| 7 | fi |
| 8 | |
Dean Troyer | 407ee7e | 2011-09-29 16:38:59 -0500 | [diff] [blame] | 9 | PROGDIR=`dirname $0` |
| 10 | |
Jesse Andrews | d31c4ea | 2011-09-28 02:30:57 -0700 | [diff] [blame] | 11 | # Source params |
| 12 | source ./stackrc |
| 13 | |
| 14 | # clean install of natty |
| 15 | if [ ! -d natty-base ]; then |
Dean Troyer | 407ee7e | 2011-09-29 16:38:59 -0500 | [diff] [blame] | 16 | $PROGDIR/make_image.sh -C natty natty-base |
Jesse Andrews | d31c4ea | 2011-09-28 02:30:57 -0700 | [diff] [blame] | 17 | # copy kernel modules... |
| 18 | # NOTE(ja): is there a better way to do this? |
Jesse Andrews | f2d6c92 | 2011-09-28 17:50:40 -0700 | [diff] [blame] | 19 | cp -pr /lib/modules/`uname -r` natty-base/lib/modules |
Dean Troyer | 407ee7e | 2011-09-29 16:38:59 -0500 | [diff] [blame] | 20 | # a simple password - pass |
| 21 | echo root:pass | chroot natty-base chpasswd |
Jesse Andrews | d31c4ea | 2011-09-28 02:30:57 -0700 | [diff] [blame] | 22 | fi |
| 23 | |
| 24 | # prime natty with as many apt/pips as we can |
| 25 | if [ ! -d primed ]; then |
| 26 | rsync -azH natty-base/ primed/ |
| 27 | chroot primed apt-get install -y `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"` |
| 28 | chroot primed pip install `cat files/pips/*` |
| 29 | |
| 30 | # Create a stack user that is a member of the libvirtd group so that stack |
| 31 | # is able to interact with libvirt. |
| 32 | chroot primed groupadd libvirtd |
| 33 | chroot primed useradd stack -s /bin/bash -d /opt -G libvirtd |
| 34 | |
| 35 | # a simple password - pass |
| 36 | echo stack:pass | chroot primed chpasswd |
| 37 | |
| 38 | # and has sudo ability (in the future this should be limited to only what |
| 39 | # stack requires) |
| 40 | echo "stack ALL=(ALL) NOPASSWD: ALL" >> primed/etc/sudoers |
| 41 | fi |
| 42 | |
| 43 | # clone git repositories onto the system |
| 44 | # ====================================== |
| 45 | |
| 46 | if [ ! -d cloned ]; then |
| 47 | rsync -azH primed/ cloned/ |
| 48 | fi |
| 49 | |
| 50 | # git clone only if directory doesn't exist already. Since ``DEST`` might not |
| 51 | # be owned by the installation user, we create the directory and change the |
| 52 | # ownership to the proper user. |
| 53 | function git_clone { |
| 54 | |
| 55 | # clone new copy or fetch latest changes |
| 56 | CHECKOUT=cloned$2 |
| 57 | if [ ! -d $CHECKOUT ]; then |
| 58 | mkdir -p $CHECKOUT |
| 59 | git clone $1 $CHECKOUT |
| 60 | else |
| 61 | pushd $CHECKOUT |
| 62 | git fetch |
| 63 | popd |
| 64 | fi |
| 65 | |
| 66 | # FIXME(ja): checkout specified version (should works for branches and tags) |
| 67 | |
| 68 | pushd $CHECKOUT |
| 69 | # checkout the proper branch/tag |
| 70 | git checkout $3 |
| 71 | # force our local version to be the same as the remote version |
| 72 | git reset --hard origin/$3 |
| 73 | popd |
| 74 | |
| 75 | # give ownership to the stack user |
| 76 | chroot cloned/ chown -R stack $2 |
| 77 | } |
| 78 | |
| 79 | git_clone $NOVA_REPO /opt/stack/nova $NOVA_BRANCH |
| 80 | git_clone $GLANCE_REPO /opt/stack/glance $GLANCE_BRANCH |
| 81 | git_clone $KEYSTONE_REPO /opt/stack/keystone $KEYSTONE_BRANCH |
| 82 | git_clone $NOVNC_REPO /opt/stack/novnc $NOVNC_BRANCH |
| 83 | git_clone $DASH_REPO /opt/stack/dash $DASH_BRANCH |
| 84 | git_clone $NIXON_REPO /opt/stack/nixon $NIXON_BRANCH |
| 85 | git_clone $NOVACLIENT_REPO /opt/stack/python-novaclient $NOVACLIENT_BRANCH |
| 86 | git_clone $OPENSTACKX_REPO /opt/stack/openstackx $OPENSTACKX_BRANCH |
| 87 | git_clone $MUNIN_REPO /opt/stack/openstack-munin $MUNIN_BRANCH |
| 88 | |
| 89 | # build a new image |
| 90 | BASE=build.$$ |
| 91 | IMG=$BASE.img |
| 92 | MNT=$BASE/ |
| 93 | |
Jesse Andrews | 236943f | 2011-09-28 18:38:10 -0700 | [diff] [blame] | 94 | # (quickly) create a 2GB blank filesystem |
| 95 | dd bs=1 count=1 seek=$((2*1024*1024*1024)) if=/dev/zero of=$IMG |
Jesse Andrews | d31c4ea | 2011-09-28 02:30:57 -0700 | [diff] [blame] | 96 | # force it to be initialized as ext2 |
| 97 | mkfs.ext2 -F $IMG |
| 98 | |
| 99 | # mount blank image loopback and load it |
| 100 | mkdir -p $MNT |
| 101 | mount -o loop $IMG $MNT |
| 102 | rsync -azH cloned/ $MNT |
| 103 | |
| 104 | # umount and cleanup |
| 105 | umount $MNT |
| 106 | rmdir $MNT |
| 107 | |
| 108 | # gzip into final location |
| 109 | gzip -1 $IMG -c > $1 |
| 110 | |