blob: a01656b122dc25ca7011436ec54d05801cb2566f [file] [log] [blame]
Jesse Andrewsd31c4ea2011-09-28 02:30:57 -07001#!/bin/bash
2
3if [ ! "$#" -eq "1" ]; then
4 echo "$0 builds a gziped natty openstack install"
5 echo "usage: $0 dest"
6 exit 1
7fi
8
Dean Troyer407ee7e2011-09-29 16:38:59 -05009PROGDIR=`dirname $0`
Dean Troyerd4a3bac2011-10-03 21:16:27 -050010CHROOTCACHE=${CHROOTCACHE:-/var/cache/devstack}
Dean Troyer407ee7e2011-09-29 16:38:59 -050011
Jesse Andrewsd31c4ea2011-09-28 02:30:57 -070012# Source params
13source ./stackrc
14
Dean Troyer03412c82011-10-03 09:56:41 -050015# Store cwd
16CWD=`pwd`
17
Dean Troyer11e5e6f2011-10-03 09:40:32 -050018DEST=${DEST:-/opt/stack}
19
Dean Troyera3379e02011-10-03 11:14:13 -050020# Option to use the version of devstack on which we are currently working
21USE_CURRENT_DEVSTACK=${USE_CURRENT_DEVSTACK:-1}
22
Jesse Andrewsd31c4ea2011-09-28 02:30:57 -070023# clean install of natty
Dean Troyer4cbb2672011-10-03 09:14:36 -050024if [ ! -d $CHROOTCACHE/natty-base ]; then
25 $PROGDIR/make_image.sh -C natty $CHROOTCACHE/natty-base
Jesse Andrewsd31c4ea2011-09-28 02:30:57 -070026 # copy kernel modules...
27 # NOTE(ja): is there a better way to do this?
Dean Troyer4cbb2672011-10-03 09:14:36 -050028 cp -pr /lib/modules/`uname -r` $CHROOTCACHE/natty-base/lib/modules
Dean Troyer407ee7e2011-09-29 16:38:59 -050029 # a simple password - pass
Dean Troyer4cbb2672011-10-03 09:14:36 -050030 echo root:pass | chroot $CHROOTCACHE/natty-base chpasswd
Jesse Andrewsd31c4ea2011-09-28 02:30:57 -070031fi
32
33# prime natty with as many apt/pips as we can
Dean Troyer4cbb2672011-10-03 09:14:36 -050034if [ ! -d $CHROOTCACHE/natty-dev ]; then
35 rsync -azH $CHROOTCACHE/natty-base/ $CHROOTCACHE/natty-dev/
36 chroot $CHROOTCACHE/natty-dev apt-get install -y `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"`
37 chroot $CHROOTCACHE/natty-dev pip install `cat files/pips/*`
Jesse Andrewsd31c4ea2011-09-28 02:30:57 -070038
39 # Create a stack user that is a member of the libvirtd group so that stack
40 # is able to interact with libvirt.
Dean Troyer4cbb2672011-10-03 09:14:36 -050041 chroot $CHROOTCACHE/natty-dev groupadd libvirtd
Dean Troyer11e5e6f2011-10-03 09:40:32 -050042 chroot $CHROOTCACHE/natty-dev useradd stack -s /bin/bash -d $DEST -G libvirtd
43 mkdir -p $CHROOTCACHE/natty-dev/$DEST
44 chown stack $CHROOTCACHE/natty-dev/$DEST
Jesse Andrewsd31c4ea2011-09-28 02:30:57 -070045
46 # a simple password - pass
Dean Troyer4cbb2672011-10-03 09:14:36 -050047 echo stack:pass | chroot $CHROOTCACHE/natty-dev chpasswd
Jesse Andrewsd31c4ea2011-09-28 02:30:57 -070048
49 # and has sudo ability (in the future this should be limited to only what
50 # stack requires)
Dean Troyer4cbb2672011-10-03 09:14:36 -050051 echo "stack ALL=(ALL) NOPASSWD: ALL" >> $CHROOTCACHE/natty-dev/etc/sudoers
Jesse Andrewsd31c4ea2011-09-28 02:30:57 -070052fi
53
54# clone git repositories onto the system
55# ======================================
56
Dean Troyer4cbb2672011-10-03 09:14:36 -050057if [ ! -d $CHROOTCACHE/natty-stack ]; then
58 rsync -azH $CHROOTCACHE/natty-dev/ $CHROOTCACHE/natty-stack/
Jesse Andrewsd31c4ea2011-09-28 02:30:57 -070059fi
60
61# git clone only if directory doesn't exist already. Since ``DEST`` might not
62# be owned by the installation user, we create the directory and change the
63# ownership to the proper user.
64function git_clone {
65
66 # clone new copy or fetch latest changes
Dean Troyer4cbb2672011-10-03 09:14:36 -050067 CHECKOUT=$CHROOTCACHE/natty-stack$2
Jesse Andrewsd31c4ea2011-09-28 02:30:57 -070068 if [ ! -d $CHECKOUT ]; then
69 mkdir -p $CHECKOUT
70 git clone $1 $CHECKOUT
71 else
72 pushd $CHECKOUT
73 git fetch
74 popd
75 fi
76
77 # FIXME(ja): checkout specified version (should works for branches and tags)
78
79 pushd $CHECKOUT
80 # checkout the proper branch/tag
81 git checkout $3
82 # force our local version to be the same as the remote version
83 git reset --hard origin/$3
84 popd
85
86 # give ownership to the stack user
Dean Troyer4cbb2672011-10-03 09:14:36 -050087 chroot $CHROOTCACHE/natty-stack/ chown -R stack $2
Jesse Andrewsd31c4ea2011-09-28 02:30:57 -070088}
89
Dean Troyer11e5e6f2011-10-03 09:40:32 -050090git_clone $NOVA_REPO $DEST/nova $NOVA_BRANCH
91git_clone $GLANCE_REPO $DEST/glance $GLANCE_BRANCH
92git_clone $KEYSTONE_REPO $DEST/keystone $KEYSTONE_BRANCH
93git_clone $NOVNC_REPO $DEST/novnc $NOVNC_BRANCH
94git_clone $DASH_REPO $DEST/dash $DASH_BRANCH
95git_clone $NOVACLIENT_REPO $DEST/python-novaclient $NOVACLIENT_BRANCH
96git_clone $OPENSTACKX_REPO $DEST/openstackx $OPENSTACKX_BRANCH
Jesse Andrewsd31c4ea2011-09-28 02:30:57 -070097
Dean Troyer03412c82011-10-03 09:56:41 -050098# Use this version of devstack?
99if [ "$USE_CURRENT_DEVSTACK" = "1" ]; then
Dean Troyer10db4452011-10-03 11:16:32 -0500100 rm -rf $CHROOTCACHE/natty-stack/$DEST/devstack
Dean Troyer6994f942011-10-03 11:03:27 -0500101 cp -pr $CWD $CHROOTCACHE/natty-stack/$DEST/devstack
Dean Troyer03412c82011-10-03 09:56:41 -0500102fi
103
Dean Troyercf9db8d2011-10-03 13:42:16 -0500104# Configure host network for DHCP
105mkdir -p $CHROOTCACHE/natty-stack/etc/network
Dean Troyerd4a3bac2011-10-03 21:16:27 -0500106cat > $CHROOTCACHE/natty-stack/etc/network/interfaces <<EOF
Dean Troyercf9db8d2011-10-03 13:42:16 -0500107auto lo
108iface lo inet loopback
109
110auto eth0
111iface eth0 inet dhcp
112EOF
113
Jesse Andrewsd31c4ea2011-09-28 02:30:57 -0700114# build a new image
Dean Troyer10db4452011-10-03 11:16:32 -0500115BASE=$CHROOTCACHE/build.$$
Jesse Andrewsd31c4ea2011-09-28 02:30:57 -0700116IMG=$BASE.img
117MNT=$BASE/
118
Jesse Andrews236943f2011-09-28 18:38:10 -0700119# (quickly) create a 2GB blank filesystem
120dd bs=1 count=1 seek=$((2*1024*1024*1024)) if=/dev/zero of=$IMG
Jesse Andrewsd31c4ea2011-09-28 02:30:57 -0700121# force it to be initialized as ext2
122mkfs.ext2 -F $IMG
123
124# mount blank image loopback and load it
125mkdir -p $MNT
126mount -o loop $IMG $MNT
Dean Troyer4cbb2672011-10-03 09:14:36 -0500127rsync -azH $CHROOTCACHE/natty-stack/ $MNT
Jesse Andrewsd31c4ea2011-09-28 02:30:57 -0700128
129# umount and cleanup
130umount $MNT
131rmdir $MNT
132
133# gzip into final location
134gzip -1 $IMG -c > $1
135