From 428fd5992521ad14afe32e1aed3145d860c6b5c6 Mon Sep 17 00:00:00 2001 From: Jose Date: Thu, 9 Jul 2020 22:26:06 -0400 Subject: [PATCH] Recursively destroy base release to deal with previous snapshots --- usr/local/share/bastille/destroy.sh | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/usr/local/share/bastille/destroy.sh b/usr/local/share/bastille/destroy.sh index b4c84a3..71f1090 100644 --- a/usr/local/share/bastille/destroy.sh +++ b/usr/local/share/bastille/destroy.sh @@ -96,6 +96,8 @@ destroy_jail() { } destroy_rel() { + local OPTIONS + ## check release name match before destroy if [ -n "${NAME_VERIFY}" ]; then TARGET="${NAME_VERIFY}" @@ -125,10 +127,16 @@ destroy_rel() { echo -e "${COLOR_GREEN}Deleting base: ${TARGET}.${COLOR_RESET}" if [ "${bastille_zfs_enable}" = "YES" ]; then if [ -n "${bastille_zfs_zpool}" ]; then - zfs destroy "${bastille_zfs_zpool}/${bastille_zfs_prefix}/releases/${TARGET}" - if [ "${FORCE}" = "1" ]; then - if [ -d "${bastille_cachedir}/${TARGET}" ]; then - zfs destroy "${bastille_zfs_zpool}/${bastille_zfs_prefix}/cache/${TARGET}" + if [ -n "${TARGET}" ]; then + OPTIONS="-r" + if [ "${FORCE}" = "1" ]; then + OPTIONS="-rf" + fi + zfs destroy "${OPTIONS}" "${bastille_zfs_zpool}/${bastille_zfs_prefix}/releases/${TARGET}" + if [ "${FORCE}" = "1" ]; then + if [ -d "${bastille_cachedir}/${TARGET}" ]; then + zfs destroy "${OPTIONS}" "${bastille_zfs_zpool}/${bastille_zfs_prefix}/cache/${TARGET}" + fi fi fi fi