Recursively destroy base release to deal with previous snapshots

This commit is contained in:
Jose
2020-07-09 22:26:06 -04:00
parent 77274adb95
commit 428fd59925
+12 -4
View File
@@ -96,6 +96,8 @@ destroy_jail() {
} }
destroy_rel() { destroy_rel() {
local OPTIONS
## check release name match before destroy ## check release name match before destroy
if [ -n "${NAME_VERIFY}" ]; then if [ -n "${NAME_VERIFY}" ]; then
TARGET="${NAME_VERIFY}" TARGET="${NAME_VERIFY}"
@@ -125,10 +127,16 @@ destroy_rel() {
echo -e "${COLOR_GREEN}Deleting base: ${TARGET}.${COLOR_RESET}" echo -e "${COLOR_GREEN}Deleting base: ${TARGET}.${COLOR_RESET}"
if [ "${bastille_zfs_enable}" = "YES" ]; then if [ "${bastille_zfs_enable}" = "YES" ]; then
if [ -n "${bastille_zfs_zpool}" ]; then if [ -n "${bastille_zfs_zpool}" ]; then
zfs destroy "${bastille_zfs_zpool}/${bastille_zfs_prefix}/releases/${TARGET}" if [ -n "${TARGET}" ]; then
if [ "${FORCE}" = "1" ]; then OPTIONS="-r"
if [ -d "${bastille_cachedir}/${TARGET}" ]; then if [ "${FORCE}" = "1" ]; then
zfs destroy "${bastille_zfs_zpool}/${bastille_zfs_prefix}/cache/${TARGET}" 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 fi
fi fi