Browse code

some enhancements to bootstrapping to better detect if we've properly warmed the cache. Also provide option to delete lxc cache

Anthony Young authored on 2011/09/29 07:12:18
Showing 1 changed files
... ...
@@ -75,9 +75,16 @@ function git_clone {
75 75
     fi
76 76
 }
77 77
 
78
-# Warm the base image on first install
78
+# Location of the base image directory
79 79
 CACHEDIR=/var/cache/lxc/natty/rootfs-amd64
80
-if [ ! -d $CACHEDIR ]; then
80
+
81
+# Provide option to do totally clean install
82
+if [ "$CLEAR_LXC_CACHE" = "1" ]; then
83
+    rm -rf $CACHEDIR
84
+fi
85
+
86
+# Warm the base image on first install
87
+if [ ! -f $CACHEDIR/bootstrapped ]; then
81 88
     # by deleting the container, we force lxc-create to re-bootstrap (lxc is
82 89
     # lazy and doesn't do anything if a container already exists)
83 90
     lxc-destroy -n $CONTAINER
... ...
@@ -86,6 +93,7 @@ if [ ! -d $CACHEDIR ]; then
86 86
     chroot $CACHEDIR apt-get update
87 87
     chroot $CACHEDIR apt-get install -y --force-yes `cat files/apts/* | cut -d\# -f1 | egrep -v "(rabbitmq|libvirt-bin|mysql-server|munin-node)"`
88 88
     chroot $CACHEDIR pip install `cat files/pips/*`
89
+    touch $CACHEDIR/bootstrapped
89 90
 fi
90 91
 
91 92
 # Clean out code repos if directed to do so