diff --git a/build_lxc.sh b/build_lxc.sh index 2ef5c08..e4fda6e 100755 --- a/build_lxc.sh +++ b/build_lxc.sh @@ -10,16 +10,19 @@ NAMESERVER=${NAMESERVER:-192.168.1.1} COPYENV=${COPYENV:-1} WARMCACHE=${WARMCACHE:-0} -# Destroy any existing container +# Shutdown any existing container lxc-stop -n $CONTAINER sleep 1 +# This prevents zombie containers cgdelete -r cpu,net_cls:$CONTAINER sleep 1 +# Destroy the old container lxc-destroy -n $CONTAINER sleep 1 +# Warm the base image on first run or when WARMCACHE=1 CACHEDIR=/var/cache/lxc/natty/rootfs-amd64 -if [ "$WARMCACHE" = "1" ]; then +if [ "$WARMCACHE" = "1" ] || [ ! -d $CACHEDIR ]; then if [ -d $CACHEDIR ]; then # Pre-cache files chroot $CACHEDIR apt-get update @@ -29,17 +32,18 @@ if [ "$WARMCACHE" = "1" ]; then fi # Create network configuration -NET_CONF=/tmp/net.conf -cat > $NET_CONF < $LXC_CONF <