Simplify key recovery from remote servers

This commit is contained in:
Bob Mottram 2015-12-09 16:32:30 +00:00
parent 3f91711e93
commit bbe5d6a9e0
1 changed files with 3 additions and 18 deletions

View File

@ -135,24 +135,9 @@ function restore_database_from_friend {
fi
}
# Social key management. Note that because this a restore from only
# one domain you are only going to download a single fragment for each gpg key.
# To recover all fragments use the recoverkey command
for d in /home/*/ ; do
USERNAME=$(echo "$d" | awk -F '/' '{print $3}')
if [[ $USERNAME != "git" ]]; then
# Retrieve key fragments for $USERNAME
/usr/bin/sshpass -p "$REMOTE_PASSWORD" scp -r -P $REMOTE_SSH_PORT $REMOTE_SERVER/.gnupg_fragments_$USERNAME /home/$USERNAME/
if [ -d /home/$USERNAME/.gnupg_fragments_$USERNAME ]; then
if [ -d /home/$USERNAME/.gnupg_fragments ]; then
cp /home/$USERNAME/.gnupg_fragments_$USERNAME/* /home/$USERNAME/.gnupg_fragments
rm -rf /home/$USERNAME/.gnupg_fragments_$USERNAME
else
mv /home/$USERNAME/.gnupg_fragments_$USERNAME /home/$USERNAME/.gnupg_fragments
fi
fi
fi
done
# Social key management
# Recover any key fragments and reconstruct the gpg key
${PROJECT_NAME}-recoverkey -u ${ADMIN_USERNAME} -l /home/${ADMIN_USERNAME}/backup.list
copy_gpg_keys