Compare commits
No commits in common. "bec7f593faadb8c9352db9182b003b755a79b58d" and "7f54aba4afa760b1b7a12334ff3ecfe81ed6036c" have entirely different histories.
bec7f593fa
...
7f54aba4af
@ -30,12 +30,6 @@ 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
|
||||||
###############################################################################
|
###############################################################################
|
||||||
@ -88,29 +82,17 @@ for server in "${SERVERS[@]}"; do
|
|||||||
sudo mkdir -p "${MOUNT_POINT}"
|
sudo mkdir -p "${MOUNT_POINT}"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Check if the NFS share is mounted and accessible.
|
# Mount the NFS share if it's not already mounted.
|
||||||
if is_nfs_mounted "${MOUNT_POINT}"; then
|
if ! is_nfs_mounted "${MOUNT_POINT}"; then
|
||||||
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
|
|
||||||
echo "[ERROR] Remount failed, folder still not accessible."
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
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..."
|
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}"
|
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
|
if is_nfs_mounted "${MOUNT_POINT}"; then
|
||||||
echo "[SUCCESS] NFS share mounted successfully at ${MOUNT_POINT}."
|
echo "[SUCCESS] NFS share mounted successfully at ${MOUNT_POINT}."
|
||||||
else
|
else
|
||||||
echo "[ERROR] Failed to mount NFS share ${NFS_SHARE} at ${MOUNT_POINT} or folder not accessible!"
|
echo "[ERROR] Failed to mount NFS share ${NFS_SHARE} at ${MOUNT_POINT}!"
|
||||||
fi
|
fi
|
||||||
|
else
|
||||||
|
echo "[INFO] NFS share is already mounted at ${MOUNT_POINT}."
|
||||||
fi
|
fi
|
||||||
|
|
||||||
done
|
done
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user