Added bauerbill to pacman unlock routine
[mirrors/Programs.git] / bash / gencfs.bash
CommitLineData
84aff5c8
H
1#!/bin/bash
2#############################################################
3# gEncFS 0.2 (Harvie 2oo8-2oo9)        #
4# BASH & zenity GUI frontend for mounting EncFS filesystems #
5#############################################################
6
7zenity="/usr/bin/zenity";
8gksu="/usr/bin/gksu"; #path to gksu or gksudo (doesn't matter)
9encfs="/usr/bin/encfs";
10grep="/bin/grep";
11cut="/bin/cut"; #Arch: /bin/cut vs. Debian: /usr/bin/cut
12cat="/bin/cat";
13
14cut=$(which cut); #maybe bit insecure - for compatibility
15
16
17gencfs_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
24gencfs_fuses() {
25 echo -e "\n\nList of mouted FUSE filesystems:";
26 $cat /etc/mtab | $grep "^\(fuse\|encfs\) " | $cut -d ' ' -f 2;
27}
28
29gencfs_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
40gencfs_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
48gencfs_checkdir "$1";
49gencfs_checkdir "$2";
50
51$zenity --question --text "Do you want to (re)mount\n$1 to $2 ?$(gencfs_fuses;)" --title gEncFS
52if [ $? != 0 ]; then
53 exit;
54fi;
55
56fuseout=$(fusermount -u "$2" 2>&1)
57if [ $? == 0 ]; then
58 fuseout="";
59fi;
60
61false;
62while [ $? != 0 ]; do
63 gencfs_mount "$1" "$2" "$fuseout";
64done;
This page took 0.13008 seconds and 4 git commands to generate.