Check for backup key file

This commit is contained in:
Bob Mottram 2017-06-23 18:39:20 +01:00
parent b5f6a554f3
commit c1bd5c9691
1 changed files with 5 additions and 1 deletions

View File

@ -119,9 +119,13 @@ function interactive_gpg_from_usb {
cp -r $USB_MOUNT/letsencrypt/* /etc/letsencrypt
fi
if [ -f $USB_MOUNT/.mastergpgkey && -f $USB_MOUNT/.backupgpgkey ]; then
if [ -f $USB_MOUNT/.mastergpgkey ]; then
# Recovering keys from file rather than just copying the gnupg
# directory may help to avoid problems during upgrades/reinstalls
if [ ! -f $USB_MOUNT/.backupgpgkey ]; then
echo $'No backup key file found on USB drive'
exit 725729
fi
gpg --homedir=/home/$MY_USERNAME/.gnupg --allow-secret-key-import --import $USB_MOUNT/.mastergpgkey
echo "$BACKUP_DUMMY_PASSWORD" | gpg --batch --passphrase-fd 0 --homedir=/home/$MY_USERNAME/.gnupg --allow-secret-key-import --import $USB_MOUNT/.backupgpgkey
if [ -d /home/$MY_USERNAME/.gnupg ]; then