#!/bin/bash # Ensures the NAS CIFS mount and the MSP360 bind-mount are both live. # MSP360's pre-flight check does `mountpoint ` on the exact configured # storage Path (/mnt/nas-backups/MSPBackups). Since that's a subdirectory of # the real CIFS mount (/mnt/nas-backups), it never registers as a mountpoint # on its own -- so we bind-mount it onto itself to make it one. set -u MOUNT=/mnt/nas-backups SUBDIR="$MOUNT/MSPBackups" LOG=/var/log/msp360-mount-ensure.log log() { echo "$(date '+%F %T') $1" >> "$LOG"; } if ! mountpoint -q "$MOUNT"; then log "CIFS mount down, remounting $MOUNT..." if mount "$MOUNT" 2>>"$LOG"; then log "CIFS remount OK" umount "$SUBDIR" 2>/dev/null || true else log "CIFS remount FAILED" exit 1 fi fi if ! mountpoint -q "$SUBDIR"; then log "Bind mount down, rebinding $SUBDIR..." mkdir -p "$SUBDIR" if mount --bind "$SUBDIR" "$SUBDIR" 2>>"$LOG"; then log "Bind mount OK" else log "Bind mount FAILED" exit 1 fi fi exit 0