lazy unmount, use XDG_RUNTIME_DIR decrypt mount

This commit is contained in:
Jakobus Schürz 2020-11-28 16:12:37 +01:00
parent 888e5f6c20
commit 98ffb534d4

View file

@ -127,9 +127,12 @@ mencfs () {
return 2
fi
logdebug "ENCDIR: $ENCDIR"
[ -z ${PKEY+x} ] && { EXIT; return 3; }
[ -z ${ENCDIR+x} ] && { EXIT; return 4; }
[ -z "${DESTDIR+x}" ] && [ -n "${XDG_RUNTIME_DIR}" ] && DESTDIR="${XDG_RUNTIME_DIR}/decrypted/$(basename $ENCDIR| tr '[:lower:]' '[:upper:]'| sed -e 's/^\.//')"
[ -z ${DESTDIR+x} ] && DESTDIR="$(dirname $ENCDIR)/$(basename $ENCDIR| tr '[:lower:]' '[:upper:]'| sed -e 's/^\.//')"
logdebug "DESTDIR: $DESTDIR"
[ -d "$DESTDIR" ] || mkdir -p "$DESTDIR"
$PASS "${PKEY}" 1>/dev/null 2>&1 || { logerror "entry $PKEY does not exist in passwordsotre"; return 5; }
local ENCFS_PASSWORD=$($PASS "${PKEY}" | head -n1)
@ -165,14 +168,14 @@ uencfs () {
else
loginfo "umount encrypted directory" $1 >&2
sync
$FUSERMOUNT -u "$1"
$FUSERMOUNT -z -u "$1"
fi
else
loginfo "no arguments given. Umount all mounted encfs-dirs" >&2
for i in $(mount|grep encfs|sed -e 's/^encfs on \(.*\)\ type.*$/\1/');do
loginfo "$FUSERMOUNT -u $i"
sync
$FUSERMOUNT -u "$i"
$FUSERMOUNT -z -u "$i"
done
EXIT
return 1