]> git.proxmox.com Git - mirror_lxc.git/commitdiff
lxc-oci: cleanup temporary download directory if umoci is interrupted
authorFelix Abecassis <fabecassis@nvidia.com>
Fri, 1 Dec 2017 06:51:38 +0000 (22:51 -0800)
committerFelix Abecassis <fabecassis@nvidia.com>
Fri, 1 Dec 2017 06:51:38 +0000 (22:51 -0800)
Signed-off-by: Felix Abecassis <fabecassis@nvidia.com>
templates/lxc-oci.in

index f98c38bcdd4a3b1529d360fd8e61263853ebebb4..1c7e0721f452b4e68b9f5a536c77f3242e01bb9c 100755 (executable)
@@ -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"