|
@@ -87,19 +87,115 @@ function upgrade_mailpile {
|
87
|
87
|
}
|
88
|
88
|
|
89
|
89
|
function backup_local_mailpile {
|
90
|
|
- echo -n ''
|
|
90
|
+ if [ ! -f /etc/systemd/system/mailpile.service ]; then
|
|
91
|
+ return
|
|
92
|
+ fi
|
|
93
|
+ MAILPILE_DOMAIN_NAME='mailpile.local'
|
|
94
|
+ if grep -q "mailpile domain" $COMPLETION_FILE; then
|
|
95
|
+ MAILPILE_DOMAIN_NAME=$(get_completion_param "mailpile domain")
|
|
96
|
+ fi
|
|
97
|
+ source_directory=/var/www/${MAILPILE_DOMAIN_NAME}/mail/.local
|
|
98
|
+ if [ -d $source_directory ]; then
|
|
99
|
+ systemctl stop mailpile
|
|
100
|
+
|
|
101
|
+ function_check backup_directory_to_usb
|
|
102
|
+ backup_directory_to_usb $source_directory mailpile
|
|
103
|
+
|
|
104
|
+ systemctl start mailpile
|
|
105
|
+ fi
|
91
|
106
|
}
|
92
|
107
|
|
93
|
108
|
function restore_local_mailpile {
|
94
|
|
- echo -n ''
|
|
109
|
+ if [ ! -f /etc/systemd/system/mailpile.service ]; then
|
|
110
|
+ return
|
|
111
|
+ fi
|
|
112
|
+ MAILPILE_DOMAIN_NAME='mailpile.local'
|
|
113
|
+ if grep -q "mailpile domain" $COMPLETION_FILE; then
|
|
114
|
+ MAILPILE_DOMAIN_NAME=$(get_completion_param "mailpile domain")
|
|
115
|
+ fi
|
|
116
|
+ if [ $MAILPILE_DOMAIN_NAME ]; then
|
|
117
|
+ systemctl stop mailpile
|
|
118
|
+
|
|
119
|
+ temp_restore_dir=/root/tempmailpile
|
|
120
|
+ restore_directory_from_usb $temp_restore_dir mailpile
|
|
121
|
+ if [ -d /var/www/${MAILPILE_DOMAIN_NAME}/mail/.local ]; then
|
|
122
|
+ mv /var/www/${MAILPILE_DOMAIN_NAME}/mail/.local /var/www/${MAILPILE_DOMAIN_NAME}/mail/.previous
|
|
123
|
+ fi
|
|
124
|
+ temp_source_dir=$(find ${temp_restore_dir} -name ".local")
|
|
125
|
+ cp -r ${temp_source_dir} /var/www/${MAILPILE_DOMAIN_NAME}/mail/
|
|
126
|
+ if [ ! "$?" = "0" ]; then
|
|
127
|
+ if [ -d mv /var/www/${MAILPILE_DOMAIN_NAME}/mail/.previous ]; then
|
|
128
|
+ mv /var/www/${MAILPILE_DOMAIN_NAME}/mail/.previous /var/www/${MAILPILE_DOMAIN_NAME}/mail/.local
|
|
129
|
+ fi
|
|
130
|
+ backup_unmount_drive
|
|
131
|
+ exit 3685
|
|
132
|
+ fi
|
|
133
|
+ rm -rf ${temp_restore_dir}
|
|
134
|
+ chown -R mailpile: /var/www/$MAILPILE_DOMAIN_NAME/mail/
|
|
135
|
+
|
|
136
|
+ if [ -d /etc/letsencrypt/live/${MAILPILE_DOMAIN_NAME} ]; then
|
|
137
|
+ ln -s /etc/letsencrypt/live/${MAILPILE_DOMAIN_NAME}/privkey.pem /etc/ssl/private/${MAILPILE_DOMAIN_NAME}.key
|
|
138
|
+ ln -s /etc/letsencrypt/live/${MAILPILE_DOMAIN_NAME}/fullchain.pem /etc/ssl/certs/${MAILPILE_DOMAIN_NAME}.pem
|
|
139
|
+ fi
|
|
140
|
+
|
|
141
|
+ systemctl start mailpile
|
|
142
|
+ fi
|
95
|
143
|
}
|
96
|
144
|
|
97
|
145
|
function backup_remote_mailpile {
|
98
|
|
- echo -n ''
|
|
146
|
+ if [ ! -f /etc/systemd/system/mailpile.service ]; then
|
|
147
|
+ return
|
|
148
|
+ fi
|
|
149
|
+ MAILPILE_DOMAIN_NAME='mailpile.local'
|
|
150
|
+ if grep -q "mailpile domain" $COMPLETION_FILE; then
|
|
151
|
+ MAILPILE_DOMAIN_NAME=$(get_completion_param "mailpile domain")
|
|
152
|
+ fi
|
|
153
|
+ source_directory=/var/www/${MAILPILE_DOMAIN_NAME}/mail/.local
|
|
154
|
+ if [ -d $source_directory ]; then
|
|
155
|
+ systemctl stop mailpile
|
|
156
|
+
|
|
157
|
+ function_check backup_directory_to_usb
|
|
158
|
+ backup_directory_to_friend $source_directory mailpile
|
|
159
|
+
|
|
160
|
+ systemctl start mailpile
|
|
161
|
+ fi
|
99
|
162
|
}
|
100
|
163
|
|
101
|
164
|
function restore_remote_mailpile {
|
102
|
|
- echo -n ''
|
|
165
|
+ if [ ! -f /etc/systemd/system/mailpile.service ]; then
|
|
166
|
+ return
|
|
167
|
+ fi
|
|
168
|
+ MAILPILE_DOMAIN_NAME='mailpile.local'
|
|
169
|
+ if grep -q "mailpile domain" $COMPLETION_FILE; then
|
|
170
|
+ MAILPILE_DOMAIN_NAME=$(get_completion_param "mailpile domain")
|
|
171
|
+ fi
|
|
172
|
+ if [ $MAILPILE_DOMAIN_NAME ]; then
|
|
173
|
+ systemctl stop mailpile
|
|
174
|
+
|
|
175
|
+ temp_restore_dir=/root/tempmailpile
|
|
176
|
+ restore_directory_from_friend $temp_restore_dir mailpile
|
|
177
|
+ if [ -d /var/www/${MAILPILE_DOMAIN_NAME}/mail/.local ]; then
|
|
178
|
+ mv /var/www/${MAILPILE_DOMAIN_NAME}/mail/.local /var/www/${MAILPILE_DOMAIN_NAME}/mail/.previous
|
|
179
|
+ fi
|
|
180
|
+ temp_source_dir=$(find ${temp_restore_dir} -name ".local")
|
|
181
|
+ cp -r ${temp_source_dir} /var/www/${MAILPILE_DOMAIN_NAME}/mail/
|
|
182
|
+ if [ ! "$?" = "0" ]; then
|
|
183
|
+ if [ -d mv /var/www/${MAILPILE_DOMAIN_NAME}/mail/.previous ]; then
|
|
184
|
+ mv /var/www/${MAILPILE_DOMAIN_NAME}/mail/.previous /var/www/${MAILPILE_DOMAIN_NAME}/mail/.local
|
|
185
|
+ fi
|
|
186
|
+ backup_unmount_drive
|
|
187
|
+ exit 36732
|
|
188
|
+ fi
|
|
189
|
+ rm -rf ${temp_restore_dir}
|
|
190
|
+ chown -R mailpile: /var/www/$MAILPILE_DOMAIN_NAME/mail/
|
|
191
|
+
|
|
192
|
+ if [ -d /etc/letsencrypt/live/${MAILPILE_DOMAIN_NAME} ]; then
|
|
193
|
+ ln -s /etc/letsencrypt/live/${MAILPILE_DOMAIN_NAME}/privkey.pem /etc/ssl/private/${MAILPILE_DOMAIN_NAME}.key
|
|
194
|
+ ln -s /etc/letsencrypt/live/${MAILPILE_DOMAIN_NAME}/fullchain.pem /etc/ssl/certs/${MAILPILE_DOMAIN_NAME}.pem
|
|
195
|
+ fi
|
|
196
|
+
|
|
197
|
+ systemctl start mailpile
|
|
198
|
+ fi
|
103
|
199
|
}
|
104
|
200
|
|
105
|
201
|
function remove_mailpile {
|