Skip to content

Instantly share code, notes, and snippets.

@jpgrace
Forked from icheko/check-s3fs-mount.sh
Created April 5, 2017 18:33
Show Gist options
  • Save jpgrace/8d5823fc10c487f53748c003390fe020 to your computer and use it in GitHub Desktop.
Save jpgrace/8d5823fc10c487f53748c003390fe020 to your computer and use it in GitHub Desktop.
Check if S3FS mount is not connected and attempt to reconnect Usage: ./checkNFSMount.sh /mount/point
#!/bin/sh
MNT_PATH=$1
if [ -z "$MNT_PATH" ]
then
echo "MNT_PATH is not set"
exit
fi
DF_OUTPUT=$((df -h | grep $MNT_PATH) 2>&1)
if [[ "$DF_OUTPUT" != *"endpoint is not connected"* ]]
then
exit;
fi
echo "NFS is unmounted"
echo "================"
echo "lazy unmounting $1..."
# lazy unmount
umount -l $1
echo "sleep...15"
# wait
sleep 15
echo "mount fstab"
# mount
mount -a
echo "done!"
echo "================"
df -h
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment