2011-09-11 10:22:13 +00:00
|
|
|
#!/bin/bash
|
|
|
|
|
2011-09-26 21:04:13 +00:00
|
|
|
# Use stackrc.example if stackrc is missing
|
|
|
|
if [ ! -e ./stackrc ]; then
|
|
|
|
read -n1 -p "No stackrc present. Copy stackrc.example to stackrc? (y/n) "
|
|
|
|
echo
|
|
|
|
[[ $REPLY = [yY] ]] && cp stackrc.example stackrc|| { echo "Aborting: Missing stackrc"; exit 1; }
|
|
|
|
fi
|
|
|
|
|
2011-09-26 20:02:40 +00:00
|
|
|
# Source params
|
|
|
|
source ./stackrc
|
|
|
|
|
2011-09-11 10:22:13 +00:00
|
|
|
# TODO: make dest not hardcoded
|
|
|
|
|
|
|
|
NAME=$1
|
2011-09-11 22:42:17 +00:00
|
|
|
DEST="/nfs/$NAME"
|
2011-09-11 10:22:13 +00:00
|
|
|
|
|
|
|
# remove old nfs filesystem if one exists
|
|
|
|
rm -rf $DEST
|
|
|
|
|
|
|
|
# build a proto image - natty + packages that will install (optimization)
|
2011-09-11 23:23:21 +00:00
|
|
|
if [ ! -d proto ]; then
|
2011-09-11 22:42:17 +00:00
|
|
|
debootstrap natty proto
|
2011-09-11 23:34:34 +00:00
|
|
|
cp files/sources.list proto/etc/apt/sources.list
|
2011-09-11 22:42:17 +00:00
|
|
|
chroot proto apt-get update
|
2011-09-16 18:27:43 +00:00
|
|
|
chroot proto apt-get install -y `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"`
|
|
|
|
chroot proto pip install `cat files/pips/*`
|
2011-09-26 20:02:40 +00:00
|
|
|
git_clone $NOVA_REPO proto/opt/nova $NOVA_BRANCH
|
|
|
|
git_clone $GLANCE_REPO proto/opt/glance $GLANCE_BRANCH
|
|
|
|
git_clone $KEYSTONE_REPO proto/opt/keystone $KEYSTONE_BRANCH
|
|
|
|
git_clone $NOVNC_REPO proto/opt/novnc $NOVNC_BRANCH
|
|
|
|
git_clone $DASH_REPO proto/opt/dash $DASH_BRANCH $DASH_TAG
|
|
|
|
git_clone $NIXON_REPO proto/opt/nixon $NIXON_BRANCH
|
|
|
|
git_clone $NOVACLIENT_REPO proto/opt/python-novaclient $NOVACLIENT_BRANCH
|
|
|
|
git_clone $OPENSTACKX_REPO proto/opt/openstackx $OPENSTACKX_BRANCH
|
|
|
|
git_clone $MUNIN_REPO proto/opt/openstack-munin $MUNIN_BRANCH
|
2011-09-16 21:16:36 +00:00
|
|
|
chroot proto mkdir -p /opt/files
|
|
|
|
wget -c http://images.ansolabs.com/tty.tgz -O proto/opt/files/tty.tgz
|
2011-09-11 10:22:13 +00:00
|
|
|
fi
|
|
|
|
|
2011-09-11 22:42:17 +00:00
|
|
|
cp -pr proto $DEST
|
2011-09-11 10:22:13 +00:00
|
|
|
|
|
|
|
# set hostname
|
|
|
|
echo $NAME > $DEST/etc/hostname
|
|
|
|
echo "127.0.0.1 localhost $NAME" > $DEST/etc/hosts
|
|
|
|
|
|
|
|
# copy kernel modules
|
|
|
|
cp -pr /lib/modules/`uname -r` $DEST/lib/modules
|
|
|
|
|
2011-09-11 23:34:34 +00:00
|
|
|
|
2011-09-11 10:22:13 +00:00
|
|
|
# copy openstack installer and requirement lists to a new directory.
|
|
|
|
mkdir -p $DEST/opt
|
2011-09-16 18:27:43 +00:00
|
|
|
|
|
|
|
# inject stack.sh and dependant files
|
|
|
|
cp -r files $DEST/opt/files
|
2011-09-11 10:22:13 +00:00
|
|
|
cp stack.sh $DEST/opt/stack.sh
|
|
|
|
|
2011-09-11 23:34:34 +00:00
|
|
|
# injecting root's public ssh key if it exists
|
|
|
|
if [ -f /root/.ssh/id_rsa.pub ]; then
|
|
|
|
mkdir $DEST/root/.ssh
|
|
|
|
chmod 700 $DEST/root/.ssh
|
|
|
|
cp /root/.ssh/id_rsa.pub $DEST/root/.ssh/authorized_keys
|
|
|
|
fi
|
2011-09-11 10:22:13 +00:00
|
|
|
|
|
|
|
# set root password to password
|
2011-09-13 04:46:12 +00:00
|
|
|
echo root:pass | chroot $DEST chpasswd
|
2011-09-11 10:22:13 +00:00
|
|
|
|
2011-09-13 06:48:30 +00:00
|
|
|
# Create a stack user that is a member of the libvirtd group so that stack
|
|
|
|
# is able to interact with libvirt.
|
|
|
|
chroot $DEST groupadd libvirtd
|
|
|
|
chroot $DEST useradd stack -s /bin/bash -d /opt -G libvirtd
|
|
|
|
# a simple password - pass
|
2011-09-13 04:46:12 +00:00
|
|
|
echo stack:pass | chroot $DEST chpasswd
|
2011-09-13 06:48:30 +00:00
|
|
|
# give stack ownership over /opt so it may do the work needed
|
2011-09-13 04:46:12 +00:00
|
|
|
chroot $DEST chown -R stack /opt
|
|
|
|
|
2011-09-13 06:48:30 +00:00
|
|
|
# and has sudo ability (in the future this should be limited to only what
|
|
|
|
# stack requires)
|
2011-09-13 04:46:12 +00:00
|
|
|
echo "stack ALL=(ALL) NOPASSWD: ALL" >> $DEST/etc/sudoers
|