From 50e82f61b17d4de444c797e0029a96d4e7a4b557 Mon Sep 17 00:00:00 2001 From: Fabio Rehm Date: Thu, 19 Sep 2013 18:24:08 -0300 Subject: [PATCH] Remove unused arguments from generic lxc template and introduce support for the rootfs param --- boxes/common/lxc-template | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/boxes/common/lxc-template b/boxes/common/lxc-template index 9e53be4..a239a18 100755 --- a/boxes/common/lxc-template +++ b/boxes/common/lxc-template @@ -112,12 +112,8 @@ post_process() usage() { cat <] [ -S | --auth-key ] -release: the ubuntu release (e.g. precise): defaults to host release on ubuntu, otherwise uses latest LTS -trim: make a minimal (faster, but not upgrade-safe) container +$1 -h|--help [-a|--arch] [--trim] [-d|--debug] [--rootfs ] [-T|--tarball arch: the container architecture (e.g. amd64): defaults to host arch -auth-key: SSH Public key file to inject into container EOF return 0 } @@ -162,12 +158,11 @@ while true do case "$1" in -h|--help) usage $0 && exit 0;; + --rootfs) rootfs=$2; shift 2;; -p|--path) path=$2; shift 2;; -n|--name) name=$2; shift 2;; -T|--tarball) tarball=$2; shift 2;; - -r|--release) release=$2; shift 2;; -a|--arch) arch=$2; shift 2;; - -x|--trim) trim_container=1; shift 1;; -S|--auth-key) auth_key=$2; shift 2;; -d|--debug) debug=1; shift 1;; --) shift 1; break ;; @@ -179,7 +174,6 @@ if [ $debug -eq 1 ]; then set -x fi - if [ "$arch" == "i686" ]; then arch=i386 fi @@ -201,10 +195,13 @@ fi # detect rootfs config="$path/config" -if grep -q '^lxc.rootfs' $config 2>/dev/null ; then - rootfs=`grep 'lxc.rootfs =' $config | awk -F= '{ print $2 }'` -else - rootfs=$path/rootfs +# if $rootfs exists here, it was passed in with --rootfs +if [ -z "$rootfs" ]; then + if grep -q '^lxc.rootfs' $config 2>/dev/null ; then + rootfs=`grep 'lxc.rootfs =' $config | awk -F= '{ print $2 }'` + else + rootfs=$path/rootfs + fi fi install_ubuntu $rootfs $release $tarball