[Devel] [PATCH] liblxc: lxc-debian expects missing directories

Matt Helsley matthltc at us.ibm.com
Thu Feb 5 01:05:17 PST 2009


lxc-debian fails unless the directories a given rootfs needs already
exist. To fix this without relying on any particular function call order
we can do: mkdir -p `dirname PATH/TO/FILE`
before actually making the file.

Signed-off-by: Matt Helsley <matthltc at us.ibm.com>
---
 scripts/lxc-debian.in |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

Index: lxc/scripts/lxc-debian.in
===================================================================
--- lxc.orig/scripts/lxc-debian.in
+++ lxc/scripts/lxc-debian.in
@@ -24,13 +24,14 @@ SSHD_CONFIG="/etc/ssh/sshd_config"
 # custom selinux
 
 write_debian_selinux() {
-    mkdir $ROOTFS/selinux
+    mkdir -p $ROOTFS/selinux
     echo 0 > $ROOTFS/selinux/enforce
 }
 
 # custom fstab
 
 write_debian_fstab() {
+mkdir -p `dirname $ROOTFS/$FSTAB`
 cat <<EOF > $ROOTFS/$FSTAB
 tmpfs  /dev/shm   tmpfs  defaults  0 0
 EOF
@@ -39,6 +40,7 @@ EOF
 # custom inittab
 
 write_debian_inittab() {
+mkdir -p `dirname $ROOTFS/$INITTAB`
 cat <<EOF > $ROOTFS/$INITTAB
 id:3:initdefault:
 si::sysinit:/etc/init.d/rcS
@@ -62,6 +64,7 @@ EOF
 # custom network configuration
 
 write_debian_network() {
+mkdir -p `dirname $ROOTFS/$INTERFACES`
 cat <<EOF > $ROOTFS/$INTERFACES
 auto eth0 lo
 iface eth0 inet static
@@ -76,6 +79,7 @@ EOF
 # custom hostname
 
 write_debian_hostname() {
+mkdir -p `dirname $ROOTFS/$HOSTNAME`
 cat <<EOF > $ROOTFS/$HOSTNAME
 $UTSNAME
 EOF
@@ -84,6 +88,7 @@ EOF
 # custom sshd configuration file
 
 write_debian_sshd_config() {
+mkdir -p `dirname $ROOTFS/$SSHD_CONFIG`
 cat <<EOF > $ROOTFS/$SSHD_CONFIG
 Port 22
 Protocol 2


_______________________________________________
Containers mailing list
Containers at lists.linux-foundation.org
https://lists.linux-foundation.org/mailman/listinfo/containers




More information about the Devel mailing list