build_nfs.sh match build_pxe_ramdisk.sh

This commit is contained in:
Dean Troyer 2011-10-03 09:30:57 -05:00
parent 4cbb267679
commit cc80654450

View file

@ -1,5 +1,6 @@
#!/bin/bash
PROGDIR=`dirname $0`
CHROOTCACHE=${CHROOTCACHE:-/root/cache}
# Source params
@ -13,25 +14,83 @@ DEST="/nfs/$NAME"
# remove old nfs filesystem if one exists
rm -rf $DEST
# build a proto image - natty + packages that will install (optimization)
if [ ! -d $CHROOTCACHE/proto ]; then
debootstrap natty $CHROOTCACHE/proto
cp files/sources.list $CHROOTCACHE/proto/etc/apt/sources.list
chroot $CHROOTCACHE/proto apt-get update
chroot $CHROOTCACHE/proto apt-get install -y `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"`
chroot $CHROOTCACHE/proto pip install `cat files/pips/*`
git_clone $NOVA_REPO $CHROOTCACHE/proto/opt/nova $NOVA_BRANCH
git_clone $GLANCE_REPO $CHROOTCACHE/proto/opt/glance $GLANCE_BRANCH
git_clone $KEYSTONE_REPO $CHROOTCACHE/proto/opt/keystone $KEYSTONE_BRANCH
git_clone $NOVNC_REPO $CHROOTCACHE/proto/opt/novnc $NOVNC_BRANCH
git_clone $DASH_REPO $CHROOTCACHE/proto/opt/dash $DASH_BRANCH $DASH_TAG
git_clone $NOVACLIENT_REPO $CHROOTCACHE/proto/opt/python-novaclient $NOVACLIENT_BRANCH
git_clone $OPENSTACKX_REPO $CHROOTCACHE/proto/opt/openstackx $OPENSTACKX_BRANCH
chroot $CHROOTCACHE/proto mkdir -p /opt/files
wget -c http://images.ansolabs.com/tty.tgz -O $CHROOTCACHE/proto/opt/files/tty.tgz
# clean install of natty
if [ ! -d $CHROOTCACHE/natty-base ]; then
$PROGDIR/make_image.sh -C natty $CHROOTCACHE/natty-base
# copy kernel modules...
# NOTE(ja): is there a better way to do this?
cp -pr /lib/modules/`uname -r` $CHROOTCACHE/natty-base/lib/modules
# a simple password - pass
echo root:pass | chroot $CHROOTCACHE/natty-base chpasswd
fi
cp -pr $CHROOTCACHE/proto $DEST
# prime natty with as many apt/pips as we can
if [ ! -d $CHROOTCACHE/natty-dev ]; then
rsync -azH $CHROOTCACHE/natty-base/ $CHROOTCACHE/natty-dev/
chroot $CHROOTCACHE/natty-dev apt-get install -y `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"`
chroot $CHROOTCACHE/natty-dev pip install `cat files/pips/*`
# Create a stack user that is a member of the libvirtd group so that stack
# is able to interact with libvirt.
chroot $CHROOTCACHE/natty-dev groupadd libvirtd
chroot $CHROOTCACHE/natty-dev useradd stack -s /bin/bash -d /opt -G libvirtd
# a simple password - pass
echo stack:pass | chroot $CHROOTCACHE/natty-dev chpasswd
# and has sudo ability (in the future this should be limited to only what
# stack requires)
echo "stack ALL=(ALL) NOPASSWD: ALL" >> $CHROOTCACHE/natty-dev/etc/sudoers
fi
# clone git repositories onto the system
# ======================================
if [ ! -d $CHROOTCACHE/natty-stack ]; then
rsync -azH $CHROOTCACHE/natty-dev/ $CHROOTCACHE/natty-stack/
fi
# git clone only if directory doesn't exist already. Since ``DEST`` might not
# be owned by the installation user, we create the directory and change the
# ownership to the proper user.
function git_clone {
# clone new copy or fetch latest changes
CHECKOUT=$CHROOTCACHE/natty-stack$2
if [ ! -d $CHECKOUT ]; then
mkdir -p $CHECKOUT
git clone $1 $CHECKOUT
else
pushd $CHECKOUT
git fetch
popd
fi
# FIXME(ja): checkout specified version (should works for branches and tags)
pushd $CHECKOUT
# checkout the proper branch/tag
git checkout $3
# force our local version to be the same as the remote version
git reset --hard origin/$3
popd
# give ownership to the stack user
chroot $CHROOTCACHE/natty-stack/ chown -R stack $2
}
git_clone $NOVA_REPO /opt/stack/nova $NOVA_BRANCH
git_clone $GLANCE_REPO /opt/stack/glance $GLANCE_BRANCH
git_clone $KEYSTONE_REPO /opt/stack/keystone $KEYSTONE_BRANCH
git_clone $NOVNC_REPO /opt/stack/novnc $NOVNC_BRANCH
git_clone $DASH_REPO /opt/stack/dash $DASH_BRANCH $DASH_TAG
git_clone $NOVACLIENT_REPO /opt/stack/python-novaclient $NOVACLIENT_BRANCH
git_clone $OPENSTACKX_REPO /opt/stack/openstackx $OPENSTACKX_BRANCH
chroot $CHROOTCACHE/natty-stack mkdir -p /opt/stack/files
wget -c http://images.ansolabs.com/tty.tgz -O $CHROOTCACHE/natty-stack/opt/stack/files/tty.tgz
cp -pr $CHROOTCACHE/natty-stack $DEST
# set hostname
echo $NAME > $DEST/etc/hostname
@ -54,19 +113,3 @@ if [ -f /root/.ssh/id_rsa.pub ]; then
chmod 700 $DEST/root/.ssh
cp /root/.ssh/id_rsa.pub $DEST/root/.ssh/authorized_keys
fi
# set root password to password
echo root:pass | chroot $DEST chpasswd
# 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
echo stack:pass | chroot $DEST chpasswd
# give stack ownership over /opt so it may do the work needed
chroot $DEST chown -R stack /opt
# and has sudo ability (in the future this should be limited to only what
# stack requires)
echo "stack ALL=(ALL) NOPASSWD: ALL" >> $DEST/etc/sudoers