Add option to list encrypted files

This commit is contained in:
Tim Byrne 2015-07-16 20:57:53 -05:00
parent 5a44ef25ca
commit d1fe16407d
3 changed files with 62 additions and 47 deletions

16
yadm
View File

@ -65,6 +65,9 @@ function main() {
-f) #; used by init() and clone() -f) #; used by init() and clone()
FORCE="YES" FORCE="YES"
;; ;;
-l) #; used by decrypt()
DO_LIST="YES"
;;
-w) #; used by init() and clone() -w) #; used by init() and clone()
if [[ ! "$2" =~ ^/ ]] ; then if [[ ! "$2" =~ ^/ ]] ; then
error_out "You must specify a fully qualified work tree" error_out "You must specify a fully qualified work tree"
@ -194,10 +197,16 @@ function decrypt() {
YADM_WORK=$(git config core.worktree) YADM_WORK=$(git config core.worktree)
if [ "$DO_LIST" == "YES" ] ; then
tar_option="t"
else
tar_option="x"
fi
#; decrypt the archive #; decrypt the archive
(gpg -d "$YADM_ARCHIVE" || echo 1) | tar xv -C "$YADM_WORK" (gpg -d "$YADM_ARCHIVE" || echo 1) | tar v$tar_option -C "$YADM_WORK"
if [ $? = 0 ] ; then if [ $? = 0 ] ; then
echo "All files decrypted." [ ! "$DO_LIST" == "YES" ] && echo "All files decrypted."
else else
error_out "Unable to extract encrypted files." error_out "Unable to extract encrypted files."
fi fi
@ -265,13 +274,14 @@ Commands:
yadm list [-a] - List tracked files yadm list [-a] - List tracked files
yadm alt - Create links for alternates yadm alt - Create links for alternates
yadm encrypt - Encrypt files yadm encrypt - Encrypt files
yadm decrypt - Decrypt files yadm decrypt [-l] - Decrypt files
yadm perms - Fix perms for private files yadm perms - Fix perms for private files
Files: Files:
\$HOME/.yadm/config - yadm's configuration file \$HOME/.yadm/config - yadm's configuration file
\$HOME/.yadm/repo.git - yadm's Git repository \$HOME/.yadm/repo.git - yadm's Git repository
\$HOME/.yadm/encrypt - List of globs used for encrypt/decrypt \$HOME/.yadm/encrypt - List of globs used for encrypt/decrypt
\$HOME/.yadm/files.gpg - Encrypted data stored here
Use "man yadm" for complete documentation. Use "man yadm" for complete documentation.
EOF EOF

4
yadm.1
View File

@ -36,6 +36,7 @@ list
.BR yadm " encrypt .BR yadm " encrypt
.BR yadm " decrypt .BR yadm " decrypt
.RB [ -l ]
.BR yadm " alt .BR yadm " alt
@ -136,6 +137,9 @@ Decrypt all files stored in
Files decrypted will be relative to the configured Files decrypted will be relative to the configured
.IR work-tree " (usually .IR work-tree " (usually
.IR $HOME ). .IR $HOME ).
Using the
.B -l
option will list the files stored without extracting them.
.TP .TP
.B encrypt .B encrypt
Encrypt all files matching the patterns found in Encrypt all files matching the patterns found in

View File

@ -21,7 +21,7 @@
yadm encrypt yadm encrypt
yadm decrypt yadm decrypt [-l]
yadm alt yadm alt
@ -78,7 +78,8 @@
decrypt decrypt
Decrypt all files stored in $HOME/.yadm/files.gpg. Files Decrypt all files stored in $HOME/.yadm/files.gpg. Files
decrypted will be relative to the configured work-tree (usually decrypted will be relative to the configured work-tree (usually
$HOME). $HOME). Using the -l option will list the files stored without
extracting them.
encrypt encrypt
Encrypt all files matching the patterns found in Encrypt all files matching the patterns found in