Changeset - bc975515fcbd
[Not reviewed]
0 1 0
Branko Majic (branko) - 4 years ago 2020-06-29 04:17:40
branko@majic.rs
Added some git integration for the init command. The script will now add the .gnupg to the changeset, and also include a .gitignore file.
1 file changed with 31 insertions and 0 deletions:
0 comments (0 inline, 0 general) First comment
openpgp/gitprotect.sh
Show inline comments
 
@@ -198,12 +198,43 @@ if [[ $command == "init" ]]; then
 
    # Create the local .gnupg directory.
 
    mkdir "$gnupgHome"
 
    chmod 700 "$gnupgHome"
 

	
 
    # Initialise the GnuPG files in local directory.
 
    gpg2 --batch --homedir "$gnupgHome" --list-keys 2>/dev/null
 

	
 
    # Set-up a .gitignore file that will exclude some temporary files from being
 
    # tracked, as well as decrypted files.
 
    cat <<EOF >> .gitignore
 
# BEGIN gitprotect.sh
 
.gnupg/pubring.gpg~
 
.gnupg/random_seed
 
.gnupg/secring.gpg
 
decrypted/
 
# END gitprotect.sh
 
EOF
 
    # Add the empty keyring and gitignore file to the index so they can be
 
    # committed by the user.
 
    git add .gnupg/
 
    git add .gitignore
 
    cat <<EOF
 
$program has set-up the repository directory for encryption. Before proceeding,
 
please commit the changes. The commit includes empty public and trust keryings for
 
GnuPG, and gitignore file that prevents inclusion of decrypted files and
 
temporary GnuPG files.
 

	
 
Before proceeding with the commit, verify the changes with:
 

	
 
git status --staged .
 

	
 
After you have verfied the changes, commit the changes with (you may specify
 
alternative message):
 

	
 
git commit .gnupg .gitignore -m "Configured directory for use with gitprotect.sh"
 

	
 
EOF
 
elif [[ $command == "addkey" ]]; then
 
    gitprotectConfigured || exit "$ERR_NOCONFIG"
 

	
 
    # At least one key has to be provided.
 
    if [[ "${#@}" == 0 ]]; then
 
        echo "ERROR: At least one key file or identifier must be specified" >&2
0 comments (0 inline, 0 general) First comment
You need to be logged in to comment. Login now