Description: in precise, make /dev/shm a symbolic link to /run/shm
 This would be done (though done wrongly) by mounted-dev.conf, but
 that doesn't run because we don't mount /dev.
Author: Serge Hallyn <serge.hallyn@ubuntu.com>
Forwarded: no
Bug-Ubuntu: https://bugs.launchpad.net/launchpad/+bug/974584

Index: lxc-0.7.5/templates/lxc-ubuntu-cloud.in
===================================================================
--- lxc-0.7.5.orig/templates/lxc-ubuntu-cloud.in	2012-04-12 10:33:38.000000000 -0500
+++ lxc-0.7.5/templates/lxc-ubuntu-cloud.in	2012-04-12 11:11:57.066675104 -0500
@@ -31,6 +31,7 @@
     rootfs=$2
     name=$3
     arch=$4
+    release=$5
 
     if [ $arch = "i386" ]; then
         arch="i686"
@@ -93,6 +94,16 @@
 sysfs           sys          sysfs defaults  0 0
 EOF
 
+    # rmdir /dev/shm in precise containers.
+    # I'm afraid of doing rm -rf $rootfs/dev/shm, in case it did
+    # get bind mounted to the host's /run/shm.  So try to rmdir
+    # it, and in case that fails move it out of the way.
+    if [ $release = "precise" ]; then
+        [ -d "$rootfs/dev/shm" ] && rmdir $rootfs/dev/shm
+        [ -e "$rootfs/dev/shm" ] && mv $rootfs/dev/shm $rootfs/dev/shm.bak
+        ln -s /run/shm $rootfs/dev/shm
+    fi
+
     return 0
 }
 
@@ -360,7 +371,7 @@
 
 ) 200>/var/lock/subsys/lxc-ubucloud
 
-copy_configuration $path $rootfs $name $arch
+copy_configuration $path $rootfs $name $arch $release
 
 echo "Container $name created."
 exit 0
Index: lxc-0.7.5/templates/lxc-ubuntu.in
===================================================================
--- lxc-0.7.5.orig/templates/lxc-ubuntu.in	2012-04-12 10:33:38.000000000 -0500
+++ lxc-0.7.5/templates/lxc-ubuntu.in	2012-04-12 11:11:36.498674838 -0500
@@ -491,6 +491,16 @@
         chroot $rootfs apt-get update
         chroot $rootfs apt-get install --force-yes -y --no-install-recommends upstart:${hostarch} mountall:amd64 iproute:amd64 isc-dhcp-client:amd64
     fi
+
+    # rmdir /dev/shm in precise containers.
+    # I'm afraid of doing rm -rf $rootfs/dev/shm, in case it did
+    # get bind mounted to the host's /run/shm.  So try to rmdir
+    # it, and in case that fails move it out of the way.
+    if [ $release = "precise" ]; then
+        [ -d "$rootfs/dev/shm" ] && rmdir $rootfs/dev/shm
+        [ -e "$rootfs/dev/shm" ] && mv $rootfs/dev/shm $rootfs/dev/shm.bak
+        ln -s /run/shm $rootfs/dev/shm
+    fi
 }
 
 do_bindhome()
