Tidying key recovery from usb

This commit is contained in:
Bob Mottram 2016-10-27 10:35:45 +01:00
parent 8409b0f198
commit 763544efd7
3 changed files with 21 additions and 28 deletions

View File

@ -955,8 +955,8 @@ function reconstruct_key {
}
function interactive_gpg_from_usb {
dialog --title $"Encryption keys" \
--msgbox $'Plug in a USB drive containing a copy of your full key or key fragment' 6 70
dialog --title $"Recover Encryption Keys" \
--msgbox $'Plug in a USB keydrive containing a copy of your full key or key fragment' 6 70
HOME_DIR=/home/$MY_USERNAME
GPG_LOADING="yes"
@ -964,34 +964,17 @@ function interactive_gpg_from_usb {
GPG_CTR=0
while [[ $GPG_LOADING == "yes" ]]
do
if [[ $INSTALLING_ON_BBB == "yes" ]]; then
GPG_USB_DRIVE='/dev/sda1'
if [ ! -b $GPG_USB_DRIVE ]; then
if (( GPG_CTR > 0 )); then
reconstruct_key
return 0
fi
dialog --title $"Encryption keys" --msgbox $'No USB drive found' 6 30
exit 739836
fi
else
GPG_USB_DRIVE='/dev/sdb1'
if [ ! -b $GPG_USB_DRIVE ]; then
GPG_USB_DRIVE='/dev/sdc1'
if [ ! -b $GPG_USB_DRIVE ]; then
GPG_USB_DRIVE='/dev/sdd1'
if [ ! -b $GPG_USB_DRIVE ]; then
if (( GPG_CTR > 0 )); then
reconstruct_key
return 0
fi
dialog --title $"Encryption keys" --msgbox $'No USB drive found' 6 30
exit 27852
fi
fi
if [ ! -b $GPG_USB_DRIVE ]; then
if (( GPG_CTR > 0 )); then
reconstruct_key
return 0
fi
dialog --title $"Recover Encryption Keys" --msgbox $'No USB drive found' 6 30
exit 739836
fi
detect_usb_drive
GPG_USB_DRIVE=$USB_DRIVE
GPG_USB_MOUNT='/mnt/usb'
umount -f $GPG_USB_MOUNT
if [ ! -d $GPG_USB_MOUNT ]; then
@ -1013,7 +996,7 @@ function interactive_gpg_from_usb {
reconstruct_key
return 0
fi
dialog --title $"Encryption keys" \
dialog --title $"Recover Encryption Keys" \
--msgbox $"There was a problem mounting the USB drive to $GPG_USB_MOUNT" 6 70
rm -rf $GPG_USB_MOUNT
exit 74393

View File

@ -135,6 +135,10 @@ if [[ $MASTER_DRIVE == "yes" || $MASTER_DRIVE == "y" || $MASTER_DRIVE == "1" ]];
exit 73025
fi
cp -rf /home/$MY_USERNAME/.gnupg $USB_MOUNT
if [ -d /etc/letsencrypt ]; then
cp -rf /etc/letsencrypt $USB_MOUNT
echo $"LetsEncrypt keys copied to $USB_DRIVE"
fi
if [ -d $USB_MOUNT/.gnupg ]; then
echo $"GPG Keyring copied to $USB_DRIVE. You may now remove the drive."
else

View File

@ -223,6 +223,12 @@ function interactive_gpg_from_usb {
if [ ! -d $HOME_DIR/.gnupg ]; then
mkdir $HOME_DIR/.gnupg
fi
if [ -d $GPG_USB_MOUNT/letsencrypt ]; then
test -r $GPG_USB_MOUNT/letsencrypt
if [ $? -ne ]; then
cp -rf $GPG_USB_MOUNT/letsencrypt /etc
fi
fi
cp -r $GPG_USB_MOUNT/.gnupg/* $HOME_DIR/.gnupg
GPG_LOADING="no"
dialog --title $"Encryption keys" \