Skip to content

Instantly share code, notes, and snippets.

@alexalouit
Last active February 19, 2018 10:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save alexalouit/1620c5c555717d5bda4f to your computer and use it in GitHub Desktop.
Save alexalouit/1620c5c555717d5bda4f to your computer and use it in GitHub Desktop.
mountpoint checker/alert/remounter
#!/bin/sh
#
# cron ex: * * * * * /usr/bin/nice -n 19 /usr/bin/ionice -c2 -n7 /root/scripts/check-mountpoint.sh >> /root/scripts/cron.log
# mountpoint must be present in fstab
mountpoint=" /mnt/endpoint" # use space before (prevent mountpoint as source)
email=""
if [ -z "$(grep $mountpoint /proc/mounts)" ]; then
# we use space before, prevent mountpoint as source
echo "$mountpoint not present"
unmount $mountpoint
mount $mountpoint
echo -e "Erreur du point de montage $(mountpoint) sur le serveur:\n $(hostname)" | mail -s "Rapport d'erreur point de montage" $email
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment