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