Use homedir for gpg export and import
This commit is contained in:
parent
839e129c5f
commit
22e6e4ae62
|
@ -145,17 +145,17 @@ if [[ $MASTER_DRIVE == "yes" || $MASTER_DRIVE == "y" || $MASTER_DRIVE == "1" ]];
|
|||
export GPG_TTY
|
||||
|
||||
USER_EMAIL_ADDRESS=$MY_USERNAME@$HOSTNAME
|
||||
GPG_ID=$(gpg --list-keys $USER_EMAIL_ADDRESS | sed -n '2p' | sed 's/^[ \t]*//')
|
||||
GPG_BACKUP_ID=$(gpg --list-keys "(backup key)" | sed -n '2p' | sed 's/^[ \t]*//')
|
||||
GPG_ID=$(su -m root -c "gpg --list-keys $USER_EMAIL_ADDRESS | sed -n '2p' | sed 's/^[ \t]*//'" - $MY_USERNAME)
|
||||
GPG_BACKUP_ID=$(su -m root -c "gpg --list-keys \"(backup key)\" | sed -n '2p' | sed 's/^[ \t]*//'" - $MY_USERNAME)
|
||||
|
||||
gpgerrstr=$'error'
|
||||
gpgkey=$(gpg --armor --export $GPG_ID)
|
||||
gpgkey=$(gpg --homedir=/home/$MY_USERNAME/.gnupg --armor --export $GPG_ID)
|
||||
if [[ "$gpgkey" == *"$gpgerrstr"* ]]; then
|
||||
echo $'Problem exporting public gpg key'
|
||||
echo "$gpgkey"
|
||||
exit 735282
|
||||
fi
|
||||
gpgprivkey=$(gpg --armor --export-secret-key $GPG_ID)
|
||||
gpgprivkey=$(gpg --homedir=/home/$MY_USERNAME/.gnupg --armor --export-secret-key $GPG_ID)
|
||||
if [[ "$gpgprivkey" == *"$gpgerrstr"* ]]; then
|
||||
echo $'Problem exporting private gpg key'
|
||||
echo "$gpgprivkey"
|
||||
|
@ -163,17 +163,17 @@ if [[ $MASTER_DRIVE == "yes" || $MASTER_DRIVE == "y" || $MASTER_DRIVE == "1" ]];
|
|||
exit 629362
|
||||
fi
|
||||
|
||||
backupgpgkey=$(gpg --armor --export $GPG_BACKUP_ID)
|
||||
backupgpgkey=$(gpg --homedir=/home/$MY_USERNAME/.gnupg --armor --export $GPG_BACKUP_ID)
|
||||
if [[ "$backupgpgkey" == *"$gpgerrstr"* ]]; then
|
||||
echo $'Problem exporting public gpg backup key'
|
||||
echo "$backupgpgkey"
|
||||
exit 735282
|
||||
fi
|
||||
backupgpgprivkey=$(gpg --armor --export-secret-key $GPG_BACKUP_ID)
|
||||
backupgpgprivkey=$(gpg --homedir=/home/$MY_USERNAME/.gnupg --armor --export-secret-key $GPG_BACKUP_ID)
|
||||
if [[ "$backupgpgprivkey" == *"$gpgerrstr"* ]]; then
|
||||
echo $'Problem exporting private gpg backup key'
|
||||
echo "$backupgpgprivkey"
|
||||
gpgprivkey=
|
||||
backupgpgprivkey=
|
||||
exit 629362
|
||||
fi
|
||||
|
||||
|
|
|
@ -174,7 +174,7 @@ fi
|
|||
echo $'Key fragments recombined'
|
||||
|
||||
# import the gpg key
|
||||
su -c "gpg --allow-secret-key-import --import $KEYS_FILE" - $MY_USERNAME
|
||||
gpg --homedir=/home/$MY_USERNAME/.gnupg --allow-secret-key-import --import $KEYS_FILE
|
||||
if [ ! "$?" = "0" ]; then
|
||||
echo $'Unable to import gpg key'
|
||||
shred -zu $KEYS_FILE
|
||||
|
|
Loading…
Reference in New Issue