]> git.ipfire.org Git - thirdparty/lxc.git/commitdiff
lxc-create: Allow for empty or unset template name
authorStéphane Graber <stgraber@ubuntu.com>
Fri, 7 Dec 2012 15:41:10 +0000 (10:41 -0500)
committerStéphane Graber <stgraber@ubuntu.com>
Fri, 7 Dec 2012 17:25:54 +0000 (12:25 -0500)
This restores an old behaviour where lxc-create can be called without
a template. In such case, only a minimal configuration is built and no
rootfs is created. However the various backingstore code is still used.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
Acked-by: Serge E. Hallyn <serge.hallyn@ubuntu.com>
src/lxc/lxc-create.in

index 3c66bfa7b592ae2a51f4110a4d93f47dedfe8960..5cd9fdba5d0f4ab793ec241112cd09a4448966e1 100644 (file)
@@ -284,19 +284,19 @@ if [ ! -r "$lxc_config" ]; then
     exit 1
 fi
 
-# Allow for a path to be provided as the template name
-if [ -x "$lxc_template" ]; then
-    template_path=$lxc_template
-else
-    template_path=${templatedir}/lxc-$lxc_template
-fi
+if [ ! -z "$lxc_template" ]; then
+    # Allow for a path to be provided as the template name
+    if [ -x "$lxc_template" ]; then
+        template_path=$lxc_template
+    else
+        template_path=${templatedir}/lxc-$lxc_template
+    fi
 
-if ! [ -x "$template_path" ]; then
-    echo "$(basename $0): unknown template '$lxc_template'" >&2
-    cleanup
-fi
+    if ! [ -x "$template_path" ]; then
+        echo "$(basename $0): unknown template '$lxc_template'" >&2
+        cleanup
+    fi
 
-if [ ! -z "$lxc_template" ]; then
     sum=$(sha1sum $template_path | cut -d ' ' -f1)
     echo "# Template used to create this container: $lxc_template" >> $lxc_path/$lxc_name/config
     if [ -n "$*" ]; then