Skip to content

Instantly share code, notes, and snippets.

@DrizzlyOwl
Created October 26, 2022 10:36
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 DrizzlyOwl/721fbe34e28055d863d402fd20e1b322 to your computer and use it in GitHub Desktop.
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.
#! /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