#!/bin/sh # # Author: Martti Kuparinen # # $Id: secdir,v 1.2 2008-05-06 09:12:15 martti Exp $ # SRC="${HOME}/.private" DST="${HOME}/private" OPT_I="60" usage() { cat << EOF Usage: `basename $0` [-gh] [-i minutes] {-d | -e} -d Disable -e Enable -g Show a detailed setup guide -h This help -i n Stop after n minutes of idle time (default: 60) -l List current mounts EOF } guide() { cat << EOF How to create a new encrypted directory with EncFS ################################################## Install the required software ----------------------------- sudo aptitude install encfs fuse-utils sudo modprobe fuse sudo adduser \${USER} fuse Create the directories ---------------------- mkdir -p ~/.private ~/private chmod 700 ~/.private ~/private Start decryption ---------------- secdir -e cd ~/private Stop decryption ---------------- secdir -d EOF } list() { mount | grep ^encfs | awk '{ print $3 }' | while read i do df -h $i done } start() { # $1 = idle if [ ! -z "`mount | grep ^encfs | awk '{ print $3 }' | grep ${DST}`" ] then echo "${DST} is already mounted." exit 1 fi if [ -z "`lsmod | grep fuse`" ]; then echo "Loading the fuse kernel module" sudo modprobe fuse fi echo "Starting directory encryption" sudo encfs --idle=${1} --public ${SRC} ${DST} list } stop() { sudo fusermount -u ${DST} } ARGV=`getopt deghi:lu${*}` if [ ${?} != 0 ]; then usage fi OPT_D= OPT_E= for i; do case "${i}" in -d) OPT_D=YES shift ;; -e) OPT_E=YES shift ;; -g) guide exit ;; -h) usage exit ;; -i) OPT_I=${2} shift 2 ;; -l) list exit ;; --) shift ;; esac done if [ ! -z "${OPT_D}" ]; then stop exit fi if [ ! -z "${OPT_E}" ]; then start ${OPT_I} exit fi usage