|
@@ -38,6 +38,19 @@ function gpg_update_mutt {
|
38
|
38
|
CURR_EMAIL_ADDRESS=$key_username@$HOSTNAME
|
39
|
39
|
CURR_GPG_ID=$(gpg --homedir=/home/$key_username/.gnupg --list-keys $CURR_EMAIL_ADDRESS | sed -n '2p' | sed 's/^[ \t]*//')
|
40
|
40
|
|
|
41
|
+ # If the default key is specified within gpg.conf
|
|
42
|
+ if [ -f /home/$key_username/gpg.conf ]; then
|
|
43
|
+ if grep -q "default-key" /home/$key_username/gpg.conf; then
|
|
44
|
+ default_gpg_key=$(cat /home/$key_username/gpg.conf | grep "default-key")
|
|
45
|
+ if [[ "$default_gpg_key" != *'#'* ]]; then
|
|
46
|
+ default_gpg_key=$(cat /home/$key_username/gpg.conf | grep "default-key" | awk -F ' ' '{print $2}')
|
|
47
|
+ if [ ${#default_gpg_key} -gt 3 ]; then
|
|
48
|
+ CURR_GPG_ID=$(gpg --homedir=/home/$key_username/.gnupg --list-keys $default_gpg_key | sed -n '2p' | sed 's/^[ \t]*//')
|
|
49
|
+ fi
|
|
50
|
+ fi
|
|
51
|
+ fi
|
|
52
|
+ fi
|
|
53
|
+
|
41
|
54
|
sed -i "s|set pgp_encrypt_only_command.*|set pgp_encrypt_only_command=\"/usr/lib/mutt/pgpewrap gpg --batch --quiet --no-verbose --output - --encrypt --textmode --armor --trust-model always --encrypt-to $CURR_GPG_ID -- -r %r -- %f\"|g" /home/$key_username/.muttrc
|
42
|
55
|
sed -i "s|set pgp_encrypt_sign_command.*|set pgp_encrypt_sign_command=\"/usr/lib/mutt/pgpewrap gpg %?p?--passphrase-fd 0? --batch --quiet --no-verbose --textmode --output - --encrypt --sign %?a?-u %a? --armor --trust-model always --encrypt-to $CURR_GPG_ID -- -r %r -- %f\"|g" /home/$key_username/.muttrc
|
43
|
56
|
|