Просмотр исходного кода

Move xmpp local restore to app script

Bob Mottram 8 лет назад
Родитель
Сommit
9ffb0fe508
3 измененных файлов: 53 добавлений и 44 удалений
  1. 28
    0
      src/freedombone-app-ipfs
  2. 25
    0
      src/freedombone-app-xmpp
  3. 0
    44
      src/freedombone-restore-local

+ 28
- 0
src/freedombone-app-ipfs Просмотреть файл

@@ -63,10 +63,38 @@ function backup_local_ipfs {
63 63
 	fi
64 64
 }
65 65
 
66
+function restore_local_ipfs {
67
+	if ! grep -q "Admin user" $COMPLETION_FILE; then
68
+		return
69
+	fi
70
+	if [ -d $USB_MOUNT/backup/ipfs ]; then
71
+		echo $"Restoring IPFS"
72
+		temp_restore_dir=/root/tempipfs
73
+		function_check restore_directory_from_usb
74
+		restore_directory_from_usb $temp_restore_dir ipfs
75
+		ADMIN_USERNAME=$(cat $COMPLETION_FILE | grep "Admin user" | awk -F ':' '{print $2}')
76
+		cp -rf $temp_restore_dir/home/$ADMIN_USERNAME/.ipfs/* /home/$ADMIN_USERNAME/.ipfs
77
+		if [ ! "$?" = "0" ]; then
78
+			rm -rf $temp_restore_dir
79
+			function_check set_user_permissions
80
+			set_user_permissions
81
+			function_check backup_unmount_drive
82
+			backup_unmount_drive
83
+			exit 27627
84
+		fi
85
+		rm -rf $temp_restore_dir
86
+		echo $"Restore of IPFS complete"
87
+	fi
88
+}
89
+
66 90
 function backup_remote_ipfs {
67 91
 	echo -n ''
68 92
 }
69 93
 
94
+function restore_remote_ipfs {
95
+	echo -n ''
96
+}
97
+
70 98
 function remove_ipfs {
71 99
 	if ! grep -Fxq "install_ipfs" $COMPLETION_FILE; then
72 100
 		return

+ 25
- 0
src/freedombone-app-xmpp Просмотреть файл

@@ -116,10 +116,35 @@ function backup_local_xmpp {
116 116
 	fi
117 117
 }
118 118
 
119
+function restore_local_xmpp {
120
+	if [ -d /var/lib/prosody ]; then
121
+		echo $"Restoring XMPP settings"
122
+		temp_restore_dir=/root/tempxmpp
123
+		function_check restore_directory_from_usb
124
+		restore_directory_from_usb $temp_restore_dir xmpp
125
+		cp -r $temp_restore_dir/var/lib/prosody/* /var/lib/prosody
126
+		if [ ! "$?" = "0" ]; then
127
+			function_check set_user_permissions
128
+			set_user_permissions
129
+			function_check backup_unmount_drive
130
+			backup_unmount_drive
131
+			exit 725
132
+		fi
133
+		rm -rf $temp_restore_dir
134
+		service prosody restart
135
+		chown -R prosody:prosody /var/lib/prosody/*
136
+		echo $"Restore of XMPP settings complete"
137
+	fi
138
+}
139
+
119 140
 function backup_remote_xmpp {
120 141
 	echo -n ''
121 142
 }
122 143
 
144
+function restore_remote_xmpp {
145
+	echo -n ''
146
+}
147
+
123 148
 function configure_firewall_for_xmpp {
124 149
 	if [ ! -d /etc/prosody ]; then
125 150
 		return

+ 0
- 44
src/freedombone-restore-local Просмотреть файл

@@ -491,26 +491,6 @@ function restore_admin_readme {
491 491
     fi
492 492
 }
493 493
 
494
-function restore_ipfs {
495
-    if [[ $RESTORE_APP != 'all' ]]; then
496
-        if [[ $RESTORE_APP != 'ipfs' ]]; then
497
-            return
498
-        fi
499
-    fi
500
-    if [ -d $USB_MOUNT/backup/ipfs ]; then
501
-        echo $"Restoring IPFS"
502
-        restore_directory_from_usb /root/tempipfs ipfs
503
-        cp -rf /root/tempipfs/home/$ADMIN_USERNAME/.ipfs/* /home/$ADMIN_USERNAME/.ipfs
504
-        if [ ! "$?" = "0" ]; then
505
-            rm -rf /root/tempipfs
506
-            set_user_permissions
507
-            backup_unmount_drive
508
-            exit 276
509
-        fi
510
-        rm -rf /root/tempipfs
511
-    fi
512
-}
513
-
514 494
 function restore_user_ssh_keys {
515 495
     if [[ $RESTORE_APP != 'all' ]]; then
516 496
         if [[ $RESTORE_APP != 'ssh' ]]; then
@@ -797,27 +777,6 @@ function restore_mailing_list {
797 777
     fi
798 778
 }
799 779
 
800
-function restore_xmpp {
801
-    if [[ $RESTORE_APP != 'all' ]]; then
802
-        if [[ $RESTORE_APP != 'xmpp' ]]; then
803
-            return
804
-        fi
805
-    fi
806
-    if [ -d /var/lib/prosody ]; then
807
-        echo $"Restoring XMPP settings"
808
-        restore_directory_from_usb /root/tempxmpp xmpp
809
-        cp -r /root/tempxmpp/var/lib/prosody/* /var/lib/prosody
810
-        if [ ! "$?" = "0" ]; then
811
-            set_user_permissions
812
-            backup_unmount_drive
813
-            exit 725
814
-        fi
815
-        rm -rf /root/tempxmpp
816
-        service prosody restart
817
-        chown -R prosody:prosody /var/lib/prosody/*
818
-    fi
819
-}
820
-
821 780
 function restore_email {
822 781
     if [[ $RESTORE_APP != 'all' ]]; then
823 782
         if [[ $RESTORE_APP != 'email' ]]; then
@@ -905,9 +864,6 @@ restore_certs
905 864
 restore_personal_settings
906 865
 restore_mailing_list
907 866
 
908
-restore_ipfs
909
-restore_xmpp
910
-
911 867
 restore_email
912 868
 restore_apps
913 869
 set_user_permissions