|
@@ -965,17 +965,62 @@ function backup_data {
|
965
|
965
|
any_key
|
966
|
966
|
}
|
967
|
967
|
|
968
|
|
-function restore_from_usb {
|
|
968
|
+function restore_data_from_storage {
|
|
969
|
+ restore_type="$1"
|
|
970
|
+
|
|
971
|
+ restore_command="${PROJECT_NAME}-restore-local $USB_DRIVE"
|
|
972
|
+ if [[ $restore_type != "local" ]]; then
|
|
973
|
+ restore_command="${PROJECT_NAME}-restore-remote $remote_domain_name configuration;;"
|
|
974
|
+ else
|
|
975
|
+ remote_domain_name="$1"
|
|
976
|
+ restore_command="${PROJECT_NAME}-restore-remote $remote_domain_name"
|
|
977
|
+ fi
|
|
978
|
+
|
|
979
|
+ utils_installed=(configuration
|
|
980
|
+ mariadb
|
|
981
|
+ letsencrypt
|
|
982
|
+ mutt
|
|
983
|
+ gpg
|
|
984
|
+ procmail
|
|
985
|
+ spamassassin
|
|
986
|
+ readme
|
|
987
|
+ ssh
|
|
988
|
+ userconfig
|
|
989
|
+ userlocal
|
|
990
|
+ userfin
|
|
991
|
+ certs
|
|
992
|
+ personal)
|
|
993
|
+
|
969
|
994
|
detect_apps
|
970
|
|
- applist="all"
|
|
995
|
+
|
|
996
|
+ app_list=()
|
|
997
|
+ AllStr=$"all"
|
971
|
998
|
n=1
|
|
999
|
+ applist="$n $AllStr off"
|
|
1000
|
+ n=$[n+1]
|
|
1001
|
+
|
|
1002
|
+ util_index=0
|
|
1003
|
+ for a in "${utils_installed[@]}"
|
|
1004
|
+ do
|
|
1005
|
+ applist="$applist $n $a off"
|
|
1006
|
+ app_name=${utils_installed[util_index]}
|
|
1007
|
+ n=$[n+1]
|
|
1008
|
+ util_index=$[util_index+1]
|
|
1009
|
+ app_list+=("$app_name")
|
|
1010
|
+ done
|
|
1011
|
+
|
972
|
1012
|
app_index=0
|
973
|
1013
|
for a in "${APPS_INSTALLED_NAMES[@]}"
|
974
|
1014
|
do
|
975
|
1015
|
applist="$applist $n $a off"
|
976
|
1016
|
n=$[n+1]
|
977
|
1017
|
app_index=$[app_index+1]
|
|
1018
|
+ app_name=${APPS_INSTALLED_NAMES[app_index]}
|
|
1019
|
+ app_list+=("$app_name")
|
978
|
1020
|
done
|
|
1021
|
+ ExitStr=$"Exit"
|
|
1022
|
+ applist="$applist $n $ExitStr on"
|
|
1023
|
+ n=$[n+1]
|
979
|
1024
|
|
980
|
1025
|
choices=$(dialog --stdout --backtitle $"Freedombone" \
|
981
|
1026
|
--title $"Restore apps" \
|
|
@@ -984,16 +1029,52 @@ function restore_from_usb {
|
984
|
1029
|
|
985
|
1030
|
if [ $? -eq 0 ]; then
|
986
|
1031
|
clear
|
987
|
|
- ctr=0
|
|
1032
|
+
|
|
1033
|
+ # Test for exit
|
988
|
1034
|
for choice in $choices
|
989
|
1035
|
do
|
990
|
1036
|
app_index=$[choice-1]
|
991
|
|
- app_name=${APPS_INSTALLED_NAMES[app_index]}
|
992
|
|
- if [[ "${app_name}" == 'all' ]]; then
|
993
|
|
- ${PROJECT_NAME}-restore-local $USB_DRIVE
|
994
|
|
- else
|
995
|
|
- ${PROJECT_NAME}-restore-local $USB_DRIVE "${app_name}"
|
|
1037
|
+ app_name=${app_list[app_index]}
|
|
1038
|
+ if [[ $app_name == "$ExitStr" ]]; then
|
|
1039
|
+ return
|
996
|
1040
|
fi
|
|
1041
|
+ done
|
|
1042
|
+
|
|
1043
|
+ # Test for restoring all apps
|
|
1044
|
+ for choice in $choices
|
|
1045
|
+ do
|
|
1046
|
+ app_index=$[choice-1]
|
|
1047
|
+ app_name=${app_list[app_index]}
|
|
1048
|
+ if [[ $app_name == "$AllStr" ]]; then
|
|
1049
|
+ $restore_command
|
|
1050
|
+ if [ ! "$?" = "0" ]; then
|
|
1051
|
+ if [[ "$1" == "local" ]]; then
|
|
1052
|
+ dialog --title $"Restore all apps from USB" \
|
|
1053
|
+ --msgbox $"Restore failed with code $?" 6 40
|
|
1054
|
+ else
|
|
1055
|
+ dialog --title $"Restore all apps from $1" \
|
|
1056
|
+ --msgbox $"Restore failed with code $?" 6 40
|
|
1057
|
+ fi
|
|
1058
|
+ return
|
|
1059
|
+ fi
|
|
1060
|
+
|
|
1061
|
+ if [[ "$1" == "local" ]]; then
|
|
1062
|
+ dialog --title $"Restore all apps from USB" \
|
|
1063
|
+ --msgbox $"Restore complete" 6 40
|
|
1064
|
+ else
|
|
1065
|
+ dialog --title $"Restore all apps from $1" \
|
|
1066
|
+ --msgbox $"Restore complete" 6 40
|
|
1067
|
+ fi
|
|
1068
|
+ return
|
|
1069
|
+ fi
|
|
1070
|
+ done
|
|
1071
|
+
|
|
1072
|
+ ctr=0
|
|
1073
|
+ for choice in $choices
|
|
1074
|
+ do
|
|
1075
|
+ app_index=$[choice-1]
|
|
1076
|
+ app_name=${app_list[app_index]}
|
|
1077
|
+ $restore_command "${app_name}"
|
997
|
1078
|
if [ ! "$?" = "0" ]; then
|
998
|
1079
|
dialog --title $"Restore apps from USB" \
|
999
|
1080
|
--msgbox $"Restore of ${app_name} failed with code $?" 6 40
|
|
@@ -1002,95 +1083,16 @@ function restore_from_usb {
|
1002
|
1083
|
ctr=$((ctr + 1))
|
1003
|
1084
|
done
|
1004
|
1085
|
if [ $ctr -gt 0 ]; then
|
1005
|
|
- dialog --title $"Restore apps from USB" \
|
1006
|
|
- --msgbox $"Restore complete" 6 40
|
|
1086
|
+ if [[ "$1" == "local" ]]; then
|
|
1087
|
+ dialog --title $"Restore apps from USB" \
|
|
1088
|
+ --msgbox $"Restore complete" 6 40
|
|
1089
|
+ else
|
|
1090
|
+ dialog --title $"Restore apps from $1" \
|
|
1091
|
+ --msgbox $"Restore complete" 6 40
|
|
1092
|
+ fi
|
|
1093
|
+ return
|
1007
|
1094
|
fi
|
1008
|
1095
|
fi
|
1009
|
|
-}
|
1010
|
|
-
|
1011
|
|
-function restore_from_remote {
|
1012
|
|
- remote_domain_name=$1
|
1013
|
|
-
|
1014
|
|
- while true
|
1015
|
|
- do
|
1016
|
|
- data=$(tempfile 2>/dev/null)
|
1017
|
|
- trap "rm -f $data" 0 1 2 5 15
|
1018
|
|
- dialog --backtitle $"Freedombone Control Panel" \
|
1019
|
|
- --title $"Restore from ${remote_domain_name}" \
|
1020
|
|
- --radiolist $"Choose an application to restore:" 31 70 28 \
|
1021
|
|
- 1 $"Everything" off \
|
1022
|
|
- 2 $"Return to the backup and restore menu" on \
|
1023
|
|
- 3 $"Configuration files" off \
|
1024
|
|
- 4 $"MariaDB settings" off \
|
1025
|
|
- 5 $"Let's Encrypt account" off \
|
1026
|
|
- 6 $"Mutt email client settings" off \
|
1027
|
|
- 7 $"GPG keys" off \
|
1028
|
|
- 8 $"Email processing rules" off \
|
1029
|
|
- 9 $"Spam filtering rules" off \
|
1030
|
|
- 10 $"Administrator's README file" off \
|
1031
|
|
- 11 $"IPFS" off \
|
1032
|
|
- 12 $"SSH keys" off \
|
1033
|
|
- 13 $"User configuration files" off \
|
1034
|
|
- 14 $"User local files" off \
|
1035
|
|
- 15 $"User fin files" off \
|
1036
|
|
- 16 $"SSL/TLS certificates" off \
|
1037
|
|
- 17 $"Personal settings" off \
|
1038
|
|
- 18 $"Mailing List" off \
|
1039
|
|
- 19 $"XMPP chat" off \
|
1040
|
|
- 20 $"GNU Social" off \
|
1041
|
|
- 21 $"Hubzilla" off \
|
1042
|
|
- 22 $"Syncthing" off \
|
1043
|
|
- 23 $"Gogs" off \
|
1044
|
|
- 24 $"Wiki" off \
|
1045
|
|
- 25 $"Blog" off \
|
1046
|
|
- 26 $"Email" off \
|
1047
|
|
- 27 $"DLNA" off \
|
1048
|
|
- 28 $"Mumble" off \
|
1049
|
|
- 29 $"RSS reader" off \
|
1050
|
|
- 30 $"Tox" off 2> $data
|
1051
|
|
- sel=$?
|
1052
|
|
- case $sel in
|
1053
|
|
- 1) break;;
|
1054
|
|
- 255) break;;
|
1055
|
|
- esac
|
1056
|
|
-
|
1057
|
|
- if [ $(cat $data) -ne 2 ]; then
|
1058
|
|
- clear
|
1059
|
|
- fi
|
1060
|
|
-
|
1061
|
|
- case $(cat $data) in
|
1062
|
|
- 1) ${PROJECT_NAME}-restore-remote $remote_domain_name;;
|
1063
|
|
- 2) return;;
|
1064
|
|
- 3) ${PROJECT_NAME}-restore-remote $remote_domain_name configuration;;
|
1065
|
|
- 4) ${PROJECT_NAME}-restore-remote $remote_domain_name mariadb;;
|
1066
|
|
- 5) ${PROJECT_NAME}-restore-remote $remote_domain_name letsencrypt;;
|
1067
|
|
- 6) ${PROJECT_NAME}-restore-remote $remote_domain_name mutt;;
|
1068
|
|
- 7) ${PROJECT_NAME}-restore-remote $remote_domain_name gpg;;
|
1069
|
|
- 8) ${PROJECT_NAME}-restore-remote $remote_domain_name procmail;;
|
1070
|
|
- 9) ${PROJECT_NAME}-restore-remote $remote_domain_name spamassassin;;
|
1071
|
|
- 10) ${PROJECT_NAME}-restore-remote $remote_domain_name readme;;
|
1072
|
|
- 11) ${PROJECT_NAME}-restore-remote $remote_domain_name ipfs;;
|
1073
|
|
- 12) ${PROJECT_NAME}-restore-remote $remote_domain_name ssh;;
|
1074
|
|
- 13) ${PROJECT_NAME}-restore-remote $remote_domain_name userconfig;;
|
1075
|
|
- 14) ${PROJECT_NAME}-restore-remote $remote_domain_name userlocal;;
|
1076
|
|
- 15) ${PROJECT_NAME}-restore-remote $remote_domain_name userfin;;
|
1077
|
|
- 16) ${PROJECT_NAME}-restore-remote $remote_domain_name certs;;
|
1078
|
|
- 17) ${PROJECT_NAME}-restore-remote $remote_domain_name personal;;
|
1079
|
|
- 18) ${PROJECT_NAME}-restore-remote $remote_domain_name mailinglist;;
|
1080
|
|
- 19) ${PROJECT_NAME}-restore-remote $remote_domain_name xmpp;;
|
1081
|
|
- 20) ${PROJECT_NAME}-restore-remote $remote_domain_name gnusocial;;
|
1082
|
|
- 21) ${PROJECT_NAME}-restore-remote $remote_domain_name hubzilla;;
|
1083
|
|
- 22) ${PROJECT_NAME}-restore-remote $remote_domain_name syncthing;;
|
1084
|
|
- 23) ${PROJECT_NAME}-restore-remote $remote_domain_name gogs;;
|
1085
|
|
- 24) ${PROJECT_NAME}-restore-remote $remote_domain_name wiki;;
|
1086
|
|
- 25) ${PROJECT_NAME}-restore-remote $remote_domain_name blog;;
|
1087
|
|
- 26) ${PROJECT_NAME}-restore-remote $remote_domain_name email;;
|
1088
|
|
- 27) ${PROJECT_NAME}-restore-remote $remote_domain_name dlna;;
|
1089
|
|
- 28) ${PROJECT_NAME}-restore-remote $remote_domain_name mumble;;
|
1090
|
|
- 29) ${PROJECT_NAME}-restore-remote $remote_domain_name ttrss;;
|
1091
|
|
- 30) ${PROJECT_NAME}-restore-remote $remote_domain_name tox;;
|
1092
|
|
- esac
|
1093
|
|
- done
|
1094
|
1096
|
any_key
|
1095
|
1097
|
}
|
1096
|
1098
|
|
|
@@ -1100,7 +1102,7 @@ function restore_data {
|
1100
|
1102
|
clear
|
1101
|
1103
|
echo ' '
|
1102
|
1104
|
echo $'Enter the passphrase for your LUKS encrypted backup drive:'
|
1103
|
|
- restore_from_usb
|
|
1105
|
+ restore_data_from_storage local
|
1104
|
1106
|
}
|
1105
|
1107
|
|
1106
|
1108
|
function restore_data_remote {
|
|
@@ -1129,7 +1131,7 @@ function restore_data_remote {
|
1129
|
1131
|
return
|
1130
|
1132
|
fi
|
1131
|
1133
|
|
1132
|
|
- restore_from_remote $friend_server_domain_name
|
|
1134
|
+ restore_data_from_storage $friend_server_domain_name
|
1133
|
1135
|
;;
|
1134
|
1136
|
esac
|
1135
|
1137
|
}
|