add remount
This commit is contained in:
parent
edf894a87b
commit
5fbdab6afa
@ -30,6 +30,12 @@ is_nfs_mounted() {
|
|||||||
mount | grep -q "${mount_point}"
|
mount | grep -q "${mount_point}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Check if the mount point directory is accessible (i.e. can be listed)
|
||||||
|
is_mount_accessible() {
|
||||||
|
local mount_point=$1
|
||||||
|
ls -1 "${mount_point}" >/dev/null 2>&1
|
||||||
|
}
|
||||||
|
|
||||||
###############################################################################
|
###############################################################################
|
||||||
# Main Loop: Process Each Server and Its Mount Points
|
# Main Loop: Process Each Server and Its Mount Points
|
||||||
###############################################################################
|
###############################################################################
|
||||||
@ -82,17 +88,29 @@ for server in "${SERVERS[@]}"; do
|
|||||||
sudo mkdir -p "${MOUNT_POINT}"
|
sudo mkdir -p "${MOUNT_POINT}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Mount the NFS share if it's not already mounted.
|
# Check if the NFS share is mounted and accessible.
|
||||||
if ! is_nfs_mounted "${MOUNT_POINT}"; then
|
|
||||||
echo "[INFO] NFS share is not mounted at ${MOUNT_POINT}. Attempting to mount..."
|
|
||||||
sudo mount -t nfs -o ro,port="${LOCAL_PORT}",nolock,soft,timeo=5,retrans=3 127.0.0.1:"${NFS_SHARE}" "${MOUNT_POINT}"
|
|
||||||
if is_nfs_mounted "${MOUNT_POINT}"; then
|
if is_nfs_mounted "${MOUNT_POINT}"; then
|
||||||
echo "[SUCCESS] NFS share mounted successfully at ${MOUNT_POINT}."
|
if ! is_mount_accessible "${MOUNT_POINT}"; then
|
||||||
|
echo "[WARNING] Mount point ${MOUNT_POINT} is not accessible. Attempting to remount..."
|
||||||
|
sudo umount "${MOUNT_POINT}"
|
||||||
|
sleep 2
|
||||||
|
sudo mount -t nfs -o ro,port="${LOCAL_PORT}",nolock,soft,timeo=5,retrans=3 127.0.0.1:"${NFS_SHARE}" "${MOUNT_POINT}"
|
||||||
|
if is_mount_accessible "${MOUNT_POINT}"; then
|
||||||
|
echo "[SUCCESS] Remounted successfully and folder is now accessible."
|
||||||
else
|
else
|
||||||
echo "[ERROR] Failed to mount NFS share ${NFS_SHARE} at ${MOUNT_POINT}!"
|
echo "[ERROR] Remount failed, folder still not accessible."
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "[INFO] NFS share is already mounted at ${MOUNT_POINT}."
|
echo "[INFO] NFS share is mounted and accessible at ${MOUNT_POINT}."
|
||||||
|
fi
|
||||||
|
else
|
||||||
|
echo "[INFO] NFS share is not mounted at ${MOUNT_POINT}. Attempting to mount..."
|
||||||
|
sudo mount -t nfs -o ro,port="${LOCAL_PORT}",nolock,soft,timeo=5,retrans=3 127.0.0.1:"${NFS_SHARE}" "${MOUNT_POINT}"
|
||||||
|
if is_mount_accessible "${MOUNT_POINT}"; then
|
||||||
|
echo "[SUCCESS] NFS share mounted successfully at ${MOUNT_POINT}."
|
||||||
|
else
|
||||||
|
echo "[ERROR] Failed to mount NFS share ${NFS_SHARE} at ${MOUNT_POINT} or folder not accessible!"
|
||||||
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user