blob: 6290c740995de1ae11884006552aa2ab53fd8e8b [file] [log] [blame]
Jesse Andrewsba23cc72011-09-11 03:22:13 -07001#!/bin/bash
2
Dean Troyer4cbb2672011-10-03 09:14:36 -05003CHROOTCACHE=${CHROOTCACHE:-/root/cache}
4
Anthony Young2f140202011-09-26 13:02:40 -07005# Source params
6source ./stackrc
7
Jesse Andrewsba23cc72011-09-11 03:22:13 -07008# TODO: make dest not hardcoded
9
10NAME=$1
Jesse Andrews1639ed62011-09-11 15:42:17 -070011DEST="/nfs/$NAME"
Jesse Andrewsba23cc72011-09-11 03:22:13 -070012
13# remove old nfs filesystem if one exists
14rm -rf $DEST
15
16# build a proto image - natty + packages that will install (optimization)
Dean Troyer4cbb2672011-10-03 09:14:36 -050017if [ ! -d $CHROOTCACHE/proto ]; then
18 debootstrap natty $CHROOTCACHE/proto
19 cp files/sources.list $CHROOTCACHE/proto/etc/apt/sources.list
20 chroot $CHROOTCACHE/proto apt-get update
21 chroot $CHROOTCACHE/proto apt-get install -y `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"`
22 chroot $CHROOTCACHE/proto pip install `cat files/pips/*`
23 git_clone $NOVA_REPO $CHROOTCACHE/proto/opt/nova $NOVA_BRANCH
24 git_clone $GLANCE_REPO $CHROOTCACHE/proto/opt/glance $GLANCE_BRANCH
25 git_clone $KEYSTONE_REPO $CHROOTCACHE/proto/opt/keystone $KEYSTONE_BRANCH
26 git_clone $NOVNC_REPO $CHROOTCACHE/proto/opt/novnc $NOVNC_BRANCH
27 git_clone $DASH_REPO $CHROOTCACHE/proto/opt/dash $DASH_BRANCH $DASH_TAG
28 git_clone $NOVACLIENT_REPO $CHROOTCACHE/proto/opt/python-novaclient $NOVACLIENT_BRANCH
29 git_clone $OPENSTACKX_REPO $CHROOTCACHE/proto/opt/openstackx $OPENSTACKX_BRANCH
30 chroot $CHROOTCACHE/proto mkdir -p /opt/files
31 wget -c http://images.ansolabs.com/tty.tgz -O $CHROOTCACHE/proto/opt/files/tty.tgz
Jesse Andrewsba23cc72011-09-11 03:22:13 -070032fi
33
Dean Troyer4cbb2672011-10-03 09:14:36 -050034cp -pr $CHROOTCACHE/proto $DEST
Jesse Andrewsba23cc72011-09-11 03:22:13 -070035
36# set hostname
37echo $NAME > $DEST/etc/hostname
38echo "127.0.0.1 localhost $NAME" > $DEST/etc/hosts
39
40# copy kernel modules
41cp -pr /lib/modules/`uname -r` $DEST/lib/modules
42
Jesse Andrews5f098202011-09-11 16:34:34 -070043
Jesse Andrewsba23cc72011-09-11 03:22:13 -070044# copy openstack installer and requirement lists to a new directory.
45mkdir -p $DEST/opt
Jesse Andrews4d282182011-09-16 11:27:43 -070046
47# inject stack.sh and dependant files
48cp -r files $DEST/opt/files
Jesse Andrewsba23cc72011-09-11 03:22:13 -070049cp stack.sh $DEST/opt/stack.sh
Jesse Andrewsba23cc72011-09-11 03:22:13 -070050
Jesse Andrews5f098202011-09-11 16:34:34 -070051# injecting root's public ssh key if it exists
52if [ -f /root/.ssh/id_rsa.pub ]; then
53 mkdir $DEST/root/.ssh
54 chmod 700 $DEST/root/.ssh
55 cp /root/.ssh/id_rsa.pub $DEST/root/.ssh/authorized_keys
56fi
Jesse Andrewsba23cc72011-09-11 03:22:13 -070057
58# set root password to password
Jesse Andrews18d350d2011-09-12 21:46:12 -070059echo root:pass | chroot $DEST chpasswd
Jesse Andrewsba23cc72011-09-11 03:22:13 -070060
Jesse Andrews4d6cb142011-09-12 23:48:30 -070061# Create a stack user that is a member of the libvirtd group so that stack
62# is able to interact with libvirt.
63chroot $DEST groupadd libvirtd
64chroot $DEST useradd stack -s /bin/bash -d /opt -G libvirtd
65# a simple password - pass
Jesse Andrews18d350d2011-09-12 21:46:12 -070066echo stack:pass | chroot $DEST chpasswd
Jesse Andrews4d6cb142011-09-12 23:48:30 -070067# give stack ownership over /opt so it may do the work needed
Jesse Andrews18d350d2011-09-12 21:46:12 -070068chroot $DEST chown -R stack /opt
69
Jesse Andrews4d6cb142011-09-12 23:48:30 -070070# and has sudo ability (in the future this should be limited to only what
71# stack requires)
Jesse Andrews18d350d2011-09-12 21:46:12 -070072echo "stack ALL=(ALL) NOPASSWD: ALL" >> $DEST/etc/sudoers