Created
October 26, 2022 10:36
-
-
Save DrizzlyOwl/721fbe34e28055d863d402fd20e1b322 to your computer and use it in GitHub Desktop.
Test whether a Cloudfuse mount is writable. If it isn't then re-mount it.
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 | |
# | |
# Author: Ash Davies | |
# Description: Checks a Cloudfuse mountpoint and reinitialises it if the mount goes missing | |
# | |
VOLUME="/path/to/content/uploads" | |
PROBE="$VOLUME/mounty.probe" | |
FOLDER="/path/to/cloudfuse/mount/" | |
DATETIME=$(date) | |
# Check if the mount point still exists | |
if [[ $(findmnt -M "$FOLDER") ]]; then | |
logger "[Mounty] $FOLDER is still mounted" | |
# Now check to see if it's writable | |
if [[ -w "$FOLDER" ]]; then | |
logger "[Mounty] $FOLDER is still writable"; | |
# Now see if the file exists | |
if [[ -f "$PROBE" ]]; then | |
logger "[Mounty] $PROBE is still locatable"; | |
else | |
logger "[Mounty] $PROBE cannot be found"; | |
logger "[Mounty] $FOLDER is not mounted! Attemping to remount" | |
umount /path/to/cloudfuse/mount/ | |
mount -a | |
echo "[Mounty] The volume '$FOLDER' had to be remounted at $DATETIME" | mail -s "[Mounty] Cloudfuse mount problem detected" myemail@domain | |
fi | |
else | |
logger "[Mounty] $FOLDER is no longer writable"; | |
logger "[Mounty] $FOLDER is not mounted! Attemping to remount" | |
umount /path/to/cloudfuse/mount/ | |
mount -a | |
echo "[Mounty] The volume '$FOLDER' had to be remounted at $DATETIME" | mail -s "[Mounty] Cloudfuse mount problem detected" myemail@domain | |
fi | |
else | |
logger "[Mounty] $FOLDER is not mounted! Attemping to remount" | |
umount /path/to/cloudfuse/mount/ | |
mount -a | |
echo "[Mounty] The volume '$FOLDER' had to be remounted at $DATETIME" | mail -s "[Mounty] Cloudfuse mount problem detected" myemail@domain | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment