Skip to content

Instantly share code, notes, and snippets.

@gourytch
Last active March 12, 2016 11:51
Show Gist options
  • Save gourytch/89501540178f8cf2eb1e to your computer and use it in GitHub Desktop.
Save gourytch/89501540178f8cf2eb1e to your computer and use it in GitHub Desktop.
#! /bin/bash
master_container="$HOME/Dropbox/.safe"
master_mountpoint="$HOME/safe"
keyfile="$HOME/.keys/encfs-safe"
mount_master() {
echo "* mounting master cryptocontainer..."
if [ ! -d "$master_container" ]
then
echo "! master cryptocontainer not found"
exit 1
fi
if [ ! -d "$master_mountpoint" ]
then
echo "! master mountpoint not found"
exit 1
fi
if encfs --extpass="cat $keyfile" $master_container $master_mountpoint
then
echo "* cryptocontainer mounted"
else
echo "! cryptocontainer mount error"
exit 1
fi
}
umount_master() {
echo "* unmounting master cryptocontainer..."
sync
fusermount -u $master_mountpoint
echo "* cryptocontainer unmounted."
}
case $(basename $0) in
"safe_mount")
mount_master
;;
"safe_umount")
umount_master
;;
*)
echo "must be named as safe_mount or safe_umount" 1>&2
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment