From 18a4c6f3c76afc394138f29a673241429f4446b8 Mon Sep 17 00:00:00 2001 From: FailedProxy Date: Wed, 29 Apr 2026 20:44:11 -0400 Subject: [PATCH] updated disk checking logic in rsync on remote check --- common.sh | 62 ++++++++++++++++++++++++++++++++++++++----------------- 1 file changed, 43 insertions(+), 19 deletions(-) diff --git a/common.sh b/common.sh index 2865239..c11c238 100644 --- a/common.sh +++ b/common.sh @@ -643,30 +643,57 @@ check_remote_disks() { exit 1 fi - # Find which disk(s) back this share on remote + # Find which disk(s) back this share on remote — check full path first + # Share may be nested (e.g. /mnt/user/appdata-Failover/Critical-Data lives at + # /mnt/cache/appdata-Failover/Critical-Data on the remote cache pool) local backing_disks backing_disks=$(ssh -i "$SSH_KEY" root@"$REMOTE_SERVER" \ "ls -d /mnt/disk*/$share_name 2>/dev/null | awk -F/ '{print \$3}'" 2>/dev/null) - # Also check ZFS standalone pools (cache, gaming, media-servers etc.) + # Check ZFS standalone pools for the share — by basename AND nested path local zfs_pool_paths zfs_pool_paths=$(ssh -i "$SSH_KEY" root@"$REMOTE_SERVER" \ "zpool list -H -o name 2>/dev/null | while read pool; do - [[ -d \"/mnt/\${pool}/$share_name\" ]] && echo \"\$pool\" - done" 2>/dev/null) + # Check direct: /mnt/pool/sharename + [[ -d \"/mnt/\${pool}/$share_name\" ]] && echo \"\$pool\" && continue + # Check nested: /mnt/pool/**/sharename (one level deep) + find \"/mnt/\${pool}\" -maxdepth 2 -name '$share_name' -type d 2>/dev/null | \ + grep -q . && echo \"\$pool\" + done | sort -u" 2>/dev/null) + + # Also check unRAID shfs — share exists under /mnt/user which is the union filesystem + # If the path exists under /mnt/user on remote it's accessible regardless of backing disk + if [[ -z "$backing_disks" ]] && [[ -z "$zfs_pool_paths" ]]; then + local on_user + on_user=$(ssh -i "$SSH_KEY" root@"$REMOTE_SERVER" \ + "find /mnt/user -maxdepth 3 -name '$share_name' -type d 2>/dev/null | head -1" \ + 2>/dev/null) + if [[ -n "$on_user" ]]; then + # Share exists on remote shfs — find which pool backs it + local actual_path + actual_path=$(ssh -i "$SSH_KEY" root@"$REMOTE_SERVER" \ + "readlink -f '$on_user' 2>/dev/null || echo '$on_user'" 2>/dev/null) + local pool_name + pool_name=$(echo "$actual_path" | awk -F/ '{print $3}') + if [[ -n "$pool_name" ]] && [[ "$pool_name" != "user" ]]; then + zfs_pool_paths="$pool_name" + info "$ICON_DISK $share_name found at $actual_path on $REMOTE_SERVER_NAME" + else + # Accessible via shfs — verify shfs is mounted + local shfs_ok + shfs_ok=$(ssh -i "$SSH_KEY" root@"$REMOTE_SERVER" \ + "mountpoint -q /mnt/user && echo yes || echo no" 2>/dev/null) + if [[ "$shfs_ok" == "yes" ]]; then + success "All disks backing $share_name are online ✅ (via shfs)" + return 0 + fi + fi + fi + fi if [[ -z "$backing_disks" ]] && [[ -z "$zfs_pool_paths" ]]; then - # Check cache pool directly - local on_cache - on_cache=$(ssh -i "$SSH_KEY" root@"$REMOTE_SERVER" \ - "[[ -d '/mnt/cache/$share_name' ]] && echo yes" 2>/dev/null) - if [[ "$on_cache" == "yes" ]]; then - backing_disks="" - zfs_pool_paths="cache" - else - error "$ICON_DISK No disks found backing $share_name on $REMOTE_SERVER_NAME" - exit 1 - fi + error "$ICON_DISK No disks found backing $share_name on $REMOTE_SERVER_NAME" + exit 1 fi local all_ok=true @@ -676,7 +703,6 @@ check_remote_disks() { while IFS= read -r disk_name; do [[ -z "$disk_name" ]] && continue - # Get fsType for this disk from disks.ini local fs_type fs_type=$(echo "$disks_ini_content" | awk -F= -v disk="$disk_name" ' /^\["'"'"'?/ { current=substr($0,3,length($0)-4) } @@ -685,7 +711,6 @@ check_remote_disks() { fs_type="${fs_type:-xfs}" if [[ "$fs_type" == "zfs" ]]; then - # ZFS single disk in array — check zpool status local pool_health pool_health=$(ssh -i "$SSH_KEY" root@"$REMOTE_SERVER" \ "zpool list -H -o health '$disk_name' 2>/dev/null" 2>/dev/null) @@ -696,7 +721,6 @@ check_remote_disks() { all_ok=false fi else - # XFS — check mountpoint local mounted mounted=$(ssh -i "$SSH_KEY" root@"$REMOTE_SERVER" \ "mountpoint -q '/mnt/$disk_name' && echo yes || echo no" 2>/dev/null) @@ -710,7 +734,7 @@ check_remote_disks() { done <<< "$backing_disks" fi - # Check ZFS standalone pools + # Check ZFS standalone pools (cache, gaming, media-servers etc.) if [[ -n "$zfs_pool_paths" ]]; then while IFS= read -r pool_name; do [[ -z "$pool_name" ]] && continue