Allow rename legacy jail directory even if zfs is explicitly configured

This commit is contained in:
Jose
2020-05-10 11:03:38 -04:00
parent 33588397ad
commit 9344b2f647

View File

@@ -102,9 +102,16 @@ change_name() {
if [ "${bastille_zfs_enable}" = "YES" ]; then
if [ -n "${bastille_zfs_zpool}" ]; then
# Rename ZFS dataset and mount points accordingly
zfs rename "${bastille_zfs_zpool}/${bastille_zfs_prefix}/jails/${TARGET}" "${bastille_zfs_zpool}/${bastille_zfs_prefix}/jails/${NEWNAME}"
if [ "$?" -ne 0 ]; then
error_notify "${COLOR_RED}Error: Can't rename zfs dataset.${COLOR_RESET}"
if zfs list | grep -qw "${bastille_zfs_prefix}/jails/${TARGET}$"; then
zfs rename "${bastille_zfs_zpool}/${bastille_zfs_prefix}/jails/${TARGET}" "${bastille_zfs_zpool}/${bastille_zfs_prefix}/jails/${NEWNAME}"
if [ "$?" -ne 0 ]; then
error_notify "${COLOR_RED}Error: Can't rename zfs dataset.${COLOR_RESET}"
fi
else
# Just rename the jail directory
if ! zfs list | grep -qw "jails/${TARGET}$"; then
mv "${bastille_jailsdir}/${TARGET}" "${bastille_jailsdir}/${NEWNAME}"
fi
fi
fi
else