Pthread pause
[mirrors/Programs.git] / bash / encfs / automount / encfs-automount.sh
CommitLineData
7a01525b
H
1#!/bin/sh
2# ~/.config/fsniper/scripts/encfs-automount.sh
3# Quick & dirty script for automounting EncFS USB drives
4# TODO:
5# - Unmounting!!!
6#
7ASKPASS="/usr/lib/git-core/git-gui--askpass"
8
9lock=/tmp/fsniper_encfs.lock
10lpid=$(cat "$lock" 2>/dev/null) &&
11ps "$lpid" | grep "$lpid" >/dev/null && {
12 echo "Another instance of fsniper_encfs is running"
13 exit;
14}
15echo $BASHPID > "$lock";
16sleep 2;
17
18echo
19echo ==== EncFS automount script for fsniper ====
20
21list_mounts() {
22 cat /proc/mounts | cut -d ' ' -f 2
23}
24
25list_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 }
41done
42echo
43
44rm "$lock" 2>/dev/null
This page took 0.231547 seconds and 4 git commands to generate.