Social key management as the first step

This commit is contained in:
Bob Mottram 2015-12-09 15:39:51 +00:00
parent d454608ec3
commit 0124ea76b6
1 changed files with 17 additions and 17 deletions

View File

@ -135,6 +135,23 @@ function restore_database_from_friend {
fi
}
# Social key management
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
copy_gpg_keys
# Restore configuration files
@ -650,23 +667,6 @@ if [ -d /var/cache/minidlna ]; then
fi
fi
# Social key management
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
echo $"*** Remote restore was successful ***"
exit 0