blob: fa3e3ef89cbea078c75c23f85bd95abc9fe8534a [file] [log] [blame]
Jesse Andrewsba23cc72011-09-11 03:22:13 -07001#!/bin/bash
2
Anthony Young2f140202011-09-26 13:02:40 -07003# Source params
4source ./stackrc
5
Jesse Andrewsba23cc72011-09-11 03:22:13 -07006# TODO: make dest not hardcoded
7
8NAME=$1
Jesse Andrews1639ed62011-09-11 15:42:17 -07009DEST="/nfs/$NAME"
Jesse Andrewsba23cc72011-09-11 03:22:13 -070010
11# remove old nfs filesystem if one exists
12rm -rf $DEST
13
14# build a proto image - natty + packages that will install (optimization)
Jesse Andrewsf2ef7602011-09-11 16:23:21 -070015if [ ! -d proto ]; then
Jesse Andrews1639ed62011-09-11 15:42:17 -070016 debootstrap natty proto
Jesse Andrews5f098202011-09-11 16:34:34 -070017 cp files/sources.list proto/etc/apt/sources.list
Jesse Andrews1639ed62011-09-11 15:42:17 -070018 chroot proto apt-get update
Jesse Andrews4d282182011-09-16 11:27:43 -070019 chroot proto apt-get install -y `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"`
20 chroot proto pip install `cat files/pips/*`
Anthony Young2f140202011-09-26 13:02:40 -070021 git_clone $NOVA_REPO proto/opt/nova $NOVA_BRANCH
22 git_clone $GLANCE_REPO proto/opt/glance $GLANCE_BRANCH
23 git_clone $KEYSTONE_REPO proto/opt/keystone $KEYSTONE_BRANCH
24 git_clone $NOVNC_REPO proto/opt/novnc $NOVNC_BRANCH
25 git_clone $DASH_REPO proto/opt/dash $DASH_BRANCH $DASH_TAG
26 git_clone $NIXON_REPO proto/opt/nixon $NIXON_BRANCH
27 git_clone $NOVACLIENT_REPO proto/opt/python-novaclient $NOVACLIENT_BRANCH
28 git_clone $OPENSTACKX_REPO proto/opt/openstackx $OPENSTACKX_BRANCH
29 git_clone $MUNIN_REPO proto/opt/openstack-munin $MUNIN_BRANCH
Jesse Andrews543d7d42011-09-16 14:16:36 -070030 chroot proto mkdir -p /opt/files
31 wget -c http://images.ansolabs.com/tty.tgz -O proto/opt/files/tty.tgz
Jesse Andrewsba23cc72011-09-11 03:22:13 -070032fi
33
Jesse Andrews1639ed62011-09-11 15:42:17 -070034cp -pr 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