Call gpg2 specifically instead of just gpg. Some systems have both gpg1 and gpg2, and we need gpg2.

This commit is contained in:
Storm Dragon 2021-01-18 11:18:11 -05:00
parent 267fbbbc9a
commit 523e7d4eb4

View File

@ -24,7 +24,7 @@ muttHome=~/.mutt
check_dependancies()
{
local dep
for dep in dialog gettext gpg mutt ; do
for dep in dialog gettext gpg2 mutt ; do
if ! command -v $dep &> /dev/null ; then
echo "$(eval_gettext "\$dep is not installed. Please install $dep and run this script again.")"
exit 1
@ -207,8 +207,8 @@ EOF
if [[ $(gpg --list-secret-keys | wc -l) -eq 0 ]]; then
read -p "$(gettext "No gpg key was found. Type your name and press entr to generate a PGP key.control+c if you would like to create it manually.") " continue
# Try to use quick key generation, and fall back to the more verbose version for legacy systems.
if ! gpg --quick-gen-key "${continue:-${USER}}"; then
gpg --gen-key
if ! gpg2 --quick-gen-key "${continue:-${USER}}"; then
gpg2 --gen-key
fi
fi
PS3="$(gettext "Select the key you want to use for encryption/signing:")"
@ -217,7 +217,7 @@ EOF
break
fi
done
keyName="$(gpg --list-secret-keys --keyid-format short | grep -B1 ^uid | head -n1 | rev | cut -c -8 | rev)"
keyName="$(gpg2 --list-secret-keys --keyid-format short | grep -B1 ^uid | head -n1 | rev | cut -c -8 | rev)"
echo "set pgp_sign_as=$keyName" >> "$muttHome/gpg.rc"
fi
# Create or update macro file
@ -304,7 +304,7 @@ configure_gpg()
fi
# Make sure the configuration directory exists
if ! [ -d ~/.gnupg/ ]; then
gpg --list-secret-keys &> /dev/null
gpg2 --list-secret-keys &> /dev/null
fi
if [ -f ~/.gnupg/gpg.conf ]; then
read -p "$(gettext "This will overwrite your existing ~/.gnupg/gpg.conf file. Press enter to continue or control+c to abort. ")" continue
@ -380,12 +380,12 @@ add_email_address()
echo "$(gettext "The passwords do not match.")"
fi
done
keyName="$(gpg --list-secret-keys --keyid-format short | grep -B1 ^uid | head -n1 | rev | cut -c -8 | rev)"
keyName="$(gpg2 --list-secret-keys --keyid-format short | grep -B1 ^uid | head -n1 | rev | cut -c -8 | rev)"
# I wish it were possible to just echo the password through gpg and not have an unencrypted file at all.
# but either it's not, or I just can't figure out how to do it. So we'll use mktemp and shred.
passwordFile="$(mktemp)"
echo -e "set imap_pass=\"$passOne\"\nset smtp_pass=\"$passOne\"" > "$passwordFile"
gpg -r $keyName -e "$passwordFile"
gpg2 -r $keyName -e "$passwordFile"
mv "$passwordFile.gpg" "$muttHome/$emailAddress.gpg"
shred -fuzn 10 "$passwordFile"
echo "source \"gpg -d ${muttHome/#$HOME/\~}/${emailAddress}.gpg|\"" >> "$muttHome/$emailAddress"