Commit | Line | Data |
---|---|---|
84aff5c8 H |
1 | #!/bin/bash |
2 | ############################################################# | |
3 | # gEncFS 0.2 (Harvie 2oo8-2oo9) # | |
4 | # BASH & zenity GUI frontend for mounting EncFS filesystems # | |
5 | ############################################################# | |
6 | ||
7 | zenity="/usr/bin/zenity"; | |
8 | gksu="/usr/bin/gksu"; #path to gksu or gksudo (doesn't matter) | |
9 | encfs="/usr/bin/encfs"; | |
10 | grep="/bin/grep"; | |
11 | cut="/bin/cut"; #Arch: /bin/cut vs. Debian: /usr/bin/cut | |
12 | cat="/bin/cat"; | |
13 | ||
14 | cut=$(which cut); #maybe bit insecure - for compatibility | |
15 | ||
16 | ||
17 | gencfs_getpass() { | |
18 | #zenity - insecure way | |
19 | #$zenity --entry --hide-text --text "$(echo -ne "Please enter EncFS password for $1\n$2")" --title "gEncFS: Password for $1" 2>/dev/null; | |
20 | #gksu/gksudo - secure way (grabs keyboard!) | |
21 | gksu -p -m "$(echo -ne "Please enter EncFS password for $1\n$2")" 2>/dev/null; | |
22 | } | |
23 | ||
24 | gencfs_fuses() { | |
25 | echo -e "\n\nList of mouted FUSE filesystems:"; | |
26 | $cat /etc/mtab | $grep "^\(fuse\|encfs\) " | $cut -d ' ' -f 2; | |
27 | } | |
28 | ||
29 | gencfs_mount() { | |
30 | errout=$(gencfs_getpass "$1" "$3" | $encfs "--extpass=$cat" "$1" "$2") | |
31 | if [ $? != 0 ]; then | |
32 | $zenity --question --text "$errout\n\nTry again?" --title "gEncFS: Try again?"; | |
33 | if [ $? == 0 ]; then | |
34 | return 1; | |
35 | fi; | |
36 | fi; | |
37 | return 0; | |
38 | } | |
39 | ||
40 | gencfs_checkdir() { | |
41 | if [ -d "$1" ]; then echo -n; else | |
42 | $zenity --error --title "gEncFS: Error!" --text\ | |
43 | "Directory $1 doesn't exist.\nYou have to create it manualy by encfs command:\n\nencfs [options] rootDir mountPoint [-- [FUSE Mount Options]]"; | |
44 | exit; | |
45 | fi; | |
46 | } | |
47 | ||
48 | gencfs_checkdir "$1"; | |
49 | gencfs_checkdir "$2"; | |
50 | ||
51 | $zenity --question --text "Do you want to (re)mount\n$1 to $2 ?$(gencfs_fuses;)" --title gEncFS | |
52 | if [ $? != 0 ]; then | |
53 | exit; | |
54 | fi; | |
55 | ||
56 | fuseout=$(fusermount -u "$2" 2>&1) | |
57 | if [ $? == 0 ]; then | |
58 | fuseout=""; | |
59 | fi; | |
60 | ||
61 | false; | |
62 | while [ $? != 0 ]; do | |
63 | gencfs_mount "$1" "$2" "$fuseout"; | |
64 | done; |