Skip to content

Instantly share code, notes, and snippets.

@pastleo
Created July 30, 2017 06:35
Show Gist options
  • Save pastleo/b49975022581a4b9e7a0a363cbbf01da to your computer and use it in GitHub Desktop.
Save pastleo/b49975022581a4b9e7a0a363cbbf01da to your computer and use it in GitHub Desktop.
google-drive-ocamlfuse mount and check script
#!/bin/bash
# Usage: path/to/this/script.sh [label]
# For crontab that checks every 10 minutes:
# */10 * * * * path/to/this/script.sh [label]
if [ -z "$1" ]; then
label="default"
else
label=$1
fi
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
mountpoint="$DIR/$label"
log_file="$DIR/$label.log"
check_file="$mountpoint/.gdfuse"
echo "[$label] gdfuse/mount.sh executed..." >> "$log_file"
date >> "$log_file"
if [ -f "$check_file" ]; then
echo "check file ok!" >> "$log_file"
else
echo "check file not found, remounting..." >> "$log_file"
fusermount -u $mountpoint &>> "$log_file"
sleep 1
google-drive-ocamlfuse -label $label $mountpoint -o allow_root &>> "$log_file" && \
sleep 1 && \
touch "$check_file"
echo "Done." >> "$log_file"
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment