From 9ff71acb08e4885d7da8cb44aedb2ff79f4e0909 Mon Sep 17 00:00:00 2001 From: Anthony Young Date: Fri, 14 Oct 2011 15:02:20 -0700 Subject: [PATCH] make build_lxc.sh work on oneiric --- tools/build_lxc.sh | 35 ++++++++++++++++++++++++++--------- 1 file changed, 26 insertions(+), 9 deletions(-) diff --git a/tools/build_lxc.sh b/tools/build_lxc.sh index d4df344..507f93e 100755 --- a/tools/build_lxc.sh +++ b/tools/build_lxc.sh @@ -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 < /$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 <