From 96b2c7175a9dc505bcb0c62c64a0817124b075d9 Mon Sep 17 00:00:00 2001 From: Dan Post Date: Mon, 25 Aug 2014 11:57:54 -0700 Subject: [PATCH] lxc-template: add parameter strip-components, as not all tarballs are created like ./rootfs/... --- scripts/lxc-template | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/scripts/lxc-template b/scripts/lxc-template index 5827e79..8036bba 100755 --- a/scripts/lxc-template +++ b/scripts/lxc-template @@ -33,6 +33,7 @@ LXC_PATH= LXC_ROOTFS= LXC_TARBALL= LXC_CONFIG= +LXC_STRIP_COMPONENTS=2 usage() { cat < ]: The path to the container's rootfs [ --mapped-uid ]: A uid map (user namespaces) [ --mapped-gid ]: A gid map (user namespaces) +[ --strip-components ]: Number of path components to strip from tarball EOF return 0 } -options=$(getopt -o h -l tarball:,config:,help:,name:,path:,rootfs:,mapped-uid:,mapped-gid: -- "$@")SS +options=$(getopt -o h -l tarball:,config:,help:,name:,path:,rootfs:,mapped-uid:,mapped-gid:,strip-components: -- "$@")SS if [ $? -ne 0 ]; then usage $(basename $0) @@ -74,6 +76,7 @@ do --rootfs) LXC_ROOTFS=$2; shift 2;; --mapped-uid) LXC_MAPPED_UID=$2; shift 2;; --mapped-gid) LXC_MAPPED_GID=$2; shift 2;; + --strip-components) LXC_STRIP_COMPONENTS=$2; shift 2;; *) break;; esac done @@ -121,7 +124,7 @@ mkdir -p /var/lock/subsys fi mkdir -p ${LXC_ROOTFS} - (cd ${LXC_ROOTFS} && tar xfz ${LXC_TARBALL} --strip-components=2) + (cd ${LXC_ROOTFS} && tar xfz ${LXC_TARBALL} --strip-components=${LXC_STRIP_COMPONENTS}) if [ $? -ne 0 ]; then echo "Failed to extract rootfs" exit 1