From 940101b74c83fb73df87eda24395348b83004c73 Mon Sep 17 00:00:00 2001 From: Bob Mottram Date: Fri, 19 Jan 2018 17:31:16 +0000 Subject: [PATCH] More directory creations on restore --- src/freedombone-restore-local | 23 ++++++++++++++++++++++- src/freedombone-restore-remote | 23 ++++++++++++++++++++++- 2 files changed, 44 insertions(+), 2 deletions(-) diff --git a/src/freedombone-restore-local b/src/freedombone-restore-local index 1367854c..62e1e3a9 100755 --- a/src/freedombone-restore-local +++ b/src/freedombone-restore-local @@ -13,7 +13,7 @@ # License # ======= # -# Copyright (C) 2015-2017 Bob Mottram +# Copyright (C) 2015-2018 Bob Mottram # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by @@ -464,6 +464,9 @@ function restore_gpg { if [ -d $temp_restore_dir/home/$USERNAME/.gnupg ]; then cp -r $temp_restore_dir/home/$USERNAME/.gnupg /home/$USERNAME/ else + if [ ! -d /home/$USERNAME/.gnupg ]; then + mkdir /home/$USERNAME/.gnupg + fi cp -r $temp_restore_dir/* /home/$USERNAME/.gnupg/ fi if [ ! "$?" = "0" ]; then @@ -543,6 +546,9 @@ function restore_spamassassin { if [ -d $temp_restore_dir/home/$USERNAME ]; then cp -rf $temp_restore_dir/home/$USERNAME/.spamassassin /home/$USERNAME/ else + if [ ! -d /home/$USERNAME/.spamassassin ]; then + mkdir /home/$USERNAME/.spamassassin + fi cp -rf $temp_restore_dir/* /home/$USERNAME/.spamassassin/ fi if [ ! "$?" = "0" ]; then @@ -611,6 +617,9 @@ function restore_user_ssh_keys { if [ -d $temp_restore_dir/home/$USERNAME/.ssh ]; then cp -r $temp_restore_dir/home/$USERNAME/.ssh /home/$USERNAME/ else + if [ ! -d /home/$USERNAME/.ssh ]; then + mkdir /home/$USERNAME/.ssh + fi cp -r $temp_restore_dir/* /home/$USERNAME/.ssh/ fi if [ ! "$?" = "0" ]; then @@ -680,6 +689,9 @@ function restore_user_monkeysphere { if [ -d $temp_restore_dir/home/$USERNAME/.monkeysphere ]; then cp -r $temp_restore_dir/home/$USERNAME/.monkeysphere /home/$USERNAME/ else + if [ ! -d /home/$USERNAME/.monkeysphere ]; then + mkdir /home/$USERNAME/.monkeysphere + fi cp -r $temp_restore_dir/* /home/$USERNAME/.monkeysphere fi if [ ! "$?" = "0" ]; then @@ -721,6 +733,9 @@ function restore_user_fin { if [ -d $temp_restore_dir/home/$USERNAME/.fin ]; then cp -r $temp_restore_dir/home/$USERNAME/.fin /home/$USERNAME/ else + if [ ! -d /home/$USERNAME/.fin ]; then + mkdir /home/$USERNAME/.fin + fi cp -r $temp_restore_dir/* /home/$USERNAME/.fin/ fi if [ ! "$?" = "0" ]; then @@ -754,6 +769,9 @@ function restore_user_local { if [ -d $temp_restore_dir/home/$USERNAME/.local ]; then cp -r $temp_restore_dir/home/$USERNAME/.local /home/$USERNAME/ else + if [ ! -d /home/$USERNAME/.local ]; then + mkdir /home/$USERNAME/.local + fi cp -r $temp_restore_dir/* /home/$USERNAME/.local/ fi if [ ! "$?" = "0" ]; then @@ -840,6 +858,9 @@ function restore_personal_settings { if [ -d $temp_restore_dir/home/$USERNAME/personal ]; then mv $temp_restore_dir/home/$USERNAME/personal /home/$USERNAME else + if [ ! -d /home/$USERNAME/personal ]; then + mkdir /home/$USERNAME/personal + fi cp -r $temp_restore_dir/* /home/$USERNAME/personal/ fi if [ ! "$?" = "0" ]; then diff --git a/src/freedombone-restore-remote b/src/freedombone-restore-remote index 2d2b0ddc..b7d55782 100755 --- a/src/freedombone-restore-remote +++ b/src/freedombone-restore-remote @@ -13,7 +13,7 @@ # License # ======= # -# Copyright (C) 2015-2017 Bob Mottram +# Copyright (C) 2015-2018 Bob Mottram # # This program is free software: you can redistribute it and/or modify # it under the terms of the GNU Affero General Public License as published by @@ -419,6 +419,9 @@ function restore_gpg { if [ -d ${temp_restore_dir}/home/$USERNAME/.gnupg ]; then cp -r ${temp_restore_dir}/home/$USERNAME/.gnupg /home/$USERNAME/ else + if [ ! -d /home/$USERNAME/.gnupg ]; then + mkdir /home/$USERNAME/.gnupg + fi cp -r ${temp_restore_dir}/* /home/$USERNAME/.gnupg/ fi if [ ! "$?" = "0" ]; then @@ -488,6 +491,9 @@ function restore_spamassassin { if [ -d $temp_restore_dir/home/$USERNAME ]; then cp -rf $temp_restore_dir/home/$USERNAME/.spamassassin /home/$USERNAME/ else + if [ ! -d /home/$USERNAME/.spamassassin ]; then + mkdir /home/$USERNAME/.spamassassin + fi cp -rf $temp_restore_dir/* /home/$USERNAME/.spamassassin/ fi if [ ! "$?" = "0" ]; then @@ -542,6 +548,9 @@ function restore_ssh_keys { if [ -d $temp_restore_dir/home/$USERNAME/.ssh ]; then cp -r $temp_restore_dir/home/$USERNAME/.ssh /home/$USERNAME/ else + if [ ! -d /home/$USERNAME/.ssh ]; then + mkdir /home/$USERNAME/.ssh + fi cp -r $temp_restore_dir/* /home/$USERNAME/.ssh/ fi if [ ! "$?" = "0" ]; then @@ -607,6 +616,9 @@ function restore_user_monkeysphere { if [ -d $temp_restore_dir/home/$USERNAME/.monkeysphere ]; then cp -r $temp_restore_dir/home/$USERNAME/.monkeysphere /home/$USERNAME/ else + if [ ! -d /home/$USERNAME/.monkeysphere ]; then + mkdir /home/$USERNAME/.monkeysphere + fi cp -r $temp_restore_dir/* /home/$USERNAME/.monkeysphere/ fi if [ ! "$?" = "0" ]; then @@ -646,6 +658,9 @@ function restore_user_fin { if [ -d $temp_restore_dir/home/$USERNAME/.fin ]; then cp -r $temp_restore_dir/home/$USERNAME/.fin /home/$USERNAME/ else + if [ ! -d /home/$USERNAME/.fin ]; then + mkdir /home/$USERNAME/.fin + fi cp -r $temp_restore_dir/* /home/$USERNAME/.fin/ fi if [ ! "$?" = "0" ]; then @@ -677,6 +692,9 @@ function restore_user_local { if [ -d $temp_restore_dir/home/$USERNAME/.local ]; then cp -r $temp_restore_dir/home/$USERNAME/.local /home/$USERNAME/ else + if [ ! -d /home/$USERNAME/.local ]; then + mkdir /home/$USERNAME/.local + fi cp -r $temp_restore_dir/* /home/$USERNAME/.local/ fi if [ ! "$?" = "0" ]; then @@ -757,6 +775,9 @@ function restore_personal_settings { fi mv $temp_restore_dir/home/$USERNAME/personal /home/$USERNAME else + if [ ! -d /home/$USERNAME/personal ]; then + mkdir /home/$USERNAME/personal + fi cp -r $temp_restore_dir/* /home/$USERNAME/personal/ fi if [ ! "$?" = "0" ]; then