diff --git a/build_lxc.sh b/build_lxc.sh index 1a2cea3..d247818 100755 --- a/build_lxc.sh +++ b/build_lxc.sh @@ -12,9 +12,19 @@ WARMCACHE=${WARMCACHE:-0} # Destroy any existing container lxc-stop -n $CONTAINER -sleep 1 +sleep 2 lxc-destroy -n $CONTAINER -sleep 1 +sleep 2 + +CACHEDIR=/var/cache/lxc/natty/rootfs-amd64 +if [ "$WARMCACHE" = "1" ]; then + if [ -d $CACHEDIR ]; then + # Pre-cache files + chroot $CACHEDIR apt-get update + chroot $CACHEDIR apt-get install -y `cat apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"` + chroot $CACHEDIR pip install `cat pips/*` + fi +fi # Create network configuration NET_CONF=/tmp/net.conf @@ -27,14 +37,7 @@ EOF # Configure the network lxc-create -n $CONTAINER -t natty -f $NET_CONF - -if [ "$WARMCACHE" = "1" ]; then - # Pre-cache files - BASECACHE=/var/cache/lxc/natty/rootfs-amd64 - chroot $BASECACHE apt-get update - chroot $BASECACHE apt-get install -y `cat apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server)"` - chroot $BASECACHE pip install `cat pips/*` -fi +sleep 2 # Where our container lives ROOTFS=/var/lib/lxc/$CONTAINER/rootfs/ @@ -67,9 +70,27 @@ cat > $INSTALL_SH <> /etc/sudoers + +# Install and run stack.sh apt-get update apt-get -y --force-yes install git-core vim-nox sudo -git clone git://github.com/cloudbuilders/nfs-stack.git /root/nfs-stack +su -c "git clone git://github.com/cloudbuilders/nfs-stack.git /opt/nfs-stack" stack +su -c "cd /opt/nfs-stack && ./stack.sh" stack EOF chmod 700 $INSTALL_SH @@ -81,20 +102,9 @@ cat > $RC_LOCAL <