From c0ce8b3a119084f2643f79fae5191dcb462e02db Mon Sep 17 00:00:00 2001 From: MickLesk Date: Sat, 15 Aug 2026 23:22:59 +0200 Subject: [PATCH] Skip mount points during backup and clean install Prevent accidental deletion or backup of mount points: - In create_backup(), skip paths that are mount points with a warning - In _deploy_source_tarball(), _deploy_unpacked_archive(), and fetch_and_deploy_from_url(), use find with mountpoint pruning to avoid deleting mount point directories during CLEAN_INSTALL --- misc/tools.func | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/misc/tools.func b/misc/tools.func index e16a37ad3..5394a78a0 100644 --- a/misc/tools.func +++ b/misc/tools.func @@ -1336,6 +1336,10 @@ create_backup() { msg_warn "Skipping backup of '${path}' (not found)" continue fi + if mountpoint -q "$path" 2>/dev/null; then + msg_warn "Skipping backup of '${path}' (is a mount point)" + continue + fi dest="${store}/files${path}" if ! mkdir -p "$(dirname "$dest")" || ! cp -a "$path" "$dest"; then msg_error "Backup of '${path}' failed - aborting update" @@ -2538,7 +2542,7 @@ _deploy_source_tarball() { mkdir -p "$target" if [[ "${CLEAN_INSTALL:-0}" == "1" ]]; then - find "${target:?}" -mindepth 1 -delete + find "${target:?}" -mindepth 1 \( -type d -exec mountpoint -q {} \; -prune \) -o -delete fi tar --no-same-owner -xzf "$tarball" -C "$workdir" || { @@ -2627,7 +2631,7 @@ _deploy_unpacked_archive() { # was truncated, the archive was unreadable, or it unpacked to nothing. mkdir -p "$target" if [[ "${CLEAN_INSTALL:-0}" == "1" ]]; then - find "${target:?}" -mindepth 1 -delete + find "${target:?}" -mindepth 1 \( -type d -exec mountpoint -q {} \; -prune \) -o -delete fi if ! cp -r "$source_dir"/* "$target/"; then @@ -9368,7 +9372,7 @@ fetch_and_deploy_from_url() { mkdir -p "$directory" if [[ "${CLEAN_INSTALL:-0}" == "1" ]]; then - find "${directory:?}" -mindepth 1 -delete + find "${directory:?}" -mindepth 1 \( -type d -exec mountpoint -q {} \; -prune \) -o -delete fi local unpack_tmp