Skip to content

Instantly share code, notes, and snippets.

@bjodah
Created August 26, 2011 22:33
Show Gist options
  • Save bjodah/1174591 to your computer and use it in GitHub Desktop.
Save bjodah/1174591 to your computer and use it in GitHub Desktop.
Mounts an EncFS folder for sharing with other group members
#!/bin/bash
# BASH shell script for mounting an encrypted EncFS folder for
# for sharing with other user/users who are member of $GROUP
# Since EncFS runs in userland, no root privileges are needed.
# Remember to uncomment user_allow_other in /etc/fuse.conf
# It is currently configured to mount the encrypted folder:
# ~/.private
# on the unencrypted mount point (which is created upon mount):
# ~/private
# To the extent possible under law, Bjoern Dahlgren has waived all
# copyright and related or neighboring rights to this work.
USER=johndoe
GROUP=family
#FUSE does not seem to supprt SGID bit, elsewise an umask of 5007 would be nice
UMASK=007 # rwxrwx---
DIRNAME=private
uid=$(id -u $USER)
gid=$(getent group $GROUP | cut -d: -f 3)
#Allow UMASK of length 3 or 4
sevens=$(echo $UMASK | tr 01234567 77777777)
antiumask=$(echo "ibase=8; obase=8; $sevens - $UMASK" | bc)
if [ ! -d ./$DIRNAME ]
then
mkdir $DIRNAME
chmod $antiumask $DIRNAME
encfs -o allow_other -o umask=$UMASK,gid=$gid,uid=$uid ~/.$DIRNAME ~/$DIRNAME || rmdir $DIRNAME
else
echo The directory \"$DIRNAME\" already exists. Did nothing.
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment