From 542939c31bb73bab55f2fd71243b98f5559597d1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Graber?= Date: Tue, 28 Aug 2012 13:42:27 -0400 Subject: [PATCH] Fix lxc-ubuntu and lxc-ubuntu-cloud to properly deal with /dev/shm. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Now that initscripts in Debian and Ubuntu has been updated to no longer do silly things with /dev/shm and /run/shm on installation/update, the check needs updating to detect any remaining broken case and fix it. Signed-off-by: Stéphane Graber --- templates/lxc-ubuntu-cloud.in | 7 +++---- templates/lxc-ubuntu.in | 5 ++--- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/templates/lxc-ubuntu-cloud.in b/templates/lxc-ubuntu-cloud.in index 8bd2b1b73..0551ef2b3 100644 --- a/templates/lxc-ubuntu-cloud.in +++ b/templates/lxc-ubuntu-cloud.in @@ -92,13 +92,12 @@ proc proc proc nodev,noexec,nosuid 0 0 sysfs sys sysfs defaults 0 0 EOF - # rmdir /dev/shm in precise and quantal containers. + # rmdir /dev/shm for containers that have /run/shm # 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" ] || [ $release = "quantal" ]; then - [ -d "$rootfs/dev/shm" ] && rmdir $rootfs/dev/shm - [ -e "$rootfs/dev/shm" ] && mv $rootfs/dev/shm $rootfs/dev/shm.bak + if [ ! -L $rootfs/dev/shm ] && [ -d $rootfs/run/shm ] && [ -e $rootfs/dev/shm ]; then + mv $rootfs/dev/shm $rootfs/dev/shm.bak ln -s /run/shm $rootfs/dev/shm fi diff --git a/templates/lxc-ubuntu.in b/templates/lxc-ubuntu.in index 69596fc6c..67478032b 100644 --- a/templates/lxc-ubuntu.in +++ b/templates/lxc-ubuntu.in @@ -511,9 +511,8 @@ post_process() # 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 [ -d $rootfs/run/shm ]; then - [ -d "$rootfs/dev/shm" ] && rmdir $rootfs/dev/shm - [ -e "$rootfs/dev/shm" ] && mv $rootfs/dev/shm $rootfs/dev/shm.bak + if [ ! -L $rootfs/dev/shm ] && [ -d $rootfs/run/shm ] && [ -e $rootfs/dev/shm ]; then + mv $rootfs/dev/shm $rootfs/dev/shm.bak ln -s /run/shm $rootfs/dev/shm fi }