mirror of
https://github.com/hackacad/bastille.git
synced 2026-01-05 20:24:09 +01:00
destroy: error_exit > error_continue
This commit is contained in:
@@ -52,8 +52,8 @@ destroy_jail() {
|
|||||||
|
|
||||||
for _jail in ${JAILS}; do
|
for _jail in ${JAILS}; do
|
||||||
|
|
||||||
bastille_jail_base="${bastille_jailsdir}/${_jail}" ## dir
|
bastille_jail_base="${bastille_jailsdir}/${_jail}"
|
||||||
bastille_jail_log="${bastille_logsdir}/${_jail}_console.log" ## file
|
bastille_jail_log="${bastille_logsdir}/${_jail}_console.log"
|
||||||
|
|
||||||
check_target_is_stopped "${_jail}" || if [ "${AUTO}" -eq 1 ]; then
|
check_target_is_stopped "${_jail}" || if [ "${AUTO}" -eq 1 ]; then
|
||||||
bastille stop "${_jail}"
|
bastille stop "${_jail}"
|
||||||
@@ -63,7 +63,7 @@ destroy_jail() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -d "${bastille_jail_base}" ]; then
|
if [ -d "${bastille_jail_base}" ]; then
|
||||||
## make sure no filesystem is currently mounted in the jail directory
|
# Make sure no filesystem is currently mounted
|
||||||
mount_points="$(mount | cut -d ' ' -f 3 | grep ${bastille_jail_base}/root/)"
|
mount_points="$(mount | cut -d ' ' -f 3 | grep ${bastille_jail_base}/root/)"
|
||||||
if [ -n "${mount_points}" ]; then
|
if [ -n "${mount_points}" ]; then
|
||||||
error_notify "Failed to destroy jail: ${_jail}"
|
error_notify "Failed to destroy jail: ${_jail}"
|
||||||
@@ -81,28 +81,28 @@ destroy_jail() {
|
|||||||
# This will deal with the common "cannot unmount 'XYZ': pool or dataset is busy"
|
# 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.
|
# 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
|
if ! zfs destroy "${OPTIONS}" "${bastille_zfs_zpool}/${bastille_zfs_prefix}/jails/${_jail}"; then
|
||||||
error_exit "Jail dataset(s) appears to be busy, exiting."
|
error_continue "[ERROR]: Jail dataset(s) appears to be busy, exiting."
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -d "${bastille_jail_base}" ]; then
|
if [ -d "${bastille_jail_base}" ]; then
|
||||||
## removing all flags
|
# Remove flags
|
||||||
chflags -R noschg "${bastille_jail_base}"
|
chflags -R noschg "${bastille_jail_base}"
|
||||||
|
|
||||||
## remove jail base
|
# Remove jail base
|
||||||
rm -rf "${bastille_jail_base}"
|
rm -rf "${bastille_jail_base}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## archive jail log
|
# Archive jail log
|
||||||
if [ -f "${bastille_jail_log}" ]; then
|
if [ -f "${bastille_jail_log}" ]; then
|
||||||
mv "${bastille_jail_log}" "${bastille_jail_log}"-"$(date +%F)"
|
mv "${bastille_jail_log}" "${bastille_jail_log}"-"$(date +%F)"
|
||||||
info "Note: jail console logs archived."
|
info "Note: jail console logs archived."
|
||||||
info "${bastille_jail_log}-$(date +%F)"
|
info "${bastille_jail_log}-$(date +%F)"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
## clear any active rdr rules
|
# Clear any active rdr rules
|
||||||
if [ ! -z "$(pfctl -a "rdr/${_jail}" -Psn 2>/dev/null)" ]; then
|
if [ ! -z "$(pfctl -a "rdr/${_jail}" -Psn 2>/dev/null)" ]; then
|
||||||
info "Clearing RDR rules:"
|
info "Clearing RDR rules:"
|
||||||
pfctl -a "rdr/${_jail}" -Fn
|
pfctl -a "rdr/${_jail}" -Fn
|
||||||
|
|||||||
Reference in New Issue
Block a user