From 9344b2f6472f557ece3727b91165acc341efe62b Mon Sep 17 00:00:00 2001 From: Jose Date: Sun, 10 May 2020 11:03:38 -0400 Subject: [PATCH] Allow rename legacy jail directory even if zfs is explicitly configured --- usr/local/share/bastille/rename.sh | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/usr/local/share/bastille/rename.sh b/usr/local/share/bastille/rename.sh index 7e8cad89..f5b3a304 100644 --- a/usr/local/share/bastille/rename.sh +++ b/usr/local/share/bastille/rename.sh @@ -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