blob: 8d048441d8c957eec9ce35483c15e346c11a5717 [file] [log] [blame]
Jesse Andrewsba23cc72011-09-11 03:22:13 -07001#!/bin/bash
2
Dean Troyercc806542011-10-03 09:30:57 -05003PROGDIR=`dirname $0`
Dean Troyer4cbb2672011-10-03 09:14:36 -05004CHROOTCACHE=${CHROOTCACHE:-/root/cache}
5
Anthony Young2f140202011-09-26 13:02:40 -07006# Source params
7source ./stackrc
8
Jesse Andrewsba23cc72011-09-11 03:22:13 -07009# TODO: make dest not hardcoded
10
11NAME=$1
Jesse Andrews1639ed62011-09-11 15:42:17 -070012DEST="/nfs/$NAME"
Jesse Andrewsba23cc72011-09-11 03:22:13 -070013
14# remove old nfs filesystem if one exists
15rm -rf $DEST
16
Dean Troyercc806542011-10-03 09:30:57 -050017# clean install of natty
18if [ ! -d $CHROOTCACHE/natty-base ]; then
19 $PROGDIR/make_image.sh -C natty $CHROOTCACHE/natty-base
20 # copy kernel modules...
21 # NOTE(ja): is there a better way to do this?
22 cp -pr /lib/modules/`uname -r` $CHROOTCACHE/natty-base/lib/modules
23 # a simple password - pass
24 echo root:pass | chroot $CHROOTCACHE/natty-base chpasswd
Jesse Andrewsba23cc72011-09-11 03:22:13 -070025fi
26
Dean Troyercc806542011-10-03 09:30:57 -050027# prime natty with as many apt/pips as we can
28if [ ! -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/*`
32
33 # Create a stack user that is a member of the libvirtd group so that stack
34 # is able to interact with libvirt.
35 chroot $CHROOTCACHE/natty-dev groupadd libvirtd
36 chroot $CHROOTCACHE/natty-dev useradd stack -s /bin/bash -d /opt -G libvirtd
37
38 # a simple password - pass
39 echo stack:pass | chroot $CHROOTCACHE/natty-dev chpasswd
40
41 # and has sudo ability (in the future this should be limited to only what
42 # stack requires)
43 echo "stack ALL=(ALL) NOPASSWD: ALL" >> $CHROOTCACHE/natty-dev/etc/sudoers
44fi
45
46# clone git repositories onto the system
47# ======================================
48
49if [ ! -d $CHROOTCACHE/natty-stack ]; then
50 rsync -azH $CHROOTCACHE/natty-dev/ $CHROOTCACHE/natty-stack/
51fi
52
53# git clone only if directory doesn't exist already. Since ``DEST`` might not
54# be owned by the installation user, we create the directory and change the
55# ownership to the proper user.
56function git_clone {
57
58 # clone new copy or fetch latest changes
59 CHECKOUT=$CHROOTCACHE/natty-stack$2
60 if [ ! -d $CHECKOUT ]; then
61 mkdir -p $CHECKOUT
62 git clone $1 $CHECKOUT
63 else
64 pushd $CHECKOUT
65 git fetch
66 popd
67 fi
68
69 # FIXME(ja): checkout specified version (should works for branches and tags)
70
71 pushd $CHECKOUT
72 # checkout the proper branch/tag
73 git checkout $3
74 # force our local version to be the same as the remote version
75 git reset --hard origin/$3
76 popd
77
78 # give ownership to the stack user
79 chroot $CHROOTCACHE/natty-stack/ chown -R stack $2
80}
81
82git_clone $NOVA_REPO /opt/stack/nova $NOVA_BRANCH
83git_clone $GLANCE_REPO /opt/stack/glance $GLANCE_BRANCH
84git_clone $KEYSTONE_REPO /opt/stack/keystone $KEYSTONE_BRANCH
85git_clone $NOVNC_REPO /opt/stack/novnc $NOVNC_BRANCH
86git_clone $DASH_REPO /opt/stack/dash $DASH_BRANCH $DASH_TAG
87git_clone $NOVACLIENT_REPO /opt/stack/python-novaclient $NOVACLIENT_BRANCH
88git_clone $OPENSTACKX_REPO /opt/stack/openstackx $OPENSTACKX_BRANCH
89
90chroot $CHROOTCACHE/natty-stack mkdir -p /opt/stack/files
91wget -c http://images.ansolabs.com/tty.tgz -O $CHROOTCACHE/natty-stack/opt/stack/files/tty.tgz
92
93cp -pr $CHROOTCACHE/natty-stack $DEST
Jesse Andrewsba23cc72011-09-11 03:22:13 -070094
95# set hostname
96echo $NAME > $DEST/etc/hostname
97echo "127.0.0.1 localhost $NAME" > $DEST/etc/hosts
98
99# copy kernel modules
100cp -pr /lib/modules/`uname -r` $DEST/lib/modules
101
Jesse Andrews5f098202011-09-11 16:34:34 -0700102
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700103# copy openstack installer and requirement lists to a new directory.
104mkdir -p $DEST/opt
Jesse Andrews4d282182011-09-16 11:27:43 -0700105
106# inject stack.sh and dependant files
107cp -r files $DEST/opt/files
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700108cp stack.sh $DEST/opt/stack.sh
Jesse Andrewsba23cc72011-09-11 03:22:13 -0700109
Jesse Andrews5f098202011-09-11 16:34:34 -0700110# injecting root's public ssh key if it exists
111if [ -f /root/.ssh/id_rsa.pub ]; then
112 mkdir $DEST/root/.ssh
113 chmod 700 $DEST/root/.ssh
114 cp /root/.ssh/id_rsa.pub $DEST/root/.ssh/authorized_keys
115fi