blob: c0fa7332d0c1de1a5485510eb8e8bdf57818ef1c [file] [log] [blame]
Jesse Andrewsba23cc72011-09-11 03:22:13 -07001#!/bin/bash
2
Anthony Youngd8c259a2011-09-26 14:04:13 -07003# Use stackrc.example if stackrc is missing
4if [ ! -e ./stackrc ]; then
5 read -n1 -p "No stackrc present. Copy stackrc.example to stackrc? (y/n) "
6 echo
7 [[ $REPLY = [yY] ]] && cp stackrc.example stackrc|| { echo "Aborting: Missing stackrc"; exit 1; }
8fi
9
Anthony Young2f140202011-09-26 13:02:40 -070010# Source params
11source ./stackrc
12
Jesse Andrewsba23cc72011-09-11 03:22:13 -070013# TODO: make dest not hardcoded
14
15NAME=$1
Jesse Andrews1639ed62011-09-11 15:42:17 -070016DEST="/nfs/$NAME"
Jesse Andrewsba23cc72011-09-11 03:22:13 -070017
18# remove old nfs filesystem if one exists
19rm -rf $DEST
20
21# build a proto image - natty + packages that will install (optimization)
Jesse Andrewsf2ef7602011-09-11 16:23:21 -070022if [ ! -d proto ]; then
Jesse Andrews1639ed62011-09-11 15:42:17 -070023 debootstrap natty proto
Jesse Andrews5f098202011-09-11 16:34:34 -070024 cp files/sources.list proto/etc/apt/sources.list
Jesse Andrews1639ed62011-09-11 15:42:17 -070025 chroot proto apt-get update
Jesse Andrews4d282182011-09-16 11:27:43 -070026 chroot proto apt-get install -y `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"`
27 chroot proto pip install `cat files/pips/*`
Anthony Young2f140202011-09-26 13:02:40 -070028 git_clone $NOVA_REPO proto/opt/nova $NOVA_BRANCH
29 git_clone $GLANCE_REPO proto/opt/glance $GLANCE_BRANCH
30 git_clone $KEYSTONE_REPO proto/opt/keystone $KEYSTONE_BRANCH
31 git_clone $NOVNC_REPO proto/opt/novnc $NOVNC_BRANCH
32 git_clone $DASH_REPO proto/opt/dash $DASH_BRANCH $DASH_TAG
33 git_clone $NIXON_REPO proto/opt/nixon $NIXON_BRANCH
34 git_clone $NOVACLIENT_REPO proto/opt/python-novaclient $NOVACLIENT_BRANCH
35 git_clone $OPENSTACKX_REPO proto/opt/openstackx $OPENSTACKX_BRANCH
36 git_clone $MUNIN_REPO proto/opt/openstack-munin $MUNIN_BRANCH
Jesse Andrews543d7d42011-09-16 14:16:36 -070037 chroot proto mkdir -p /opt/files
38 wget -c http://images.ansolabs.com/tty.tgz -O proto/opt/files/tty.tgz
Jesse Andrewsba23cc72011-09-11 03:22:13 -070039fi
40
Jesse Andrews1639ed62011-09-11 15:42:17 -070041cp -pr proto $DEST
Jesse Andrewsba23cc72011-09-11 03:22:13 -070042
43# set hostname
44echo $NAME > $DEST/etc/hostname
45echo "127.0.0.1 localhost $NAME" > $DEST/etc/hosts
46
47# copy kernel modules
48cp -pr /lib/modules/`uname -r` $DEST/lib/modules
49
Jesse Andrews5f098202011-09-11 16:34:34 -070050
Jesse Andrewsba23cc72011-09-11 03:22:13 -070051# copy openstack installer and requirement lists to a new directory.
52mkdir -p $DEST/opt
Jesse Andrews4d282182011-09-16 11:27:43 -070053
54# inject stack.sh and dependant files
55cp -r files $DEST/opt/files
Jesse Andrewsba23cc72011-09-11 03:22:13 -070056cp stack.sh $DEST/opt/stack.sh
Jesse Andrewsba23cc72011-09-11 03:22:13 -070057
Jesse Andrews5f098202011-09-11 16:34:34 -070058# injecting root's public ssh key if it exists
59if [ -f /root/.ssh/id_rsa.pub ]; then
60 mkdir $DEST/root/.ssh
61 chmod 700 $DEST/root/.ssh
62 cp /root/.ssh/id_rsa.pub $DEST/root/.ssh/authorized_keys
63fi
Jesse Andrewsba23cc72011-09-11 03:22:13 -070064
65# set root password to password
Jesse Andrews18d350d2011-09-12 21:46:12 -070066echo root:pass | chroot $DEST chpasswd
Jesse Andrewsba23cc72011-09-11 03:22:13 -070067
Jesse Andrews4d6cb142011-09-12 23:48:30 -070068# Create a stack user that is a member of the libvirtd group so that stack
69# is able to interact with libvirt.
70chroot $DEST groupadd libvirtd
71chroot $DEST useradd stack -s /bin/bash -d /opt -G libvirtd
72# a simple password - pass
Jesse Andrews18d350d2011-09-12 21:46:12 -070073echo stack:pass | chroot $DEST chpasswd
Jesse Andrews4d6cb142011-09-12 23:48:30 -070074# give stack ownership over /opt so it may do the work needed
Jesse Andrews18d350d2011-09-12 21:46:12 -070075chroot $DEST chown -R stack /opt
76
Jesse Andrews4d6cb142011-09-12 23:48:30 -070077# and has sudo ability (in the future this should be limited to only what
78# stack requires)
Jesse Andrews18d350d2011-09-12 21:46:12 -070079echo "stack ALL=(ALL) NOPASSWD: ALL" >> $DEST/etc/sudoers