# of hte 'encrypt' command to be destination directory path, since
# filename should be derived from Git.
#
+# Comment. Already as of now, the destination directory, not the file,
+# is provided as argument.
+#
# TODO REFACTOR Separate sentral command functionality (compression
# and extractions) into functions
#
Encrypts or decrypts a bare repository to or from some origin
or destination, using gpg-zip.
-usage: repo-encrypt encrypt <destination-filename>
+usage: repo-encrypt encrypt <destination-directory>
repo-encrypt decrypt <origin-filename> <destination-directory>
examples:
- repo-encrypt encrypt /media/usb/git/configurations.gpg-zip
+ repo-encrypt encrypt /media/usb/git/
- repo-encrypt decrypt /media/usb/git/configurations.gpg-zip /tmp
+ repo-encrypt decrypt /media/usb/git/configurations.git.tar.gpg /tmp
For the encryption command, parent directory need to be a git repository.
"
if [ $1 == encrypt ]; then
if [ ${#@} -ne 2 ]; then printf "$0: Wrong number of arguments!\n\n$help"; exit 2; fi
if [ ! -d ".git" ]; then printf "$0: This is not a Git repository.\n\n$help"; exit 2; fi
- destination=$2
- if [ ! $(echo $destination | grep "^/") ]; then destination="$(pwd)/$destination"; fi
+ destination="$2"
+ if [ ! -d "$destination" ]; then printf "$0: Destination is not a directory.\n\n$help"; exit 2; fi
parent="$(pwd | sed -e 's:^/.*/\(.*$\):\1:')"
tmp_dir="/tmp/${0##*/}-$$"
mkdir "$tmp_dir"
cp --recursive .git "$tmp_dir/$parent.git"
tar --directory "$tmp_dir" --create --file "$tmp_dir/$parent.git.tar" "$parent.git"
- gpg --encrypt --recipient "$user" < "$tmp_dir/$parent.git.tar" > "$destination"
+ gpg --encrypt --recipient "$user" < "$tmp_dir/$parent.git.tar" > "$destination/$parent.git.tar.gpg"
rm -fr "$tmp_dir"
elif [ $1 == decrypt ]; then
if [ ${#@} -ne 3 ]; then printf "$0: Wrong number of arguments!\n\n$help"; exit 2; fi