From 1eb25c24907bcdcc9db591880a48bdecf9babbc4 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Thu, 16 Dec 2021 10:51:14 +0100 Subject: [PATCH] system: do not clobber mount points In case of ZFS a move doesn't really work. Remove links only and move the directory contents over. --- src/etc/rc.subr.d/var | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/src/etc/rc.subr.d/var b/src/etc/rc.subr.d/var index 3d1525cb5..21ffc6c9c 100755 --- a/src/etc/rc.subr.d/var +++ b/src/etc/rc.subr.d/var @@ -64,22 +64,26 @@ install_mfs_link() remove_mfs_link() { ROOT=${ROOTDIR} - MFS=$(dirname ${1}) - NAME=$(basename ${1}) + MFS=${1} # Persistent copies of MFS-bound directories # still there must be moved back into place. - if [ -d "${ROOT}${MFS}/${NAME}" ]; then + if [ -d "${ROOT}${MFS}" ]; then + if [ -L "${MFS}" ]; then + # reverse the recovery symlink before + # moving back the original database + rm "${MFS}" + fi mkdir -p "${MFS}" - # reverse the recovery symlink before - # moving back the original database - rm -f "${MFS}/${NAME}" - mv "${ROOT}${MFS}/${NAME}" "${MFS}/" + for DIR in $(find "${ROOT}${MFS}" -depth 1); do + mv "${DIR}" "${MFS}/" + done + rm -r "${ROOT}${MFS}" fi # ensure directory always exist - mkdir -p "${MFS}/${NAME}" + mkdir -p "${MFS}" } # check which directories we need