Don't delete jail content on error, cleanup

Don't delete jail content on busy datasets by default, cleanup.
This commit is contained in:
JRGTH
2025-04-09 19:51:54 -04:00
parent 904f8557c2
commit a71d55b15e

View File

@@ -77,8 +77,12 @@ destroy_jail() {
if [ "${FORCE}" = "1" ]; then
OPTIONS="-rf"
fi
## remove jail zfs dataset recursively
zfs destroy "${OPTIONS}" "${bastille_zfs_zpool}/${bastille_zfs_prefix}/jails/${_jail}"
# Remove jail zfs dataset recursively, or abort if error thus precerving jail content.
# This will deal with the common "cannot unmount 'XYZ': pool or dataset is busy"
# unless the force option is defined by the user, otherwise will have a partially deleted jail.
if ! zfs destroy "${OPTIONS}" "${bastille_zfs_zpool}/${bastille_zfs_prefix}/jails/${_jail}"; then
error_exit "Jail dataset(s) appears to be busy, exiting."
fi
fi
fi
fi
@@ -198,9 +202,9 @@ destroy_rel() {
}
# Handle options.
AUTO=0
FORCE=0
NO_CACHE=0
AUTO="0"
FORCE="0"
NO_CACHE="0"
while [ "$#" -gt 0 ]; do
case "${1}" in
-h|--help|help)