Skip to content

Instantly share code, notes, and snippets.

@schtobia
Last active Sep 28, 2018
Embed
What would you like to do?
EncFS on GDrive
#! /bin/bash
NAME=`basename $0`
BASEDIR="$XDG_RUNTIME_DIR/mount";
LOG_FILE=$(mktemp -p "${XDG_RUNTIME_DIR:-$TMPDIR}" "$NAME.XXXXXX")
[ ! -w "$LOG_FILE" ] && { echo "Logfile \"$LOG_FILE\" is not writeable." >&2; exit 1; }
trap "{ rm -f \"$LOG_FILE\"; exit $?; }" EXIT INT TERM HUP PIPE;
case $1 in
start)
mkdir -p $BASEDIR $BASEDIR/gdrive $BASEDIR/enc >"$LOG_FILE" 2>&1 && \
gdfs -o big_writes default $BASEDIR/gdrive >"$LOG_FILE" 2>&1 && \
encfs --extpass="cat $HOME/.keyfile" $BASEDIR/gdrive/enc $BASEDIR/enc >"$LOG_FILE" 2>&1;
ret_val=$?
;;
stop)
fusermount -u $BASEDIR/enc >"$LOG_FILE" 2>&1 && \
fusermount -u $BASEDIR/gdrive >"$LOG_FILE" 2>&1 && \
rmdir $BASEDIR/enc $BASEDIR/gdrive $BASEDIR >"$LOG_FILE" 2>&1;
ret_val=$?
;;
*)
echo "Usage: $NAME start|stop";
exit 1;
;;
esac
notify-send "$NAME" "`< $LOG_FILE`; return value: $ret_val"
exit $ret_val;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment