]> git.proxmox.com Git - mirror_lxc.git/commitdiff
lxc-create: Support passing a full path to -t
authorStéphane Graber <stgraber@ubuntu.com>
Mon, 12 Nov 2012 21:41:14 +0000 (16:41 -0500)
committerStéphane Graber <stgraber@ubuntu.com>
Mon, 12 Nov 2012 21:41:14 +0000 (16:41 -0500)
In some cases it may be useful to pass a full path to an executable
template script directly to lxc-create.

Signed-off-by: Stéphane Graber <stgraber@ubuntu.com>
doc/lxc-create.sgml.in
src/lxc/lxc-create.in

index 99bdb7199bb7aec32b01baeed3abe8e605f258f8..bcf0545cbb74721d4ae337de8700b699a397413b 100644 (file)
@@ -113,6 +113,8 @@ Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
            eg. busybox, debian, fedora, ubuntu or sshd.
            Refer to the examples in <filename>@LXCTEMPLATEDIR@</filename>
            for details of the expected script structure.
+           Alternatively, the full path to an executable template script
+           can also be passed as a parameter.
          </para>
        </listitem>
       </varlistentry>
index 949edbe2c2ab72911391b812c4e4f653a4214e5c..e3b50ab627b08eb30bbbb9392f13bf3641e2ad90 100644 (file)
@@ -290,14 +290,20 @@ if [ $backingstore = "lvm" ]; then
 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
 
-    type ${templatedir}/lxc-$lxc_template 2>/dev/null
+    type $template_path 2>/dev/null
     if [ $? -ne 0 ]; then
         echo "$(basename $0): unknown template '$lxc_template'" >&2
         cleanup
     fi
 
-    ${templatedir}/lxc-$lxc_template --path=$lxc_path/$lxc_name --name=$lxc_name $*
+    $template_path --path=$lxc_path/$lxc_name --name=$lxc_name $*
     if [ $? -ne 0 ]; then
         echo "$(basename $0): failed to execute template '$lxc_template'" >&2
         cleanup