encdir: Read password from stdin if dir.enc and dir exist.

This commit is contained in:
Ole Tange 2024-11-10 13:45:43 +01:00
parent 9890961c15
commit 8f7d700812
3 changed files with 32 additions and 12 deletions

View file

@ -10,14 +10,17 @@ encdir - mount encfs dir or create it if missing
=head1 SYNOPSIS
B<encdir> I<dir>
B<encdir> I<my_dir>
B<encdir> I<my_encdir> I<my_dir>
=head1 DESCRIPTION
B<encdir> uses B<encfs> to mount I<dir>.enc on I<dir>.
B<encdir> uses B<encfs> to mount I<my_encdir> on
I<my_dir>. I<my_encdir> defaults to I<my_dir>.enc
If I<dir> or I<dir>.enc do not exist then they will be created.
If I<my_dir> or I<my_encdir> do not exist then they will be created.
=head1 EXAMPLE
@ -27,7 +30,7 @@ Mount mydir.enc on mydir:
=head1 AUTHOR
Copyright (C) 2017-2020 Ole Tange,
Copyright (C) 2017-2024 Ole Tange,
http://ole.tange.dk and Free Software Foundation, Inc.
@ -61,15 +64,31 @@ B<encfs>
=cut
if [ -z "$2" ] ; then
fusermount -u $1 2>/dev/null
# --public only works if root. Ignored otherwise.
encfs --public `readlink -f "$1".enc` `readlink -f "$1"`
dir="$1"
encdir="$1".enc
else
fusermount -u `readlink -f $2` 2>/dev/null
# --public only works if root. Ignored otherwise.
encfs --public `readlink -f "$1"` `readlink -f "$2"`
dir="$2"
encdir="$1"
fi
dir=$(readlink -f "$dir")
encdir=$(readlink -f "$encdir")
fusermount -u "$dir" 2>/dev/null
if [ -d "$encdir" -a -d "$dir" ] ; then
read -sp "Enter password: " password
echo
echo "$password" |
# --public only works if root. Ignored otherwise.
encfs --stdinpass --public "$encdir" "$dir"
echo
else
# --public only works if root. Ignored otherwise.
encfs --public "$encdir" "$dir"
fi

View file

@ -4,6 +4,6 @@
# Content processes can normally be restored by clicking restore tab.
ps aux |
G firefox contentproc childID -v grep |
G firefox contentproc tab -v grep |
field 2 |
parallel -v --delay 1 -r kill

View file

@ -109,6 +109,7 @@ if(not -e $infile or $time !~ /\d\d:\d\d:\d\d.\d/) {
my @end = ("ffmpeg","-ss",$time,"-i","file:$infile","-c","copy","file:$end_file");
system(@end) == 0 or die(join" ",@end);
system("mv",$infile,$rmdir) == 0 or die;
print "OK\n";
}
sub destinationfilenames {