From: Harvie Date: Wed, 1 Jun 2011 00:55:37 +0000 (+0200) Subject: Moved gencfs.bash, Added some EncFS USB automouting scripts X-Git-Url: https://git.harvie.cz/?a=commitdiff_plain;h=7a01525be987d24f26d7fccb05873cb88ddf5cdb;p=mirrors%2FPrograms.git Moved gencfs.bash, Added some EncFS USB automouting scripts --- diff --git a/bash/encfs/automount/README b/bash/encfs/automount/README new file mode 100644 index 0000000..35dfa11 --- /dev/null +++ b/bash/encfs/automount/README @@ -0,0 +1 @@ +More info can be probably found here: https://wiki.archlinux.org/index.php/EncFS diff --git a/bash/encfs/automount/config b/bash/encfs/automount/config new file mode 100644 index 0000000..f1935e8 --- /dev/null +++ b/bash/encfs/automount/config @@ -0,0 +1,11 @@ +# ~/.config/fsniper/config +# You can get fsniper at http://code.l3ib.org/?p=fsniper.git + +watch { + /etc/ { + mtab { + # %% is replaced with the filename of the new file + handler = encfs-automount.sh %%; + } + } +} diff --git a/bash/encfs/automount/encfs-automount.sh b/bash/encfs/automount/encfs-automount.sh new file mode 100755 index 0000000..8191f2d --- /dev/null +++ b/bash/encfs/automount/encfs-automount.sh @@ -0,0 +1,44 @@ +#!/bin/sh +# ~/.config/fsniper/scripts/encfs-automount.sh +# Quick & dirty script for automounting EncFS USB drives +# TODO: +# - Unmounting!!! +# +ASKPASS="/usr/lib/git-core/git-gui--askpass" + +lock=/tmp/fsniper_encfs.lock +lpid=$(cat "$lock" 2>/dev/null) && +ps "$lpid" | grep "$lpid" >/dev/null && { + echo "Another instance of fsniper_encfs is running" + exit; +} +echo $BASHPID > "$lock"; +sleep 2; + +echo +echo ==== EncFS automount script for fsniper ==== + +list_mounts() { + cat /proc/mounts | cut -d ' ' -f 2 +} + +list_mounts | while read mount; do + config="$mount"'/*/.encfs*'; + echo Looking for "$config" + config="$(echo $config)" + [ -r "$config" ] && { + cyphertext="$(dirname "$config")"; + plaintext="$cyphertext".plain + echo Found config: "$config"; + echo Trying to mount: "$cyphertext to $plaintext"; + list_mounts | grep "$plaintext" >/dev/null && { + echo Already mounted: "$plaintext" + } || { + echo WOOHOO Will mount "$cyphertext to $plaintext" + "$ASKPASS" "EncFS $cyphertext to $plaintext" | encfs --stdinpass "$cyphertext" "$plaintext" + } + } +done +echo + +rm "$lock" 2>/dev/null diff --git a/bash/gencfs.bash b/bash/encfs/gencfs.bash similarity index 100% rename from bash/gencfs.bash rename to bash/encfs/gencfs.bash