|
@@ -419,6 +419,14 @@ function import_gpg_key_to_root {
|
419
|
419
|
MY_GPG_PUBLIC_KEY_ID=$(su -c "gpg --list-keys $MY_USERNAME@$DOMAIN_NAME | grep 'pub '" - $MY_USERNAME | awk -F ' ' '{print $2}' | awk -F '/' '{print $2}')
|
420
|
420
|
fi
|
421
|
421
|
|
|
422
|
+ # if the above fails because the key has an unexpected email address
|
|
423
|
+ if [ ! $MY_GPG_PUBLIC_KEY_ID ]; then
|
|
424
|
+ # copy the whole keyring from the user
|
|
425
|
+ cp -r /home/$MY_USERNAME/.gnupg /root
|
|
426
|
+ # get the first entry, which we assume to be the imported key
|
|
427
|
+ MY_GPG_PUBLIC_KEY_ID=$(gpg --list-keys | grep "pub " | head -n 1 | awk -F ' ' '{print $2}' | awk -F '/' '{print $2}')
|
|
428
|
+ fi
|
|
429
|
+
|
422
|
430
|
# make sure that the root user has access to your gpg public key
|
423
|
431
|
if [ $MY_GPG_PUBLIC_KEY_ID ]; then
|
424
|
432
|
su -c "gpg --export-ownertrust > ~/temp_trust.txt" - $MY_USERNAME
|