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