|
@@ -13,7 +13,7 @@
|
13
|
13
|
# License
|
14
|
14
|
# =======
|
15
|
15
|
#
|
16
|
|
-# Copyright (C) 2016 Bob Mottram <bob@freedombone.net>
|
|
16
|
+# Copyright (C) 2016-2017 Bob Mottram <bob@freedombone.net>
|
17
|
17
|
#
|
18
|
18
|
# This program is free software: you can redistribute it and/or modify
|
19
|
19
|
# it under the terms of the GNU Affero General Public License as published by
|
|
@@ -37,7 +37,7 @@ MAILPILE_DOMAIN_NAME=
|
37
|
37
|
MAILPILE_CODE=
|
38
|
38
|
MAILPILE_ONION_PORT=8103
|
39
|
39
|
MAILPILE_REPO="https://github.com/mailpile/Mailpile"
|
40
|
|
-MAILPILE_COMMIT='6f56fe4ad736c8e385bea658454bed110d08c60d'
|
|
40
|
+MAILPILE_COMMIT='88ae8e5831dddc628c827c44224166dbdbed91f1'
|
41
|
41
|
MAILPILE_PORT=33411
|
42
|
42
|
|
43
|
43
|
mailpile_variables=(MAILPILE_REPO
|
|
@@ -45,6 +45,7 @@ mailpile_variables=(MAILPILE_REPO
|
45
|
45
|
MAILPILE_CODE
|
46
|
46
|
ONION_ONLY
|
47
|
47
|
DDNS_PROVIDER
|
|
48
|
+ DEFAULT_DOMAIN_NAME
|
48
|
49
|
MY_USERNAME)
|
49
|
50
|
|
50
|
51
|
function logging_on_mailpile {
|
|
@@ -109,118 +110,19 @@ function upgrade_mailpile {
|
109
|
110
|
}
|
110
|
111
|
|
111
|
112
|
function backup_local_mailpile {
|
112
|
|
- if [ ! -f /etc/systemd/system/mailpile.service ]; then
|
113
|
|
- return
|
114
|
|
- fi
|
115
|
|
- MAILPILE_DOMAIN_NAME='mailpile.local'
|
116
|
|
- if grep -q "mailpile domain" $COMPLETION_FILE; then
|
117
|
|
- MAILPILE_DOMAIN_NAME=$(get_completion_param "mailpile domain")
|
118
|
|
- fi
|
119
|
|
- source_directory=/var/www/${MAILPILE_DOMAIN_NAME}/mail/.local
|
120
|
|
- if [ -d $source_directory ]; then
|
121
|
|
- systemctl stop mailpile
|
122
|
|
-
|
123
|
|
- function_check backup_directory_to_usb
|
124
|
|
- backup_directory_to_usb $source_directory mailpile
|
125
|
|
-
|
126
|
|
- systemctl start mailpile
|
127
|
|
- fi
|
|
113
|
+ echo -n ''
|
128
|
114
|
}
|
129
|
115
|
|
130
|
116
|
function restore_local_mailpile {
|
131
|
|
- if [ ! -f /etc/systemd/system/mailpile.service ]; then
|
132
|
|
- return
|
133
|
|
- fi
|
134
|
|
- MAILPILE_DOMAIN_NAME='mailpile.local'
|
135
|
|
- if grep -q "mailpile domain" $COMPLETION_FILE; then
|
136
|
|
- MAILPILE_DOMAIN_NAME=$(get_completion_param "mailpile domain")
|
137
|
|
- fi
|
138
|
|
- if [ $MAILPILE_DOMAIN_NAME ]; then
|
139
|
|
- systemctl stop mailpile
|
140
|
|
-
|
141
|
|
- temp_restore_dir=/root/tempmailpile
|
142
|
|
- restore_directory_from_usb $temp_restore_dir mailpile
|
143
|
|
- if [ -d /var/www/${MAILPILE_DOMAIN_NAME}/mail/.local ]; then
|
144
|
|
- mv /var/www/${MAILPILE_DOMAIN_NAME}/mail/.local /var/www/${MAILPILE_DOMAIN_NAME}/mail/.previous
|
145
|
|
- fi
|
146
|
|
- temp_source_dir=$(find ${temp_restore_dir} -name ".local")
|
147
|
|
- cp -r ${temp_source_dir} /var/www/${MAILPILE_DOMAIN_NAME}/mail/
|
148
|
|
- if [ ! "$?" = "0" ]; then
|
149
|
|
- if [ -d mv /var/www/${MAILPILE_DOMAIN_NAME}/mail/.previous ]; then
|
150
|
|
- if [ -d /var/www/${MAILPILE_DOMAIN_NAME}/mail/.previous ]; then
|
151
|
|
- rm -rf /var/www/${MAILPILE_DOMAIN_NAME}/mail/.previous
|
152
|
|
- fi
|
153
|
|
- mv /var/www/${MAILPILE_DOMAIN_NAME}/mail/.previous /var/www/${MAILPILE_DOMAIN_NAME}/mail/.local
|
154
|
|
- fi
|
155
|
|
- backup_unmount_drive
|
156
|
|
- exit 3685
|
157
|
|
- fi
|
158
|
|
- rm -rf ${temp_restore_dir}
|
159
|
|
- chown -R mailpile: /var/www/$MAILPILE_DOMAIN_NAME/mail/
|
160
|
|
-
|
161
|
|
- if [ -d /etc/letsencrypt/live/${MAILPILE_DOMAIN_NAME} ]; then
|
162
|
|
- ln -s /etc/letsencrypt/live/${MAILPILE_DOMAIN_NAME}/privkey.pem /etc/ssl/private/${MAILPILE_DOMAIN_NAME}.key
|
163
|
|
- ln -s /etc/letsencrypt/live/${MAILPILE_DOMAIN_NAME}/fullchain.pem /etc/ssl/certs/${MAILPILE_DOMAIN_NAME}.pem
|
164
|
|
- fi
|
165
|
|
-
|
166
|
|
- systemctl start mailpile
|
167
|
|
- fi
|
|
117
|
+ echo -n ''
|
168
|
118
|
}
|
169
|
119
|
|
170
|
120
|
function backup_remote_mailpile {
|
171
|
|
- if [ ! -f /etc/systemd/system/mailpile.service ]; then
|
172
|
|
- return
|
173
|
|
- fi
|
174
|
|
- MAILPILE_DOMAIN_NAME='mailpile.local'
|
175
|
|
- if grep -q "mailpile domain" $COMPLETION_FILE; then
|
176
|
|
- MAILPILE_DOMAIN_NAME=$(get_completion_param "mailpile domain")
|
177
|
|
- fi
|
178
|
|
- source_directory=/var/www/${MAILPILE_DOMAIN_NAME}/mail/.local
|
179
|
|
- if [ -d $source_directory ]; then
|
180
|
|
- systemctl stop mailpile
|
181
|
|
-
|
182
|
|
- function_check backup_directory_to_usb
|
183
|
|
- backup_directory_to_friend $source_directory mailpile
|
184
|
|
-
|
185
|
|
- systemctl start mailpile
|
186
|
|
- fi
|
|
121
|
+ echo -n ''
|
187
|
122
|
}
|
188
|
123
|
|
189
|
124
|
function restore_remote_mailpile {
|
190
|
|
- if [ ! -f /etc/systemd/system/mailpile.service ]; then
|
191
|
|
- return
|
192
|
|
- fi
|
193
|
|
- MAILPILE_DOMAIN_NAME='mailpile.local'
|
194
|
|
- if grep -q "mailpile domain" $COMPLETION_FILE; then
|
195
|
|
- MAILPILE_DOMAIN_NAME=$(get_completion_param "mailpile domain")
|
196
|
|
- fi
|
197
|
|
- if [ $MAILPILE_DOMAIN_NAME ]; then
|
198
|
|
- systemctl stop mailpile
|
199
|
|
-
|
200
|
|
- temp_restore_dir=/root/tempmailpile
|
201
|
|
- restore_directory_from_friend $temp_restore_dir mailpile
|
202
|
|
- if [ -d /var/www/${MAILPILE_DOMAIN_NAME}/mail/.local ]; then
|
203
|
|
- mv /var/www/${MAILPILE_DOMAIN_NAME}/mail/.local /var/www/${MAILPILE_DOMAIN_NAME}/mail/.previous
|
204
|
|
- fi
|
205
|
|
- temp_source_dir=$(find ${temp_restore_dir} -name ".local")
|
206
|
|
- cp -r ${temp_source_dir} /var/www/${MAILPILE_DOMAIN_NAME}/mail/
|
207
|
|
- if [ ! "$?" = "0" ]; then
|
208
|
|
- if [ -d mv /var/www/${MAILPILE_DOMAIN_NAME}/mail/.previous ]; then
|
209
|
|
- mv /var/www/${MAILPILE_DOMAIN_NAME}/mail/.previous /var/www/${MAILPILE_DOMAIN_NAME}/mail/.local
|
210
|
|
- fi
|
211
|
|
- backup_unmount_drive
|
212
|
|
- exit 36732
|
213
|
|
- fi
|
214
|
|
- rm -rf ${temp_restore_dir}
|
215
|
|
- chown -R mailpile: /var/www/$MAILPILE_DOMAIN_NAME/mail/
|
216
|
|
-
|
217
|
|
- if [ -d /etc/letsencrypt/live/${MAILPILE_DOMAIN_NAME} ]; then
|
218
|
|
- ln -s /etc/letsencrypt/live/${MAILPILE_DOMAIN_NAME}/privkey.pem /etc/ssl/private/${MAILPILE_DOMAIN_NAME}.key
|
219
|
|
- ln -s /etc/letsencrypt/live/${MAILPILE_DOMAIN_NAME}/fullchain.pem /etc/ssl/certs/${MAILPILE_DOMAIN_NAME}.pem
|
220
|
|
- fi
|
221
|
|
-
|
222
|
|
- systemctl start mailpile
|
223
|
|
- fi
|
|
125
|
+ echo -n ''
|
224
|
126
|
}
|
225
|
127
|
|
226
|
128
|
function remove_mailpile {
|
|
@@ -305,6 +207,11 @@ function install_mailpile {
|
305
|
207
|
adduser mailpile www-data
|
306
|
208
|
adduser mailpile mail
|
307
|
209
|
adduser mailpile $MY_USERNAME
|
|
210
|
+ if [[ $ONION_ONLY == 'no' ]]; then
|
|
211
|
+ chgrp -R ssl-cert /etc/letsencrypt
|
|
212
|
+ chmod -R g=rX /etc/letsencrypt
|
|
213
|
+ usermod -a -G ssl-cert mailpile
|
|
214
|
+ fi
|
308
|
215
|
chown -R mailpile: /var/www/$MAILPILE_DOMAIN_NAME/mail/
|
309
|
216
|
|
310
|
217
|
# create folders and tags
|
|
@@ -440,6 +347,17 @@ function install_mailpile {
|
440
|
347
|
pip install jinja2==2.9.6
|
441
|
348
|
pip install pgpdump==1.5
|
442
|
349
|
|
|
350
|
+ # turn off ssl in dovecot
|
|
351
|
+ sed -i 's|#ssl =.*|ssl = no|g' /etc/dovecot/conf.d/10-ssl.conf
|
|
352
|
+ sed -i 's|ssl =.*|ssl = no|g' /etc/dovecot/conf.d/10-ssl.conf
|
|
353
|
+
|
|
354
|
+ # set ssl certs, just in case we want to use them later
|
|
355
|
+ sed -i "s|#ssl_cert =.*|ssl_cert = </etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.crt|g" /etc/dovecot/conf.d/10-ssl.conf
|
|
356
|
+ sed -i "s|ssl_cert =.*|ssl_cert = </etc/ssl/certs/${DEFAULT_DOMAIN_NAME}.crt|g" /etc/dovecot/conf.d/10-ssl.conf
|
|
357
|
+ sed -i "s|#ssl_key =.*|ssl_key = </etc/ssl/private/${DEFAULT_DOMAIN_NAME}.key|g" /etc/dovecot/conf.d/10-ssl.conf
|
|
358
|
+ sed -i "s|ssl_key =.*|ssl_key = </etc/ssl/private/${DEFAULT_DOMAIN_NAME}.key|g" /etc/dovecot/conf.d/10-ssl.conf
|
|
359
|
+
|
|
360
|
+ systemctl restart dovecot
|
443
|
361
|
systemctl enable mailpile
|
444
|
362
|
systemctl daemon-reload
|
445
|
363
|
systemctl start mailpile
|