Moved gencfs.bash, Added some EncFS USB automouting scripts
[mirrors/Programs.git] / bash / encfs / automount / encfs-automount.sh
1 #!/bin/sh
2 # ~/.config/fsniper/scripts/encfs-automount.sh
3 # Quick & dirty script for automounting EncFS USB drives
4 # TODO:
5 # - Unmounting!!!
6 #
7 ASKPASS="/usr/lib/git-core/git-gui--askpass"
8
9 lock=/tmp/fsniper_encfs.lock
10 lpid=$(cat "$lock" 2>/dev/null) &&
11 ps "$lpid" | grep "$lpid" >/dev/null && {
12 echo "Another instance of fsniper_encfs is running"
13 exit;
14 }
15 echo $BASHPID > "$lock";
16 sleep 2;
17
18 echo
19 echo ==== EncFS automount script for fsniper ====
20
21 list_mounts() {
22 cat /proc/mounts | cut -d ' ' -f 2
23 }
24
25 list_mounts | while read mount; do
26 config="$mount"'/*/.encfs*';
27 echo Looking for "$config"
28 config="$(echo $config)"
29 [ -r "$config" ] && {
30 cyphertext="$(dirname "$config")";
31 plaintext="$cyphertext".plain
32 echo Found config: "$config";
33 echo Trying to mount: "$cyphertext to $plaintext";
34 list_mounts | grep "$plaintext" >/dev/null && {
35 echo Already mounted: "$plaintext"
36 } || {
37 echo WOOHOO Will mount "$cyphertext to $plaintext"
38 "$ASKPASS" "EncFS $cyphertext to $plaintext" | encfs --stdinpass "$cyphertext" "$plaintext"
39 }
40 }
41 done
42 echo
43
44 rm "$lock" 2>/dev/null
This page took 0.25875 seconds and 4 git commands to generate.