blob: d12f23b981dd1078bdf77341f91838a076816d65 [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 Troyer4cbb2672011-10-03 09:14:36 -050010CHROOTCACHE=${CHROOTCACHE:-/root/cache}
Dean Troyer407ee7e2011-09-29 16:38:59 -050011
Jesse Andrewsd31c4ea2011-09-28 02:30:57 -070012# Source params
13source ./stackrc
14
Dean Troyer11e5e6f2011-10-03 09:40:32 -050015DEST=${DEST:-/opt/stack}
16
Jesse Andrewsd31c4ea2011-09-28 02:30:57 -070017# clean install of natty
Dean Troyer4cbb2672011-10-03 09:14:36 -050018if [ ! -d $CHROOTCACHE/natty-base ]; then
19 $PROGDIR/make_image.sh -C natty $CHROOTCACHE/natty-base
Jesse Andrewsd31c4ea2011-09-28 02:30:57 -070020 # copy kernel modules...
21 # NOTE(ja): is there a better way to do this?
Dean Troyer4cbb2672011-10-03 09:14:36 -050022 cp -pr /lib/modules/`uname -r` $CHROOTCACHE/natty-base/lib/modules
Dean Troyer407ee7e2011-09-29 16:38:59 -050023 # a simple password - pass
Dean Troyer4cbb2672011-10-03 09:14:36 -050024 echo root:pass | chroot $CHROOTCACHE/natty-base chpasswd
Jesse Andrewsd31c4ea2011-09-28 02:30:57 -070025fi
26
27# prime natty with as many apt/pips as we can
Dean Troyer4cbb2672011-10-03 09:14:36 -050028if [ ! -d $CHROOTCACHE/natty-dev ]; then
29 rsync -azH $CHROOTCACHE/natty-base/ $CHROOTCACHE/natty-dev/
30 chroot $CHROOTCACHE/natty-dev apt-get install -y `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"`
31 chroot $CHROOTCACHE/natty-dev pip install `cat files/pips/*`
Jesse Andrewsd31c4ea2011-09-28 02:30:57 -070032
33 # Create a stack user that is a member of the libvirtd group so that stack
34 # is able to interact with libvirt.
Dean Troyer4cbb2672011-10-03 09:14:36 -050035 chroot $CHROOTCACHE/natty-dev groupadd libvirtd
Dean Troyer11e5e6f2011-10-03 09:40:32 -050036 chroot $CHROOTCACHE/natty-dev useradd stack -s /bin/bash -d $DEST -G libvirtd
37 mkdir -p $CHROOTCACHE/natty-dev/$DEST
38 chown stack $CHROOTCACHE/natty-dev/$DEST
Jesse Andrewsd31c4ea2011-09-28 02:30:57 -070039
40 # a simple password - pass
Dean Troyer4cbb2672011-10-03 09:14:36 -050041 echo stack:pass | chroot $CHROOTCACHE/natty-dev chpasswd
Jesse Andrewsd31c4ea2011-09-28 02:30:57 -070042
43 # and has sudo ability (in the future this should be limited to only what
44 # stack requires)
Dean Troyer4cbb2672011-10-03 09:14:36 -050045 echo "stack ALL=(ALL) NOPASSWD: ALL" >> $CHROOTCACHE/natty-dev/etc/sudoers
Jesse Andrewsd31c4ea2011-09-28 02:30:57 -070046fi
47
48# clone git repositories onto the system
49# ======================================
50
Dean Troyer4cbb2672011-10-03 09:14:36 -050051if [ ! -d $CHROOTCACHE/natty-stack ]; then
52 rsync -azH $CHROOTCACHE/natty-dev/ $CHROOTCACHE/natty-stack/
Jesse Andrewsd31c4ea2011-09-28 02:30:57 -070053fi
54
55# git clone only if directory doesn't exist already. Since ``DEST`` might not
56# be owned by the installation user, we create the directory and change the
57# ownership to the proper user.
58function git_clone {
59
60 # clone new copy or fetch latest changes
Dean Troyer4cbb2672011-10-03 09:14:36 -050061 CHECKOUT=$CHROOTCACHE/natty-stack$2
Jesse Andrewsd31c4ea2011-09-28 02:30:57 -070062 if [ ! -d $CHECKOUT ]; then
63 mkdir -p $CHECKOUT
64 git clone $1 $CHECKOUT
65 else
66 pushd $CHECKOUT
67 git fetch
68 popd
69 fi
70
71 # FIXME(ja): checkout specified version (should works for branches and tags)
72
73 pushd $CHECKOUT
74 # checkout the proper branch/tag
75 git checkout $3
76 # force our local version to be the same as the remote version
77 git reset --hard origin/$3
78 popd
79
80 # give ownership to the stack user
Dean Troyer4cbb2672011-10-03 09:14:36 -050081 chroot $CHROOTCACHE/natty-stack/ chown -R stack $2
Jesse Andrewsd31c4ea2011-09-28 02:30:57 -070082}
83
Dean Troyer11e5e6f2011-10-03 09:40:32 -050084git_clone $NOVA_REPO $DEST/nova $NOVA_BRANCH
85git_clone $GLANCE_REPO $DEST/glance $GLANCE_BRANCH
86git_clone $KEYSTONE_REPO $DEST/keystone $KEYSTONE_BRANCH
87git_clone $NOVNC_REPO $DEST/novnc $NOVNC_BRANCH
88git_clone $DASH_REPO $DEST/dash $DASH_BRANCH
89git_clone $NOVACLIENT_REPO $DEST/python-novaclient $NOVACLIENT_BRANCH
90git_clone $OPENSTACKX_REPO $DEST/openstackx $OPENSTACKX_BRANCH
Jesse Andrewsd31c4ea2011-09-28 02:30:57 -070091
92# build a new image
93BASE=build.$$
94IMG=$BASE.img
95MNT=$BASE/
96
Jesse Andrews236943f2011-09-28 18:38:10 -070097# (quickly) create a 2GB blank filesystem
98dd bs=1 count=1 seek=$((2*1024*1024*1024)) if=/dev/zero of=$IMG
Jesse Andrewsd31c4ea2011-09-28 02:30:57 -070099# force it to be initialized as ext2
100mkfs.ext2 -F $IMG
101
102# mount blank image loopback and load it
103mkdir -p $MNT
104mount -o loop $IMG $MNT
Dean Troyer4cbb2672011-10-03 09:14:36 -0500105rsync -azH $CHROOTCACHE/natty-stack/ $MNT
Jesse Andrewsd31c4ea2011-09-28 02:30:57 -0700106
107# umount and cleanup
108umount $MNT
109rmdir $MNT
110
111# gzip into final location
112gzip -1 $IMG -c > $1
113