From b210b260b1b832cd993c6382b4299f5a33a227f6 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Wed, 7 May 2014 17:32:44 -0300 Subject: [PATCH] lxc-template: Backport --rootfs fallback from old template [GH-282] --- scripts/lxc-template | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/scripts/lxc-template b/scripts/lxc-template index ad057a6..8314edf 100755 --- a/scripts/lxc-template +++ b/scripts/lxc-template @@ -88,8 +88,8 @@ if [ -z "${LXC_TARBALL}" ]; then exit 1 fi -if [ -z "${LXC_ROOTFS}" ]; then - echo "'rootfs' parameter is required" +if [ -z "${LXC_PATH}" ]; then + echo "'path' parameter is required" exit 1 fi @@ -98,9 +98,14 @@ if [ -z "${LXC_CONFIG}" ]; then exit 1 fi -if [ -z "${LXC_PATH}" ]; then - echo "'path' parameter is required" - exit 1 +# if $LXC_ROOTFS exists here, it was passed in with --rootfs +if [ -z "${LXC_ROOTFS}" ]; then + config=${LXC_PATH}/config + if grep -q '^lxc.rootfs' $config 2>/dev/null ; then + LXC_ROOTFS=`grep 'lxc.rootfs =' $config | awk -F= '{ print $2 }'` + else + LXC_ROOTFS=$LXC_PATH/rootfs + fi fi # Unpack the rootfs