From 5887a63a74e14a60f60eebc27a9e622598fe4cb3 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Sun, 13 Nov 2016 06:05:43 +0100 Subject: Adding --clean option to curl container create script to remove downloaded tarball from cache after successfull container creation. Signed-off-by: Daniel Baumann --- share/man/container-create-curl.1.txt | 3 +++ share/scripts/curl | 16 ++++++++++++++-- 2 files changed, 17 insertions(+), 2 deletions(-) (limited to 'share') diff --git a/share/man/container-create-curl.1.txt b/share/man/container-create-curl.1.txt index 7965cc4..68fc0e2 100644 --- a/share/man/container-create-curl.1.txt +++ b/share/man/container-create-curl.1.txt @@ -51,6 +51,9 @@ The following script options are available: *-n, --name='NAME'*:: Specify container name. +"--clean*:: + Remove downloaded tarball after successfull container creation. + *--image='IMAGE'*:: Specify the image name to download, defaults to debian-stretch-${ARCHITECTURE}.tar.xz (where ${ARCHITECTURE} is the host systems architecture). diff --git a/share/scripts/curl b/share/scripts/curl index 6a9f784..8af1446 100755 --- a/share/scripts/curl +++ b/share/scripts/curl @@ -25,7 +25,7 @@ CACHE="/var/cache/container-tools/curl" Parameters () { - LONG_OPTIONS="bind:,script:,name:,image:,server:,password:" + LONG_OPTIONS="bind:,script:,name:,clean,image:,server:,password:" OPTIONS="b:,s:,n:,p:" PARAMETERS="$(getopt --longoptions ${LONG_OPTIONS} --name=${SCRIPT} --options ${OPTIONS} --shell sh -- ${@})" @@ -61,6 +61,11 @@ Parameters () shift 2 ;; + --clean) + CLEAN="true" + shift 1 + ;; + --image) IMAGE="${2}" shift 2 @@ -91,7 +96,7 @@ Parameters () Usage () { - echo "Usage: container create -n|--name NAME -s|--script ${SCRIPT} -- [--image IMAGE] [--server SERVER] [-p|--password PASSWORD}" >&2 + echo "Usage: container create -n|--name NAME -s|--script ${SCRIPT} -- [--clean] [--image IMAGE] [--server SERVER] [-p|--password PASSWORD}" >&2 exit 1 } @@ -190,3 +195,10 @@ cp -L /etc/resolv.conf "${MACHINES}/${NAME}/etc/resolv.conf" # Setting root password echo root:${PASSWORD} | chroot "${MACHINES}/${NAME}" chpasswd echo "${NAME}: root password set to '${PASSWORD}'." + +# Reove cache +case "${CLEAN}" in + true) + rm -f "${CACHE}/${IMAGE}" + ;; +esac -- cgit v1.2.3