Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Simple bash script to check if a mount point has been mounted, and if not, re-mount it or notify someone via email
#!/bin/bash
MOUNTPOINT="/some/mount-point"
EMAIL="root@your-domain.example.com"
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
You can’t perform that action at this time.