Skip to content

Instantly share code, notes, and snippets.

@hazcod
Last active March 21, 2019 15:59
Show Gist options
  • Save hazcod/fd2efccb9c26f24f35d2 to your computer and use it in GitHub Desktop.
Save hazcod/fd2efccb9c26f24f35d2 to your computer and use it in GitHub Desktop.
#!/bin/bash
export ENCFS6_CONFIG="/home/media/data/.encfs.xml"
crypt_mount="/tmp/.media"
uncrypt_mount="/tmp/media"
uploadcrypt="/home/media/data/uploading"
upload="/home/media/data/uploadme"
user="media"
group="media"
read -s -p "password: " pwd
mkdir -p "$crypt_mount"
mkdir -p "$uncrypt_mount"
chmod 740 "$uncrypt_mount"
uid=$(id -u "$user")
gid=$(getent group "$group" | cut -d: -f 3)
if acdcli mount "$crypt_mount" --ro --allow-root; then
if echo "$pwd" | encfs -S -o umask=0740,uid="$uid",gid="$gid" "$crypt_mount" "$uncrypt_mount"; then
if echo "$pwd" | encfs -S "$uploadcrypt" "$upload"; then
echo "done"
exit 0
else
echo "Failed to setup local encfs"
exit 1
fi
else
echo "Failed setting up media mount"
exit 1
fi
unset pwd
else
exit 1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment