--- /dev/null
+#!/bin/bash
+
+user="gustav"
+help="\
+Encrypts or decrypts a bare repository to or from some origin
+or destination, using gpg-zip.
+
+usage: repo-encrypt encrypt <destination-filename>
+ repo-encrypt decrypt <origin-filename> <destination-directory>
+
+examples:
+
+ repo-encrypt encrypt /media/usb/git/configurations.gpg-zip
+
+ repo-encrypt decrypt /media/usb/git/configurations.gpg-zip /tmp
+
+For the encryption command, parent directory need to be a git repository.
+"
+
+if [ ${#@} -lt 2 ]; then printf "$0: Wrong number of arguments!\n\n$help"; exit 2; fi
+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
+ parent="$(pwd | sed -e 's:^/.*/\(.*$\):\1:')"
+ cd ..
+ gpg-zip --encrypt --output "$destination" --gpg-args "-r $user" "${parent}/.git"
+ cd -
+elif [ $1 == decrypt ]; then
+ if [ ${#@} -ne 3 ]; then printf "$0: Wrong number of arguments!\n\n$help"; exit 2; fi
+ origin=$2
+ destination=$3
+ if [ ! $(echo $destination | grep "^/") ]; then destination="$(pwd)/$destination"; fi
+ if [ ! $(echo $origin | grep "^/") ]; then origin="$(pwd)/$origin"; fi
+ cd "$destination"
+ gpg-zip --decrypt "$origin"
+ cd -
+else printf "$0: Command '$1' does not exist!\n\n$help"; exit 2
+fi
+
+# for decryption
+