Skip to content

Instantly share code, notes, and snippets.

@nerflad
Created August 27, 2017 08:54
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 nerflad/b1d70606c424f7d5f3db36a4a68e9c5c to your computer and use it in GitHub Desktop.
Save nerflad/b1d70606c424f7d5f3db36a4a68e9c5c to your computer and use it in GitHub Desktop.
#!/bin/sh
DRIVE_PATH=$(mount |grep google-drive-ocamlfuse |awk '{print $3}')
fn_usage () {
echo Usage:
echo $(basename $0) [PATH]
echo
echo If a Google Drive directory is mounted through google-drive-ocamlfuse,
echo unmount it. Otherwise, mount it at PATH.
}
fn_unmount () {
if [ -n "$DRIVE_PATH" ]; then
if [ -n "$1" ]; then
echo Detected Google Drive mounted at $DRIVE_PATH
echo Ignoring input paramaters...
fi
echo Unmounting $DRIVE_PATH...
sudo umount $DRIVE_PATH
else
echo Could not determine path of Google Drive directory.
echo Aborting...
exit 1
fi
}
fn_mount () {
DRIVE_PATH=$1
if [ -z "$DRIVE_PATH" ]; then
fn_usage
exit 1
elif ! [ -d $DRIVE_PATH ]; then
echo Could not mount $DRIVE_PATH: not a directory.
exit 1
else
google-drive-ocamlfuse $DRIVE_PATH && echo Mounted $DRIVE_PATH
fi
}
# main
[ -n "$DRIVE_PATH" ] && fn_unmount $1 || fn_mount $1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment