Restore users if needed

This commit is contained in:
Bob Mottram 2015-10-27 15:55:17 +00:00
parent b994a9c66c
commit b9121c9683
1 changed files with 64 additions and 16 deletions

View File

@ -3204,9 +3204,12 @@ function create_restore_script {
RESTORE_SUBDIR='usb/backup/mutt/'
fi
echo 'if [ -d $USB_MOUNT/backup/mutt ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' for d in /home/*/ ; do' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' for d in $USB_MOUNT/backup/mutt/*/ ; do' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' USERNAME=$(echo "$d" | awk -F '"'"'/'"'"' '"'"'{print $3}'"'"')' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! -d /home/$USERNAME ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' freedombone-adduser $USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "Restoring Mutt settings for $USERNAME"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' restore_directory_from_usb /root/tempmutt mutt/$USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo -n " if [ -f /root/tempmutt/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME
@ -3236,9 +3239,12 @@ function create_restore_script {
RESTORE_SUBDIR='usb/backup/gnupg/'
fi
echo 'if [ -d $USB_MOUNT/backup/gnupg ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' for d in /home/*/ ; do' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' for d in $USB_MOUNT/backup/gnupg/*/ ; do' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' USERNAME=$(echo "$d" | awk -F '"'"'/'"'"' '"'"'{print $3}'"'"')' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! -d /home/$USERNAME ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' freedombone-adduser $USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "Restoring gnupg settings for $USERNAME"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' restore_directory_from_usb /root/tempgnupg gnupg/$USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo -n " cp -r /root/tempgnupg/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME
@ -3268,9 +3274,12 @@ function create_restore_script {
RESTORE_SUBDIR='usb/backup/procmail/'
fi
echo 'if [ -d $USB_MOUNT/backup/procmail ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' for d in /home/*/ ; do' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' for d in $USB_MOUNT/backup/procmail/*/ ; do' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' USERNAME=$(echo "$d" | awk -F '"'"'/'"'"' '"'"'{print $3}'"'"')' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! -d /home/$USERNAME ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' freedombone-adduser $USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "Restoring procmail settings for $USERNAME"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' restore_directory_from_usb /root/tempprocmail procmail/$USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo -n " cp -f /root/tempprocmail/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME
@ -3292,10 +3301,13 @@ function create_restore_script {
RESTORE_SUBDIR='usb/backup/spamassassin/'
fi
echo 'if [ -d $USB_MOUNT/backup/spamassassin ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' for d in /home/*/ ; do' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' for d in $USB_MOUNT/backup/spamassassin/*/ ; do' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' USERNAME=$(echo "$d" | awk -F '"'"'/'"'"' '"'"'{print $3}'"'"')' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ -d $USB_MOUNT/backup/spamassassin/$USERNAME ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! -d /home/$USERNAME ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' freedombone-adduser $USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "Restoring spamassassin settings for $USERNAME"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' restore_directory_from_usb /root/tempspamassassin spamassassin/$USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo -n " cp -rf /root/tempspamassassin/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME
@ -3356,9 +3368,12 @@ function create_restore_script {
RESTORE_SUBDIR='usb/backup/ssh/'
fi
echo 'if [ -d $USB_MOUNT/backup/ssh ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' for d in /home/*/ ; do' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' for d in $USB_MOUNT/backup/ssh/*/ ; do' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' USERNAME=$(echo "$d" | awk -F '"'"'/'"'"' '"'"'{print $3}'"'"')' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! -d /home/$USERNAME ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' freedombone-adduser $USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "Restoring ssh keys for $USERNAME"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' restore_directory_from_usb /root/tempssh ssh/$USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo -n " cp -r /root/tempssh/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_SCRIPT_NAME
@ -3398,9 +3413,12 @@ function create_restore_script {
RESTORE_SUBDIR='usb/backup/projects/'
fi
echo 'if [ -d $USB_MOUNT/backup/projects ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' for d in /home/*/ ; do' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' for d in $USB_MOUNT/backup/projects/*/ ; do' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' USERNAME=$(echo "$d" | awk -F '"'"'/'"'"' '"'"'{print $3}'"'"')' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! -d /home/$USERNAME ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' freedombone-adduser $USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "Restoring projects for $USERNAME"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' restore_directory_from_usb /root/tempprojects projects/$USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ -d /home/$USERNAME/projects ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
@ -3424,10 +3442,13 @@ function create_restore_script {
RESTORE_SUBDIR='usb/backup/personal/'
fi
echo 'if [ -d $USB_MOUNT/backup/personal ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' for d in /home/*/ ; do' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' for d in $USB_MOUNT/backup/personal/*/ ; do' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' USERNAME=$(echo "$d" | awk -F '"'"'/'"'"' '"'"'{print $3}'"'"')' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ -d $USB_MOUNT/backup/personal/$USERNAME ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! -d /home/$USERNAME ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' freedombone-adduser $USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "Restoring personal settings for $USERNAME"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' restore_directory_from_usb /root/temppersonal personal/$USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ -d /home/$USERNAME/personal ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
@ -3690,9 +3711,12 @@ function create_restore_script {
RESTORE_SUBDIR='usb/backup/mail'
fi
echo 'if [ -d $USB_MOUNT/backup/mail ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' for d in /home/*/ ; do' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' for d in $USB_MOUNT/backup/mail/*/ ; do' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' USERNAME=$(echo "$d" | awk -F '"'"'/'"'"' '"'"'{print $3}'"'"')' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! -d /home/$USERNAME ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' freedombone-adduser $USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' echo "Restoring emails for $USERNAME"' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' restore_directory_from_usb /root/tempmail mail/$USERNAME' >> /usr/bin/$RESTORE_SCRIPT_NAME
echo ' if [ ! -d /home/$USERNAME/Maildir ]; then' >> /usr/bin/$RESTORE_SCRIPT_NAME
@ -4725,10 +4749,13 @@ function restore_from_friend {
if [[ $BACKUP_TYPE != 'obnam' ]]; then
RESTORE_SUBDIR='remoterestore/backup/mutt/'
fi
echo 'for d in /home/*/ ; do' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo 'for d in $SERVER_DIRECTORY/backup/mutt/*/ ; do' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' USERNAME=$(echo "$d" | awk -F '"'"'/'"'"' '"'"'{print $3}'"'"')' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [ -d $SERVER_DIRECTORY/backup/mutt/$USERNAME ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [ ! -d /home/$USERNAME ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' freedombone-adduser $USERNAME' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' echo "Restoring Mutt settings for $USERNAME"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' restore_directory_from_friend /root/tempmutt mutt/$USERNAME' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo -n " if [ -f /root/tempmutt/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
@ -4755,10 +4782,13 @@ function restore_from_friend {
if [[ $BACKUP_TYPE != 'obnam' ]]; then
RESTORE_SUBDIR='remoterestore/backup/gnupg'
fi
echo 'for d in /home/*/ ; do' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo 'for d in $SERVER_DIRECTORY/backup/gnupg/*/ ; do' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' USERNAME=$(echo "$d" | awk -F '"'"'/'"'"' '"'"'{print $3}'"'"')' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [ -d $SERVER_DIRECTORY/backup/gnupg/$USERNAME ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [ ! -d /home/$USERNAME ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' freedombone-adduser $USERNAME' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' echo "Restoring gnupg settings for $USERNAME"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' restore_directory_from_friend /root/tempgnupg gnupg/$USERNAME' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo -n " cp -r /root/tempgnupg/${RESTORE_SUBDIR}/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
@ -4783,10 +4813,13 @@ function restore_from_friend {
if [[ $BACKUP_TYPE != 'obnam' ]]; then
RESTORE_SUBDIR='remoterestore/backup/procmail'
fi
echo 'for d in /home/*/ ; do' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo 'for d in $SERVER_DIRECTORY/backup/procmail/*/ ; do' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' USERNAME=$(echo "$d" | awk -F '"'"'/'"'"' '"'"'{print $3}'"'"')' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [ -d $SERVER_DIRECTORY/backup/procmail/$USERNAME ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [ ! -d /home/$USERNAME ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' freedombone-adduser $USERNAME' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' echo "Restoring procmail settings for $USERNAME"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' restore_directory_from_friend /root/tempprocmail procmail/$USERNAME' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo -n " cp -f /root/tempprocmail/${RESTORE_SUBDIR}" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
@ -4805,10 +4838,13 @@ function restore_from_friend {
if [[ $BACKUP_TYPE != 'obnam' ]]; then
RESTORE_SUBDIR='remoterestore/backup/spamassassin'
fi
echo 'for d in /home/*/ ; do' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo 'for d in $SERVER_DIRECTORY/backup/spamassassin/*/ ; do' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' USERNAME=$(echo "$d" | awk -F '"'"'/'"'"' '"'"'{print $3}'"'"')' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [ -d $SERVER_DIRECTORY/backup/spamassassin/$USERNAME ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [ ! -d /home/$USERNAME ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' freedombone-adduser $USERNAME' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' echo "Restoring spamassassin settings for $USERNAME"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' restore_directory_from_friend /root/tempspamassassin spamassassin/$USERNAME' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo -n " cp -rf /root/tempspamassassin/${RESTORE_SUBDIR}/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
@ -4861,10 +4897,13 @@ function restore_from_friend {
if [[ $BACKUP_TYPE != 'obnam' ]]; then
RESTORE_SUBDIR='remoterestore/backup/ssh'
fi
echo 'for d in /home/*/ ; do' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo 'for d in $SERVER_DIRECTORY/backup/ssh/*/ ; do' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' USERNAME=$(echo "$d" | awk -F '"'"'/'"'"' '"'"'{print $3}'"'"')' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [ -d $SERVER_DIRECTORY/backup/ssh/$USERNAME ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [ ! -d /home/$USERNAME ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' freedombone-adduser $USERNAME' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' echo "Restoring ssh keys for $USERNAME"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' restore_directory_from_friend /root/tempssh ssh/$USERNAME' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo -n " cp -r /root/tempssh/${RESTORE_SUBDIR}/" >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
@ -4899,10 +4938,13 @@ function restore_from_friend {
if [[ $BACKUP_TYPE != 'obnam' ]]; then
RESTORE_SUBDIR='remoterestore/backup/projects'
fi
echo 'for d in /home/*/ ; do' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo 'for d in $SERVER_DIRECTORY/backup/projects/*/ ; do' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' USERNAME=$(echo "$d" | awk -F '"'"'/'"'"' '"'"'{print $3}'"'"')' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [ -d $SERVER_DIRECTORY/backup/projects/$USERNAME ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [ ! -d /home/$USERNAME ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' freedombone-adduser $USERNAME' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' echo "Restoring projects for $USERNAME"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' restore_directory_from_friend /root/tempprojects projects/$USERNAME' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [ -d /home/$USERNAME/projects ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
@ -4923,10 +4965,13 @@ function restore_from_friend {
if [[ $BACKUP_TYPE != 'obnam' ]]; then
RESTORE_SUBDIR='remoterestore/backup/personal'
fi
echo 'for d in /home/*/ ; do' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo 'for d in $SERVER_DIRECTORY/backup/personal/*/ ; do' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' USERNAME=$(echo "$d" | awk -F '"'"'/'"'"' '"'"'{print $3}'"'"')' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [ -d $SERVER_DIRECTORY/backup/personal/$USERNAME ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [ ! -d /home/$USERNAME ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' freedombone-adduser $USERNAME' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' echo "Restoring personal settings for $USERNAME"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' restore_directory_from_friend /root/temppersonal personal/$USERNAME' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [ -d /home/$USERNAME/personal ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
@ -5216,10 +5261,13 @@ function restore_from_friend {
if [[ $BACKUP_TYPE != 'obnam' ]]; then
RESTORE_SUBDIR='remoterestore/backup/mail'
fi
echo 'for d in /home/*/ ; do' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo 'for d in $SERVER_DIRECTORY/backup/mail/*/ ; do' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' USERNAME=$(echo "$d" | awk -F '"'"'/'"'"' '"'"'{print $3}'"'"')' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [[ $USERNAME != "git" ]]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [ -d $SERVER_DIRECTORY/backup/mail/$USERNAME ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [ ! -d /home/$USERNAME ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' freedombone-adduser $USERNAME' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' fi' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' echo "Restoring emails for $USERNAME"' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' restore_directory_from_friend /root/tempmail mail/$USERNAME' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME
echo ' if [ ! -d /home/$USERNAME/Maildir ]; then' >> /usr/bin/$RESTORE_FROM_FRIEND_SCRIPT_NAME