From 81e38b00597be6880d232d8807cde33159b3dd68 Mon Sep 17 00:00:00 2001 From: Felix Abecassis Date: Thu, 30 Nov 2017 22:51:38 -0800 Subject: [PATCH] lxc-oci: cleanup temporary download directory if umoci is interrupted Signed-off-by: Felix Abecassis --- templates/lxc-oci.in | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/templates/lxc-oci.in b/templates/lxc-oci.in index f98c38bcd..1c7e0721f 100755 --- a/templates/lxc-oci.in +++ b/templates/lxc-oci.in @@ -38,8 +38,11 @@ LXC_TEMPLATE_CONFIG="@LXCTEMPLATECONFIG@" # Some useful functions cleanup() { - if [ -d "$DOWNLOAD_TEMP" ]; then - rm -Rf $DOWNLOAD_TEMP + if [ -d "${DOWNLOAD_TEMP}" ]; then + rm -Rf "${DOWNLOAD_TEMP}" + fi + if [ -d "${LXC_ROOTFS}.tmp" ]; then + rm -Rf "${LXC_ROOTFS}.tmp" fi } @@ -244,7 +247,6 @@ fi umoci unpack ${umoci_args[@]} --image "${DOWNLOAD_TEMP}:latest" "${LXC_ROOTFS}.tmp" rmdir "${LXC_ROOTFS}" mv "${LXC_ROOTFS}.tmp/rootfs" "${LXC_ROOTFS}" -rm -rf "${LXC_ROOTFS}.tmp" OCI_CONF_FILE=$(getconfigpath ${DOWNLOAD_TEMP} latest) LXC_CONF_FILE="${LXC_PATH}/config" -- 2.47.2