make build_lxc.sh work on oneiric

This commit is contained in:
Anthony Young 2011-10-14 15:02:20 -07:00
parent 1046d94ec1
commit 9ff71acb08

View file

@ -6,10 +6,8 @@ if [ "$EUID" -ne "0" ]; then
exit 1
fi
# Warn users who aren't on natty
if ! grep -q natty /etc/lsb-release; then
echo "WARNING: this script has only been tested on natty"
fi
# Keep track of ubuntu version
UBUNTU_VERSION=`cat /etc/lsb-release | grep CODENAME | sed 's/.*=//g'`
# Move to top devstack dir
cd ..
@ -92,8 +90,21 @@ function git_clone {
fi
}
# Helper to create the container
function create_lxc {
if [ "natty" = "$UBUNTU_VERSION" ]; then
lxc-create -n $CONTAINER -t natty -f $LXC_CONF
else
lxc-create -n $CONTAINER -t ubuntu -f $LXC_CONF
fi
}
# Location of the base image directory
CACHEDIR=/var/cache/lxc/natty/rootfs-amd64
if [ "natty" = "$UBUNTU_VERSION" ]; then
CACHEDIR=/var/cache/lxc/natty/rootfs-amd64
else
CACHEDIR=/var/cache/lxc/oneiric/rootfs-amd64
fi
# Provide option to do totally clean install
if [ "$CLEAR_LXC_CACHE" = "1" ]; then
@ -106,7 +117,7 @@ if [ ! -f $CACHEDIR/bootstrapped ]; then
# lazy and doesn't do anything if a container already exists)
lxc-destroy -n $CONTAINER
# trigger the initial debootstrap
lxc-create -n $CONTAINER -t natty -f $LXC_CONF
create_lxc
chroot $CACHEDIR apt-get update
chroot $CACHEDIR apt-get install -y --force-yes `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"`
chroot $CACHEDIR pip install `cat files/pips/*`
@ -143,7 +154,7 @@ if [ "$TERMINATE" = "1" ]; then
fi
# Create the container
lxc-create -n $CONTAINER -t natty -f $LXC_CONF
create_lxc
# Specify where our container rootfs lives
ROOTFS=/var/lib/lxc/$CONTAINER/rootfs/
@ -207,6 +218,10 @@ cat > $RUN_SH <<EOF
#!/usr/bin/env bash
# Make sure dns is set up
echo "nameserver $NAMESERVER" | sudo resolvconf -a eth0
# Make there is a default route - needed for natty
if ! route | grep -q default; then
sudo ip route add default via $CONTAINER_GATEWAY
fi
sleep 1
# Kill any existing screens
@ -218,7 +233,7 @@ sudo apt-get -y --force-yes install git-core vim-nox sudo
if [ ! -d "$DEST/devstack" ]; then
git clone git://github.com/cloudbuilders/devstack.git $DEST/devstack
fi
cd $DEST/devstack && $STACKSH_PARAMS ./stack.sh > /$DEST/run.sh.log
cd $DEST/devstack && $STACKSH_PARAMS FORCE=yes ./stack.sh > /$DEST/run.sh.log
echo >> /$DEST/run.sh.log
echo >> /$DEST/run.sh.log
echo "All done! Time to start clicking." >> /$DEST/run.sh.log
@ -228,11 +243,13 @@ EOF
chmod 755 $RUN_SH
# Make runner launch on boot
RC_LOCAL=$ROOTFS/etc/rc.local
RC_LOCAL=$ROOTFS/etc/init.d/local
cat > $RC_LOCAL <<EOF
#!/bin/sh -e
su -c "$DEST/run.sh" stack
EOF
chmod +x $RC_LOCAL
chroot $ROOTFS sudo update-rc.d local defaults 80
# Configure cgroup directory
if ! mount | grep -q cgroup; then