Skip to content

Instantly share code, notes, and snippets.

@atomtigerzoo
Created July 11, 2018 09:01
Show Gist options
  • Save atomtigerzoo/8af351154ad62a8714fe52ce7a3f13c6 to your computer and use it in GitHub Desktop.
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
#!/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