diff --git a/install-freedombone.sh b/install-freedombone.sh index 4c8fca55..352d9394 100755 --- a/install-freedombone.sh +++ b/install-freedombone.sh @@ -428,18 +428,18 @@ function import_gpg_key_to_root { cp -r /home/$MY_USERNAME/.gnupg /root # get the first entry, which we assume to be the imported key MY_GPG_PUBLIC_KEY_ID=$(gpg --list-keys | grep "pub " | head -n 1 | awk -F ' ' '{print $2}' | awk -F '/' '{print $2}') - fi - - # make sure that the root user has access to your gpg public key - if [ $MY_GPG_PUBLIC_KEY_ID ]; then - su -c "gpg --export-ownertrust > ~/temp_trust.txt" - $MY_USERNAME - su -c "gpg --output $MY_GPG_PUBLIC_KEY --armor --export $MY_GPG_PUBLIC_KEY_ID" - $MY_USERNAME - su -c "gpg --output ~/temp_private_key.txt --armor --export-secret-key $MY_GPG_PUBLIC_KEY_ID" - $MY_USERNAME - gpg --import-ownertrust < /home/$MY_USERNAME/temp_trust.txt - gpg --import $MY_GPG_PUBLIC_KEY - gpg --allow-secret-key-import --import /home/$MY_USERNAME/temp_private_key.txt - shred -zu /home/$MY_USERNAME/temp_private_key.txt - shred -zu /home/$MY_USERNAME/temp_trust.txt + else + # make sure that the root user has access to your gpg public key + if [ $MY_GPG_PUBLIC_KEY_ID ]; then + su -c "gpg --export-ownertrust > ~/temp_trust.txt" - $MY_USERNAME + su -c "gpg --output $MY_GPG_PUBLIC_KEY --armor --export $MY_GPG_PUBLIC_KEY_ID" - $MY_USERNAME + su -c "gpg --output ~/temp_private_key.txt --armor --export-secret-key $MY_GPG_PUBLIC_KEY_ID" - $MY_USERNAME + gpg --import-ownertrust < /home/$MY_USERNAME/temp_trust.txt + gpg --import $MY_GPG_PUBLIC_KEY + gpg --allow-secret-key-import --import /home/$MY_USERNAME/temp_private_key.txt + shred -zu /home/$MY_USERNAME/temp_private_key.txt + shred -zu /home/$MY_USERNAME/temp_trust.txt + fi fi }