-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathMakefile
396 lines (293 loc) · 11.4 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
-include *.mk .env .init.env
SRV_LIST ?= auth app db mta
AD_DOM ?= $(call ad_sub_dot, $(AD_BASE))
AD_DC ?= $(call ad_cut_dot, 1, 1, $(AD_DOM))
SSL_O = $(MAIL_DOMAIN)
SSL_MAIL = auto
SSL_PASS = $(AD_USR_PW)
#SSL_TRST = $(SSL_SMIME)
CURL_OPT ?= -v -s
variables:
make -pn | grep -A1 "^# makefile"| grep -v "^#\|^--" | sort | uniq
test: all-test_quiet mta-test_smtp
init: up auth-init db-init app-down app-up mta-init app-init
ps:
docker-compose ps
up:
docker-compose up -d
down:
docker-compose down
destroy: auth-gui-down db-gui-down all-destroy_smime
docker-compose down -v
config:
docker-compose config
logs:
docker-compose logs --tail 10
images:
docker-compose images
$(addsuffix -up,$(SRV_LIST)):
docker-compose up -d $(patsubst %-up,%,$@)
$(addsuffix -down,$(SRV_LIST)):
docker-compose rm -sf $(patsubst %-down,%,$@)
$(addsuffix -restart,$(SRV_LIST)):
docker-compose restart $(patsubst %-restart,%,$@)
$(addsuffix -renew,$(SRV_LIST)):
docker-compose rm -s $(patsubst %-renew,%,$@)
docker-compose up -d $(patsubst %-renew,%,$@)
$(addsuffix -top,$(SRV_LIST)):
docker-compose top $(patsubst %-top,%,$@)
$(addsuffix -logs,$(SRV_LIST)):
docker-compose logs $(patsubst %-logs,%,$@)
$(addsuffix -pull,$(SRV_LIST)):
docker-compose pull $(patsubst %-pull,%,$@)
$(addsuffix -sh,$(SRV_LIST)):
docker-compose exec $(patsubst %-sh,%,$@) sh -c 'exec $$(getent passwd root | sed "s/.*://g")'
$(addsuffix -env,$(SRV_LIST)):
docker-compose exec $(patsubst %-env,%,$@) env
$(addsuffix -sv,$(SRV_LIST)):
docker-compose exec $(patsubst %-sv,%,$@) sh -c 'sv status $$SVDIR/*'
$(addsuffix -diff,$(SRV_LIST)):
docker container diff $(COMPOSE_PROJECT_NAME)_$(patsubst %-diff,%,$@)_1
$(addsuffix -hostaddr,$(SRV_LIST)):
$(eval myhost := $(call dkr_srv_ip,$(patsubst %-hostaddr,%,$@)))
wait_%:
sleep $*
web:
browse http://localhost:8008 &
auth-init: wait_3 auth-mod_conf auth-add_schema auth-add_data
export define LDIF_MOD_CONF
dn: olcDatabase={-1}frontend,cn=config
changetype: modify
add: olcPasswordHash
olcPasswordHash: {CRYPT}
dn: cn=config
changetype: modify
add: olcPasswordCryptSaltFormat
olcPasswordCryptSaltFormat: $$6$$%.16s
dn: olcDatabase={1}mdb,cn=config
changetype: modify
add: olcDbIndex
olcDbIndex: cn,ou,uid,mail eq
endef
export define LDIF_ADD_DATA
dn: $(AD_BASE)
objectClass: organization
objectClass: dcObject
dc: $(AD_DC)
o: $(AD_DOM)
dn: ou=$(AD_USR_OU),$(AD_BASE)
ou: $(AD_USR_OU)
objectClass: organizationalUnit
dn: ou=$(AD_GRP_OU),$(AD_BASE)
ou: $(AD_GRP_OU)
objectClass: organizationalUnit
dn: cn=$(AD_GRP_CN),ou=$(AD_GRP_OU),$(AD_BASE)
cn: $(AD_GRP_CN)
objectClass: groupOfNames
objectClass: kopano-group
member: uid=$(AD_ADM_CN),ou=$(AD_USR_OU),$(AD_BASE)
member: uid=$(AD_USR_CN),ou=$(AD_USR_OU),$(AD_BASE)
mail: $(AD_GRP_CN)@$(MAIL_DOMAIN)
dn: uid=$(AD_ADM_CN),ou=$(AD_USR_OU),$(AD_BASE)
changetype: add
cn: $(AD_ADM_CN)
objectClass: inetOrgPerson
objectClass: kopano-user
sn: $(AD_ADM_CN)
uid: $(AD_ADM_CN)
mail: $(AD_ADM_CN)@$(MAIL_DOMAIN)
userPassword: $(AD_ADM_PW)
telephoneNumber: $(AD_ADM_TEL)
title: $(AD_ADM_TIT)
kopanoAccount: 1
kopanoAdmin: 1
kopanoEnabledFeatures: imap
kopanoEnabledFeatures: pop3
dn: uid=$(AD_USR_CN),ou=$(AD_USR_OU),$(AD_BASE)
changetype: add
cn: $(AD_USR_CN)
objectClass: inetOrgPerson
objectClass: kopano-user
sn: $(AD_USR_CN)
uid: $(AD_USR_CN)
mail: $(AD_USR_CN)@$(MAIL_DOMAIN)
userPassword: $(AD_USR_PW)
telephoneNumber: $(AD_USR_TEL)
title: $(AD_USR_TIT)
kopanoAccount: 1
kopanoAliases: $(AD_USR_AS)@$(MAIL_DOMAIN)
kopanoEnabledFeatures: imap
kopanoEnabledFeatures: pop3
dn: uid=$(AD_SHR_CN),ou=$(AD_USR_OU),$(AD_BASE)
cn: $(AD_SHR_CN)
objectClass: inetOrgPerson
objectClass: kopano-user
sn: $(AD_SHR_CN)
uid: $(AD_SHR_CN)
mail: $(AD_SHR_CN)@$(MAIL_DOMAIN)
kopanoAccount: 1
kopanoSharedStoreOnly: 1
dn: uid=$(AD_PUB_CN),ou=$(AD_USR_OU),$(AD_BASE)
cn: $(AD_PUB_CN)
objectClass: inetOrgPerson
objectClass: kopano-user
sn: $(AD_PUB_CN)
uid: $(AD_PUB_CN)
mail: $(AD_PUB_CN)@$(MAIL_DOMAIN)
kopanoAccount: 1
kopanoHidden: 1
kopanoSharedStoreOnly: 1
kopanoResourceType: publicFolder:Public Stores/public
endef
auth-mod_conf:
echo "$$LDIF_MOD_CONF" | docker-compose exec -T auth ldapmodify -Q
auth-add_data:
echo "$$LDIF_ADD_DATA" | docker-compose exec -T auth ldapadd -Q
auth-add_schema:
docker-compose exec app zcat /usr/share/doc/kopano/kopano.ldif.gz \
| docker-compose exec -T auth ldapadd -Q
auth-show_conf:
docker-compose exec auth ldapsearch -QLLLb cn=config "(cn=config)"
docker-compose exec auth ldapsearch -QLLLb cn=config olcDatabase={-1}frontend
docker-compose exec auth ldapsearch -QLLLb cn=config olcDatabase={1}mdb
auth-show_data:
docker-compose exec auth ldapsearch -QLLL
auth-show_cat0:
docker-compose exec auth slapcat -n0
auth-show_cat1:
docker-compose exec auth slapcat -n1
auth-gui-up:
docker run -d --name auth-gui --network demo_backend \
-p 127.0.0.1:8001:80 -e PHPLDAPADMIN_LDAP_HOSTS=auth \
-e PHPLDAPADMIN_HTTPS=false osixia/phpldapadmin || true
sleep 2
firefox localhost:8001 &
auth-gui-down:
docker rm -f auth-gui || true
mta-init:
mta-init_bayes:
docker-compose exec mta sh -c 'rm -f bayesian.database.gz && wget http://artinvoice.hu/spams/bayesian.database.gz && gunzip bayesian.database.gz && sa-learn --restore bayesian.database && chown -R amavis: /var/amavis/.spamassassin && rm -rf bayesian.database'
mta-show_bayes:
docker-compose exec mta sa-learn --dump magic \
| sed -r 's/[^ ]+\s+[^ ]+\s+([^ ]+).*non-token data: (.*)/\1\@\2/g' \
| sed -r '/atime/s/(.*)@(.*)/echo $$(date --date=@\1 +%Y%b%d-%T)@\2/eg' \
| column -t -s @
mta-test_smtp:
printf "From: A tester <[email protected]>\nTo: <$(AD_USR_CN)@$(MAIL_DOMAIN)>\nDate: $$(date)\nSubject: A SMTP test message\n\nGreat news! You can receive email.\n" \
| curl smtp://localhost -T - --mail-from [email protected] \
--mail-rcpt $(AD_USR_CN)@$(MAIL_DOMAIN) $(CURL_OPT)
mta-test_smtps:
printf "From: A tester <[email protected]>\nTo: <$(AD_USR_CN)@$(MAIL_DOMAIN)>\nDate: $$(date)\nSubject: A SMTPS test message\n\nGreat news! You can receive secure email.\n" \
| curl smtps://localhost -T - --mail-from [email protected] -k \
-u $(AD_USR_CN):$(AD_USR_PW) \
--mail-rcpt $(AD_USR_CN)@$(MAIL_DOMAIN) $(CURL_OPT)
mta-test_smtp2:
printf "From: A info tester <[email protected]>\nTo: <$(AD_USR_CN)-info@$(MAIL_DOMAIN)>\nDate: $$(date)\nSubject: A SMTP test message \n\nGreat news! $(AD_USR_CN)-info@$(MAIL_DOMAIN) can also receive email.\n" \
| curl smtp://localhost -T - --mail-from [email protected] \
--mail-rcpt $(AD_USR_CN)@$(MAIL_DOMAIN) $(CURL_OPT)
mta-test_shared: all-test_quiet
printf "From: A tester <[email protected]>\nTo: <$(AD_SHR_CN)@$(MAIL_DOMAIN)>\nDate: $$(date)\nSubject: A SMTP test message\n\nGreat news! A shared store can receive email.\n" \
| curl smtp://localhost -T - --mail-from [email protected] \
--mail-rcpt $(AD_SHR_CN)@$(MAIL_DOMAIN) $(CURL_OPT)
mta-test_public: all-test_quiet
printf "From: A tester <[email protected]>\nTo: <$(AD_PUB_CN)@$(MAIL_DOMAIN)>\nDate: $$(date)\nSubject: A SMTP test message\n\nGreat news! A public store can receive email.\n" \
| curl smtp://localhost -T - --mail-from [email protected] \
--mail-rcpt $(AD_PUB_CN)@$(MAIL_DOMAIN) $(CURL_OPT)
mta-razor:
docker-compose exec mta run amavis_register_razor
mta-apk_list:
docker-compose exec mta /bin/sh -c 'for pkg in $$(apk info 2>/dev/null); do printf "%9s %3s %s\n" $$(apk info -s $$pkg 2>/dev/null | sed -n "2{p;q}") $$pkg; done | sort | sort -k 2,2'
mta-quarantine_list:
docker-compose exec mta amavis-ls
mta-freshclam_nodns:
docker-compose exec mta freshclam --no-dns
mta-clamdtop:
docker-compose exec mta clamdtop
mta-tools:
docker-compose exec mta apk --no-cache --update add \
nano less lsof htop openldap-clients bind-tools iputils strace iproute2
mta-htop: mta-tools
docker-compose exec mta htop
mta-encrypt:
$(eval secret := $(shell whiptail --backtitle "doveadm pw" --title "encrypt password" --inputbox "password" 8 78 secret 3>&1 1>&2 2>&3))
docker-compose exec mta doveadm pw -p $(secret)
mta-show_doveconf:
docker-compose exec mta doveconf -n
mta-show_postconf:
docker-compose exec mta postconf -n
mta-show_mailq:
docker-compose exec mta mailq
mta-flush_mailq:
docker-compose exec mta postqueue -f
mta-test_auth:
docker-compose exec mta doveadm auth test $(AD_USR_CN) $(AD_USR_PW)
mta-test_imap: mta-hostaddr
curl imaps://$(myhost)/inbox -s --ssl --anyauth -k -X "fetch 1 all" \
-u $(AD_USR_CN):$(AD_USR_PW)
mta-man:
docker-compose exec mta apk --no-cache --update add man-db man-pages apk-tools-doc \
postfix-doc cyrus-sasl-doc dovecot-doc spamassassin-doc clamav-doc razor-doc
db-init:
db-test:
docker-compose exec db mysqlshow -u $(MYSQL_USER) $(MYSQL_DATABASE) -p$(MYSQL_PASSWORD)
db-gui-up:
docker run -d --name db-gui --network demo_backend \
-p 127.0.0.1:8002:80 -e PMA_HOST=db \
phpmyadmin/phpmyadmin || true
sleep 2
firefox localhost:8002 &
db-gui-down:
docker rm -f db-gui || true
app-init: app-public_store app-create_smime
app-tools:
docker-compose exec app apt-get update
docker-compose exec app apt-get install --yes \
less nano ldap-utils htop net-tools lsof iputils-ping dnsutils strace
app-htop: app-tools
docker-compose exec app htop
app-test_smtp: mta-test_smtp
app-test_lmtp: app-hostaddr
printf "LHLO mx\nMAIL FROM: <[email protected]>\nRCPT TO: <$(AD_USR_CN)@$(MAIL_DOMAIN)>\nDATA\nFrom: A tester <[email protected]>\nTo: <$(AD_USR_CN)@$(MAIL_DOMAIN)>\nDate: $$(date)\nSubject: A LMTP test message from me to you\n\nDelete me, please \n.\nQUIT\n" | nc -C $(myhost) 2003
app-test_all: all-test_muted app-test_imap app-test_pop3 app-test_ical app-test_imaps app-test_pop3s app-test_icals
app-test_imap: app-hostaddr
curl imap://$(myhost) -u $(AD_USR_CN):$(AD_USR_PW) $(CURL_OPT)
app-test_imaps: app-hostaddr
curl imaps://$(myhost) -k -u $(AD_USR_CN):$(AD_USR_PW) $(CURL_OPT)
app-test_pop3: app-hostaddr
curl pop3://$(myhost) -u $(AD_USR_CN):$(AD_USR_PW) $(CURL_OPT)
app-test_pop3s: app-hostaddr
curl pop3s://$(myhost) -k -u $(AD_USR_CN):$(AD_USR_PW) $(CURL_OPT)
app-test_ical: app-hostaddr
curl http://$(myhost):8080 -u $(AD_USR_CN):$(AD_USR_PW) $(CURL_OPT)
app-test_icals: app-hostaddr
curl https://$(myhost):8443 -k -u $(AD_USR_CN):$(AD_USR_PW) $(CURL_OPT)
app-test_tls: app-hostaddr
docker run --rm -it --network demo_backend drwetter/testssl.sh app:993 || true
app-test_oof1:
docker-compose exec app kopano-oof -u $(AD_USR_CN) -m 1 -t "Dunno when I return"
app-test_oof0:
docker-compose exec app kopano-oof -u $(AD_USR_CN) -m 0
app-show_user1:
docker-compose exec app kopano-admin --details $(AD_USR_CN)
app-show_user2: app-tools
docker-compose exec app ldapsearch -H ldap://auth:389 -xLLL -b $(AD_BASE) '*'
app-show_sync:
docker-compose exec app z-push-top
app-create_store:
docker-compose exec app kopano-admin --create-store $(AD_USR_CN)
app-public_store:
docker-compose exec app kopano-storeadm -P
#app-add_user:
# docker-compose exec app kopano-admin -c $(AD_USR_CN) -p $(AD_USR_PW) \
# -e $(AD_USR_CN)@$(MAIL_DOMAIN) -f $(AD_USR_CN) -a 1
$(addprefix app-parms_,archiver dagent gateway ical ldap search server spamd spooler):
docker-compose exec app run list_parms $(patsubst app-parms_%,%,$@)
app-create_smime: all-create_smime
docker cp ssl/ca.crt $$(docker-compose ps -q app):/usr/local/share/ca-certificates/$(MAIL_DOMAIN)_CA.crt
docker-compose exec app update-ca-certificates
all-test_quiet:
$(eval CURL_OPT := -s -S )
all-test_muted:
$(eval CURL_OPT := -s -S >/dev/null || true)
all-create_smime: ssl/$(AD_USR_CN).p12
all-destroy_smime: ssl-destroy