From 713143fb07973bce45c53c0949a6fdf663ef97ec 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/scripts/curl | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'share/scripts/curl') diff --git a/share/scripts/curl b/share/scripts/curl index feaa1ba..0414413 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