Created
July 11, 2018 09:01
-
-
Save atomtigerzoo/8af351154ad62a8714fe52ce7a3f13c6 to your computer and use it in GitHub Desktop.
Simple bash script to check if a mount point has been mounted, and if not, re-mount it or notify someone via email
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
MOUNTPOINT="/some/mount-point" | |
EMAIL="[email protected]" | |
if cat /proc/mounts | grep ${MOUNTPOINT} > /dev/null; then | |
echo "${MOUNTPOINT} already mounted." | |
exit 0 | |
fi | |
# If above did not exit | |
mount ${MOUNTPOINT} | |
if [ $? -eq 0 ]; then | |
echo "${MOUNTPOINT} has been mounted." | |
else | |
# Mounting failed, send email | |
echo "Mounting of ${MOUNTPOINT} failed." | mail -s "[server notification] Mount fail" $EMAIL | |
fi | |
exit |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment