blob: 197bfc94e4f1cda6af4e1a03cbd68be1d1238cf5 [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`
10
Jesse Andrewsd31c4ea2011-09-28 02:30:57 -070011# Source params
12source ./stackrc
13
14# clean install of natty
15if [ ! -d natty-base ]; then
Dean Troyer407ee7e2011-09-29 16:38:59 -050016 $PROGDIR/make_image.sh -C natty natty-base
Jesse Andrewsd31c4ea2011-09-28 02:30:57 -070017 # copy kernel modules...
18 # NOTE(ja): is there a better way to do this?
Jesse Andrewsf2d6c922011-09-28 17:50:40 -070019 cp -pr /lib/modules/`uname -r` natty-base/lib/modules
Dean Troyer407ee7e2011-09-29 16:38:59 -050020 # a simple password - pass
21 echo root:pass | chroot natty-base chpasswd
Jesse Andrewsd31c4ea2011-09-28 02:30:57 -070022fi
23
24# prime natty with as many apt/pips as we can
25if [ ! -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
41fi
42
43# clone git repositories onto the system
44# ======================================
45
46if [ ! -d cloned ]; then
47 rsync -azH primed/ cloned/
48fi
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.
53function 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
79git_clone $NOVA_REPO /opt/stack/nova $NOVA_BRANCH
80git_clone $GLANCE_REPO /opt/stack/glance $GLANCE_BRANCH
81git_clone $KEYSTONE_REPO /opt/stack/keystone $KEYSTONE_BRANCH
82git_clone $NOVNC_REPO /opt/stack/novnc $NOVNC_BRANCH
83git_clone $DASH_REPO /opt/stack/dash $DASH_BRANCH
84git_clone $NIXON_REPO /opt/stack/nixon $NIXON_BRANCH
85git_clone $NOVACLIENT_REPO /opt/stack/python-novaclient $NOVACLIENT_BRANCH
86git_clone $OPENSTACKX_REPO /opt/stack/openstackx $OPENSTACKX_BRANCH
87git_clone $MUNIN_REPO /opt/stack/openstack-munin $MUNIN_BRANCH
88
89# build a new image
90BASE=build.$$
91IMG=$BASE.img
92MNT=$BASE/
93
Jesse Andrews236943f2011-09-28 18:38:10 -070094# (quickly) create a 2GB blank filesystem
95dd bs=1 count=1 seek=$((2*1024*1024*1024)) if=/dev/zero of=$IMG
Jesse Andrewsd31c4ea2011-09-28 02:30:57 -070096# force it to be initialized as ext2
97mkfs.ext2 -F $IMG
98
99# mount blank image loopback and load it
100mkdir -p $MNT
101mount -o loop $IMG $MNT
102rsync -azH cloned/ $MNT
103
104# umount and cleanup
105umount $MNT
106rmdir $MNT
107
108# gzip into final location
109gzip -1 $IMG -c > $1
110