Skip to content

Instantly share code, notes, and snippets.

@T31337
Last active May 26, 2018 21:51
Show Gist options
  • Save T31337/90de98dc4428832938e0de8f4f30fc19 to your computer and use it in GitHub Desktop.
Save T31337/90de98dc4428832938e0de8f4f30fc19 to your computer and use it in GitHub Desktop.
gpg helper functions script
#!/bin/bash
echo -e "\n"
echo -e "==========="
echo -e "GPG HELEPR"
echo -e "=========="
genKey()
{
clear
echo -e "Generate New GPG Key...\n"
#Generate New GPG Key
gpg --full-generate-key
}
listSecretKey()
{
#List gpg keys
clear
echo -e "Secret GPG Keys:\n"
gpg --list-secret-keys --keyid-format LONG
}
printKey()
{
# Prints the GPG key, in ASCII armor format
clear
echo -e "GPG Keys (ASCII ARMOR FORMAT)\n"
echo -e "------------------------------------\n"
gpg --armor --export
}
SignTag()
{
echo -e "GIT Tagging\n"
echo -e "--------------\n"
#sign tag
git tag -s mytag
#verify tag
git tag -v mytag
}
backupKeys()
{
echo -e "Backing Up GPG Keys...\n"
echo -e "------------------------\n"
#Backup Keys!
cp -R ~/.gnupg/ ~/gnupg_backup
}
restoreKeys()
{
echo -e "Restoring GPG Keys...\n"
echo -e "-----------------------\n"
#Restore Keys!
#incase a folder exists, it will be moved to ~/.gnupg.old
if [[ -d ~/.gnupg ]]; then
mv ~/.gnupg ~/.gnupg.$(date "+%y%m%d%H%M%S").old;
fi
mv ~/gnupg_backup ~/.gnupg
echo -e "\n\nDone!\n"
}
if [ ! $@ ]; then
clear
echo
echo -e "-GPG Helper-"
echo -e " Functions"
echo -e "------------\n"
echo -e " genKey\n listSecretKey\n printKey\n configureGit\n SignTag\n backupKeys\n restoreKeys\n"
echo -e "***************************\n"
else
$1
fi
@T31337
Copy link
Author

T31337 commented May 21, 2018

FIXED ERROR: Using $1 VS $@

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment