-
Notifications
You must be signed in to change notification settings - Fork 1
/
genpdsdm.sh
executable file
·2254 lines (2253 loc) · 85.9 KB
/
genpdsdm.sh
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
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/bin/bash
#
#***************************************************************************
#
# Copyright (c) 2023-2024 Freek de Kruijf
# All Rights Reserved.
#
# This program is free software; you can redistribute it and/or
# modify it under the terms of version 2 or later of the GNU General Public
# License as published by the Free Software Foundation.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
#**************************************************************************
#
# Script to generate an email system that supports a main domain and, if
# needed, a few other domains that have a close relation with this domain.
# It implements all security features available for such a system. It is
# designed to follow the procedure outlined in the openSUSE wiki page
# https://en.opensuse.org/Mail_server_HOWTO after heading SMTP.
#
# In this wiki page the domain name used is domain.com, which will be
# replaced by the required domain name. Furthermore all packages mentioned
# in this page will be installed right from the beginning.
#
# Version history
# Version 1.0 First release
# Version 1.0.1 Restrict disable_vrfy_command=yes to after ORIGINATING in submission
# Version 1.0.2 Milter to port 8893 is for opendkim (currenly not supported) removed
# Version 1.1.0 Improved generation of certificates (no questions asked anymore)
# Version 1.2.0 Added option to use dialog in asking questions and showing progress
# Version 1.3.0 Added support for Raspberry Pi OS with Bookworm
# Version 1.4.0 Added support for additional destination domains
# Version 1.4.1 Replaced obsolete parameters by recommended
#
# Version designed on openSUSE Leap 15.5 on Raspberry Pi 4B
# This version also works in other environments of openSUSE
# Tested also on Tumbleweed, Leap 15.6 and x86_64
# Tested in Rasbberry Pi OS (bookworm) Lite 32 bit and 64 bit on Rasberry Pi 4B
# and Debian (bookworm) in a Virtual Machine
#
# ---------------------------------------------------------------------
#
# this script should be run as user root
#
INSTDATE="$(date +'%Y-%m-%d_%H%M%S')"
LOGFILE=/var/log/genpdsdm-$INSTDATE.log
debug=0 # enables logfile
comm="$0"
dialog1='dialog --title GenPDSDM --begin 5 10'
exitmsg() {
if [ $DIAL -eq 0 ] ; then
local n=$((${#1}/50))
$dialog1 --colors --msgbox "\Z1\Zb${1}\Zr" $(($n+5)) 75
clear
else
/usr/bin/echo -e "$1"
fi
exit 1
}
dlog() {
[ $debug -eq 0 ] && do_log ">>DEBUG>> $1"
}
#
# wrren: write or renew parameter - might be an indexed parameter - in file /etc/genpdsdm/parameters
#
wrren() {
p=$(echo $1 | tr '[]' '..')
grep -q "^$p" /etc/genpdsdm/parameters
[ $? -eq 0 ] && sed -i "/^$p/ d" /etc/genpdsdm/parameters
if [ ${1:0:1} != "#" ] ;then
[ "$p" = "$1" ] && eval p='$'$1 || eval p='$'{$1}
echo ${1}=\"$p\" >> /etc/genpdsdm/parameters
else
# test on $1 ending on ] (indexed parameter)
if [ ${1: -1} = "]" ] ; then
# (#PAR[0] -> PAR[0])
p=${1:1}
p={$p}
eval p='$'$p
echo ${1}=$p >> /etc/genpdsdm/parameters
else
eval p='$'${1:1}
echo ${1}=$p >> /etc/genpdsdm/parameters
fi
fi
}
#
# echo and log
#
outlog() {
echo "${*}"
do_log "${*}"
}
#
# write log
#
do_log() {
if [ ! -f ${LOGFILE} ] ; then
touch ${LOGFILE}
chmod 600 ${LOGFILE}
outlog "Log ${LOGFILE} started."
outlog "ATTENTION: the log file contains sensitive information (e.g. passwords) "
outlog "Handle with care and sanitize before sharing."
echo -n "Press Enter to continue: "
read answ
fi
echo "$(date +'%Y-%m-%d_%H%M%S') ### ${*}" >> ${LOGFILE}
}
#
# execute and log
# make sure, to be run command is passed within '' or ""
# if redirects etc. are used
run() {
do_log "Running: ${*}"
eval ${*} >>${LOGFILE} 2>&1
RET=${?}
if [ ${RET} -ne 0 ]; then
dlog "EXIT CODE NOT ZERO (${RET})!"
fi
return ${RET}
}
#
# initialize NEW, OLD and DIAL as not activated
#
NEW=1 ; OLD=1 ; DIAL=1
grep -q "Tumbleweed" /etc/os-release && OS="openSUSE_Tumbleweed"
grep -q "Leap 15.5" /etc/os-release && OS="15.5"
grep -q "Leap 15.6" /etc/os-release && OS="15.6"
egrep -q "raspbian|ID=debian" /etc/os-release && OS="raspbian"
if [ ! -x /usr/bin/dialog ] ; then
[ "$OS" = "raspbian" ] && run 'apt-get -y install dialog' || run 'zypper in -y dialog'
fi
[ "$OS" = "" ] && exitmsg "Only openSUSE Tumbleweed, Leap 15.5/15.6 and Raspbian are supported"
#
# /var/log/genpdsdm-<date-time> .log keeps track of what has been done during running the script
# /etc/genpdsdm/parameters keeps track of what has been done already and holds parameter values
#
# initialize the parameters file of the script or read the parameters to skip what has been done
#
[ ! -f ${0%/*}/openssl_postfix.conf.in ] && exitmsg "\
===============================================================\n\
The file ${0%/*}/openssl_postfix.conf.in is missing.\n\
Please provide this file!! The script will exit!!\n\
==============================================================="
[ ! -d /var/adm/backup/genpdsdm ] && mkdir -p /var/adm/backup/genpdsdm
help="\nUse genpdsdm [OPTIONS]\n\n\
Generates configurations for Postfix, Dovecot, SPL, DKIM and DMARC from\n\
scratch. When invoked for the first time all necessary packets will be\n\
installed and all files, that will be changed, are saved to be able to\n\
start all over again, even much later in the lifetime of the system.\n\
When starting the script without --old or --new, and the script has\n\
been successfully completed before, the configuration will not change,\n\
and only processes will be restarted.\n\n\
OPTIONS\n\
--dial use dialog screens to ask questions and show progress\n\
--old configure all over again using previously saved parameters\n\
--new configure all over again using newly configured parameters\n\
--help print this help text and exit\n\n"
if [ "$1" != "" ] ; then
for par in $@
do
case $par in
--new ) NEW=0 ;;
--old ) OLD=0 ;;
--help ) [ $DIAL -ne 0 ] && /usr/bin/echo -e "$help" || $dialog1 --msgbox "$help" 20 0
exit ;;
--dial* ) DIAL=0 ;;
* ) echo "Invoke this script with $0 [--dial[og]] [--new|--old] , try again" && exit 1 ;;
esac
[ $NEW -eq 0 -a $OLD -eq 0 ] && echo "Parameters --new and --old are mutually exclusief" && exit 1
done
fi
id | tr "a-z" "A-Z" | egrep -q '^UID=0'
[ $? -ne 0 ] && exitmsg "This script should be executed by root or sudo $0"
readpar() {
#
# read the parameters file if present and set the available parameters
#
[ ! -d /etc/genpdsdm ] && mkdir -p /etc/genpdsdm
if [ -f /etc/genpdsdm/parameters ] ; then
. /etc/genpdsdm/parameters
# parameters with passwwords are present as comment in the file parameters; set these as parameters also
PASSWORD="$(grep '^#PASSWORD=' /etc/genpdsdm/parameters)"
[ -n "$PASSWORD" ] && PASSWORD=${PASSWORD#*=} || unset PASSWORD
j=0
rc=0
# To be able to have even the characters ', ", and $ in a password the following trick is used
# they are stored with a # in the first position, the parameter name followed by the index and =
# the trick is that what follows the = is stored verbose in the indexed parameter PASSW[n]
# what is entered with read and in dialog is taken verbose and written verbose in parameters
# and assigned to the indexed parameter
while [ $rc -eq 0 ]
do
PASSW[$j]="$(grep "^#PASSW.$j.=" /etc/genpdsdm/parameters)"
rc=$?
[ $rc -eq 0 ] && PASSW[$j]=${PASSW[$j]#*=} || unset PASSW[$j]
j=$(($j+1))
done
fi
}
installpackages() {
if [ $OS != raspbian ] ; then
# Check if this a clean system
if [ -f /etc/zypp/repos.d/postfix-policyd-spf-perl.repo ] ; then
exitmsg "This is not a clean installed system with only a few required additions\n\
Please start with a fresh installation on the boot device. Removing,\n\
first, the 5 involved packages and the non-standard repositories is\n\
also possible."
fi
[ "$OS" = "openSUSE_Tumbleweed" ] && run 'zypper dup -y'
[ "${OS:0:3}" = "15." ] && run 'zypper up -y'
run "zypper in -y --no-recommends postfix telnet dovecot spamassassin clzip rzip melt cabextract\
lz4 p7zip-full clamav bind-utils openssl cyrus-sasl-plain perl-Socket6"
run 'zypper in -y --recommends amavisd-new'
if [ ! -f /etc/zypp/repos.d/postfix-policyd-spf-perl.repo ] ; then
run "zypper ar https://download.opensuse.org/repositories/devel:/languages:/perl/$OS/ postfix-policyd-spf-perl"
zypper ref
run 'zypper in -y postfix-policyd-spf-perl'
# disable repository for not having conflicts during updates
run 'zypper mr -d postfix-policyd-spf-perl'
fi
[ $OS = 15.6 ] && OSl=15.5 || OSl=$OS
if [ ! -f /etc/zypp/repos.d/mail-server.repo ] ; then
run "zypper ar https://download.opensuse.org/repositories/server:/mail/$OSl/ server_mail"
run "zypper ar https://download.opensuse.org/repositories/devel:/languages:/perl/$OS language_perl"
zypper ref server_mail language_perl
run 'zypper in -y --no-recommends opendmarc'
# disable repository for not having conflicts during updates
run 'zypper mr -d server_mail'
run 'zypper mr -d language_perl'
fi
else
run 'apt-get -y update'
run 'apt-get -y upgrade'
run 'debconf-set-selections ${0%/*}/postfixsettings.txt'
run 'DEBIAN_FRONTEND=noninteractive apt-get -yqq install postfix'
run 'debconf-set-selections ${0%/*}/opendmarcsettings.txt'
run 'DEBIAN_FRONTEND=noninteractive apt-get -yqq install opendmarc'
run 'apt-get -y install dovecot-imapd postfix-policyd-spf-perl spamassassin'
run "apt-get -y install amavisd-new arj cabextract clamav-daemon lhasa libnet-ldap-perl libsnmp-perl lzop\
nomarch rpm libcrypt-des-perl clamav-freshclam clamav-docs firewalld pyzor razor bind9-dnsutils dialog"
run 'usermod -G amavis clamav'
[ -f /usr/share/dovecot/dh.pem ] && cp -a /usr/share/dovecot/dh.pem /etc/genpdsdm/
fi
mkdir -p /etc/opendmarc
if [ ! -f /etc/opendmarc/ignore.hosts ] ; then
touch /etc/opendmarc/ignore.hosts
chown opendmarc:opendmarc /etc/opendmarc/ignore.hosts
chmod 644 /etc/opendmarc/ignore.hosts
fi
if [ $OS != raspbian ] ; then
# postfix needs to be initialized to obtain a standard situation for this script
[ "$(systemctl is-active postfix.service)" != "active" ] && run 'systemctl start postfix.service'
[ "$(systemctl is-enabled postfix,service)" != "enabled" ] && run 'systemctl enable postfix.service'
#
fi
# Save all files that will get changed by the script
#
cp -a /etc/postfix/main.cf /var/adm/backup/genpdsdm/main.cf.org
cp -a /etc/postfix/master.cf /var/adm/backup/genpdsdm/master.cf.org
[ -f /etc/postfix/sasl_passwd ] && cp -a /etc/postfix/sasl_passwd /var/adm/backup/genpdsdm/sasl_passwd.org
[ -f /etc/postfix/sender_dependent_relayhost ] && \
cp -a /etc/postfix/sender_dependent_relayhost /var/adm/backup/genpdsdm/sender_dependent_relayhost.org
[ -f /etc/postfix/sender_dependent_default_transport ] && \
cp -a /etc/postfix/sender_dependent_default_transport /var/adm/backup/genpdsdm/sender_dependent_default_transport.org
[ -f /etc/postfix/tls_policy_maps ] && cp -a /etc/postfix/tls_policy /var/adm/backup/genpdsdm/tls_policy.org
cp -a /etc/dovecot/dovecot.conf /var/adm/backup/genpdsdm/dovecot.conf.org
cp -a /etc/dovecot/conf.d/10-ssl.conf /var/adm/backup/genpdsdm/10-ssl.conf.org
cp -a /etc/dovecot/conf.d/10-master.conf /var/adm/backup/genpdsdm/10-master.conf.org
cp -a /etc/dovecot/conf.d/10-mail.conf /var/adm/backup/genpdsdm/10-mail.conf.org
#cp -a /usr/share/dovecot/dovecot-openssl.cnf /var/adm/backup/genpdsdm/dovecot-openssl.cnf.org
if [ $OS != raspbian ] ; then
cp -a /etc/amavisd.conf /var/adm/backup/genpdsdm/amavisd.conf.org
else
cp -a /etc/amavis/conf.d/05-node_id /var/adm/backup/genpdsdm/05-node_id.org
cp -a /etc/amavis/conf.d/05-domain_id /var/adm/backup/genpdsdm/05-domain_id.org
cp -a /etc/amavis/conf.d/15-content_filter_mode /var/adm/backup/genpdsdm/15-content_filter_mode.org
cp -a /etc/amavis/conf.d/20-debian_defaults /var/adm/backup/genpdsdm/20-debian_defaults.org
cp -a /etc/amavis/conf.d/50-user /var/adm/backup/genpdsdm/amavis_conf.d_50-user.org
fi
cp -a /etc/opendmarc.conf /var/adm/backup/genpdsdm/opendmarc.conf.org
echo "INSTALLATION_done=yes" >> /etc/genpdsdm/parameters
}
#
# Restore all changed files
#
restorefiles() {
[ -f /var/adm/backup/genpdsdm/main.cf.org ] && cp -a /var/adm/backup/genpdsdm/main.cf.org /etc/postfix/main.cf
[ -f /var/adm/backup/genpdsdm/master.cf.org ] && cp -a /var/adm/backup/genpdsdm/master.cf.org /etc/postfix/master.cf
[ -f /var/adm/backup/genpdsdm/sasl_passwd.org ] && cp -a /var/adm/backup/genpdsdm/sasl_passwd.org /etc/postfix/sasl_passwd
[ -f /var/adm/backup/genpdsdm/sender_dependent_relayhost.org ] && \
cp -a /var/adm/backup/genpdsdm/sender_dependent_relayhost.org /etc/postfix/sender_dependent_relayhost
[ -f /var/adm/backup/genpdsdm/sender_dependent_default_transport.org ] && \
cp -a /var/adm/backup/genpdsdm/sender_dependent_default_transport.org /etc/postfix/sender_dependent_default_transport
[ -f /var/adm/backup/genpdsdm/tls_policy.org ] && cp -a /var/adm/backup/genpdsdm/tls_policy.org /etc/postfix/tls_policy
[ -f /var/adm/backup/genpdsdm/dovecot.conf.org ] && cp -a /var/adm/backup/genpdsdm/dovecot.conf.org /etc/dovecot/dovecot.conf
[ -f /var/adm/backup/genpdsdm/10-ssl.conf.org ] && cp -a /var/adm/backup/genpdsdm/10-ssl.conf.org /etc/dovecot/conf.d/10-ssl.conf
[ -f /var/adm/backup/genpdsdm/10-master.conf.org ] && cp -a /var/adm/backup/genpdsdm/10-master.conf.org /etc/dovecot/conf.d/10-master.conf
[ -f /var/adm/backup/genpdsdm/10-mail.conf.org ] && cp -a /var/adm/backup/genpdsdm/10-mail.conf.org /etc/dovecot/conf.d/10-mail.conf
#[ -f /var/adm/backup/genpdsdm/dovecot-openssl.cnf.org ] && cp -a /var/adm/backup/genpdsdm/dovecot-openssl.cnf.org /usr/share/dovecot/dovecot-openssl.cnf
if [ $OS != raspbian ] ; then
[ -f /var/adm/backup/genpdsdm/amavisd.conf.org ] && cp -a /var/adm/backup/genpdsdm/amavisd.conf.org /etc/amavisd.conf
else
[ -f /var/adm/backup/genpdsdm/05-node_id.org ] && cp -a /var/adm/backup/genpdsdm/05-node_id.org /etc/amavis/conf.d/05-node_id
[ -f /var/adm/backup/genpdsdm/05-domain_id.org ] && cp -a /var/adm/backup/genpdsdm/05-domain_id.org /etc/amavis/conf.d/05-domain_id
[ -f /var/adm/backup/genpdsdm/15-content_filter_mode.org ] && \
cp -a /var/adm/backup/genpdsdm/15-content_filter_mode.org /etc/amavis/conf.d/15-content_filter_mode
[ -f /var/adm/backup/genpdsdm/20-debian_defaults.org ] && \
cp -a /var/adm/backup/genpdsdm/20-debian_defaults.org /etc/amavis/conf.d/20-debian_defaults
[ -f /var/adm/backup/genpdsdm/amavis_conf.d_50-user.org ] && cp -a /var/adm/backup/genpdsdm/amavis_conf.d_50-user.org /etc/amavis/conf.d/50-user
fi
[ -f /etc/postfix/sasl_passwd ] && rm /etc/postfix/sasl_passwd
[ -f /etc/genpdsdm/dkimtxtrecord.txt ] && rm /etc/genpdsdm/dkimtxtrecord.txt
[ -f /var/adm/backup/genpdsdm/opendmarc.conf.org ] && cp -a /var/adm/backup/genpdsdm/opendmarc.conf.org /etc/opendmarc.conf
#
# With OLD or NEW true all generation needs to be done again
#
for par in MAINCF_done MASTERCF_done POSTFIXCERTIFICATES_done DOVECOT_done CERTIFICATEDOVECOT_done AMAVIS_done DMARC_done
do
sed -i "/^$par/ d" /etc/genpdsdm/parameters
unset $par
done
if [ $NEW -eq 0 ] ; then
#
# clear all parameters and ask these again
#
for par in PARAMETERS_done COUNTRYCODE STATEPROVINCE LOCALITYCITY ORGANIZATION RELAYHOST USERNAME \#PASSWORD ENAME \
LUSERNAME NAME BLACKLISTHOSTS USELETSENCRYPT MESSLIMIT PORT465
do
sed -i -e "/^$par/ d" /etc/genpdsdm/parameters
[ ${par:0:1} = "#" ] && unset ${par:1} || unset $par
done
j=0
while [ "${LDOMAIN[$j]}" != "" ] ; do
sed -i -e "/^LDOMAIN.$j./ d" /etc/genpdsdm/parameters
unset LDOMAIN[$j]
j=$(($j+1))
done
j=0
while [ "${EMAILA[$j]}" != "" ]
do
for par in EMAILA[$j] ADDRELAYS[$j] PORT[$j] USERNAM[$j] \#PASSW[$j]
do
pardot=$(echo $par | tr '[]' '..')
sed -i -e "/^$pardot=/ d" /etc/genpdsdm/parameters
[ "${par:0:1}" != "#" ] && unset $par || unset ${par:1: -1}[$j]
done
j=$(($j+1))
done
fi
}
#
# Find the host name and the domain name of the system
#
findhostdomainname() {
message="\
===============================================\n\
= Trying to find host name and domain name... =\n\
==============================================="
[ $DIAL -ne 0 ] && /usr/bin/echo -e "$message" || $dialog1 --infobox "$message" 5 0
[ $DIAL -eq 0 ] && sleep 3
HOSTNAME="$(cat /etc/hostname)"
DOMAINNAME=""
count=0
if [ ! -z "$HOSTNAME" ] ; then
grep "$HOSTNAME" /etc/hosts > /tmp/hosts
if [ $OS = raspbian ] ; then
grep -v "127.0.1.1" /tmp/hosts > /tmp/hostsn
mv /tmp/hostsn /tmp/hosts
fi
[ -f /tmp/hosts ] && count=$(cat /tmp/hosts | wc -l)
[ $count -gt 1 ] && rm /tmp/hosts && exitmsg "There is more than 1 line in /etc/hosts with the text \"$HOSTNAME\"\n\
You should not have changed anything in /etc/hosts before running this script."
if [ $count -eq 1 ] ; then
DOMAINNAME=$(cat /tmp/hosts | tr "\t" " ")
DOMAINNAME=${DOMAINNAME##*smtp.}
fi
fi
[ -f /tmp/hosts ] && rm /tmp/hosts
dlog "count=$count, domain name=$DOMAINNAME, host name=$HOSTNAME"
grep -q '\.' /etc/hostname
if [ $? -eq 0 -o -z "$HOSTNAME" -o $count -eq 0 -o -z "$DOMAINNAME" ] ; then
# HOSTNAME not known or contains a dot and/or no DOMAINNAME
message1="\
Questions about host name and domain name\n\
The host name can be any name and consist of letters, digits, a \"_\"\n\
and/or \"-\". This name should not be smtp or mail or imap, these names\n\
will be used elsewhere in the server."
message2="\
An example of the domain name is: example.com; should at least contain\n\
one dot. The script requires the existence of a DNS for this domain with\n\
a MX record for the domain. The MX record should point to\n\
smtp.<domain_name> or mail.<domain_name>; both should have an A record.\n\
Also an imap.<domain_name> A record should exist, all with the same IP address."
while true ; do
if [ $DIAL -ne 0 ] ; then
/usr/bin/echo -e -n "\n${message1}\nEnter the name of the system: "
read HOSTNAME
/usr/bin/echo -e -n "\n${message2}\nEnter the domain name: "
read DOMAINNAME
else
dlog "Window for host name and domain name"
$dialog1 --form "${message1}\n${message2}" 15 0 2 \
"Hostname : " 1 1 "" 1 18 20 20 \
"Domain name : " 2 1 "" 2 18 25 25 2> /tmp/u.tmp
[ $? -ne 0 ] && exitmsg "Script canceled by user or other error"
HOSTNAME="$(head -1 /tmp/u.tmp)"
DOMAINNAME=$(tail -1 /tmp/u.tmp)
rm /tmp/u.tmp
fi
if [ -z "$HOSTNAME" -o -z "$DOMAINNAME" ] ; then
message3="Hostname and Domainname must not be empty!"
[ $DIAL -ne 0 ] && echo "$message3" || $dialog1 --msgbox "$message3" 6 50
fi
# further checkes on names
message4="\
============================================\n\
= Checking for existing records in the DNS =\n\
============================================"
[ $DIAL -ne 0 ] && /usr/bin/echo -e "$message4" || $dialog1 --infobox "$message4" 5 0
[ $DIAL -eq 0 ] && sleep 5
message5="Errors found by checking:"
n=0
nslookup -query=A $DOMAINNAME > /tmp/Adomain
[ $? -ne 0 ] && message5="$message5\n\n$DOMAINNAME does not have an A record." && n=$(($n+1))
nslookup -query=MX $DOMAINNAME > /tmp/MXdomain
[ $? -ne 0 ] && message5="$message5\n\n$DOMAINNAME does not have an MX record." && n=$(($n+1))
nslookup -query=A smtp.$DOMAINNAME > /tmp/smtpdomain
[ $? -ne 0 ] && message5="$message5\n\nsmtp.$DOMAINNAME does not have an A or CNAME record." && n= $(($n+1))
nslookup -query=A mail.$DOMAINNAME > /tmp/maildomain
[ $? -ne 0 ] && message5="$message5\n\nmail.$DOMAINNAME does not have an A or CNAME record." && n=$(($n+1))
nslookup -query=A imap.$DOMAINNAME > /tmp/imapdomain
[ $? -ne 0 ] && message5="$message5\n\nimap.$DOMAINNAME does not have an A or CNAME record." && n=$(($n+1))
dlog "errorcount=$n"
if [ $n -ne 0 ] ; then
message5="$message5\n\n\
Typo? Please try again, otherwise provide the required records in the DNS\n\
for domain \"$DOMAINNAME\".\n"
if [ $DIAL -ne 0 ] ; then
/usr/bin/echo -e "${message5}Enter Ctrl+C on the next question."
else
$dialog1 --msgbox "${message5}Select Cancel on the next question." $(($n*2+9)) 80
fi
continue
fi
break
done
gipaddress=$(grep 'Address:' /tmp/Adomain | tail -1)
gipaddress=${gipaddress#* }
sub[0]="smtp" ; sub[1]="mail" ; sub[3]="imap" ; i=0 ; n=0
for f in /tmp/smtpdomain /tmp/maildomain /tmp/imapdomain ; do
grep -q "$gipaddress" $f
[ $? -ne 0 ] && message="Global IP address not in record for ${sub[$i]}.$DOMAINNAME" && n=$(($n+1))
rm $f
i=$(($i+1))
done
rm /tmp/Adomain /tmp/MXdomain
if [ $n -ne 0 ] ; then
message="$message\n\nApparently there is something wrong with the data in the DNS.\n\n\
Please fix it!"
[ $DIAL -ne 0 ] && /usr/bin/echo -e "$message" || $dialog1 --infobox "$message" 7 0
exit 1
fi
dlog "PROXYIP=$gipaddress"
PROXYIP=$gipaddress
wrren PROXYIP
#
# Check if there is already an entry in /etc/hosts for the server, if so remove it and enter such an entry.
# The entry should be <host_ip_address> <host_name>.<domain_name> <hostname>
#
hostip=$(hostname -I)
hostip=$(echo "$hostip" | tr "\t" " ")
# keep only the IP4 address
hostip=${hostip%% *}
grep -q "$hostip" /etc/hosts
[ $? -eq 0 ] && sed -i "/$hostip/ d" /etc/hosts
#
# Insert the entry in /etc/hosts after line with 127.0.0.1[[:blank:]]+localhost
#
sed -i -E "/^127.0.0.1[[:blank:]]+localhost/ a $hostip\t$HOSTNAME.$DOMAINNAME $HOSTNAME smtp.$DOMAINNAME" /etc/hosts
dlog "IP address and hostname entered in /etc/hosts"
echo $HOSTNAME > /etc/hostname
nslookup -query=AAAA smtp.$DOMAINNAME > /tmp/AAAAdomain
tail -1 /tmp/AAAAdomain | grep -q Address
if [ $? -eq 0 ] ; then
message="WARNING: This script supports only a server without an IPv6 address for smtp.$DOMAINNAME\n\n\
Contact the author if you have this requirement."
[ $DIAL -ne 0 ] && /usr/bin/echo -e "$message" || $dialog1 --msgbox "$message" 5 0
fi
rm /tmp/AAAAdomain
# count must be 1 when HOSTNAME and DOMAINNAME are set
count=1
else
message="Found host name is : ${HOSTNAME}\nDomain name is : ${DOMAINNAME}"
[ $DIAL -ne 0 ] && /usr/bin/echo -e "$message" || $dialog1 --infobox "$message" 4 60
[ $DIAL -eq 0 ] && sleep 5
fi
dlog "== End of finding domain name \"$DOMAINNAME\" and host name \"$HOSTNAME\""
dlog "== Check if domain name is OK =="
if [ -z "$DOMAINNAME_done" ] ; then
message="The domain name \"$DOMAINNAME\" will be used throughout this script\n\
Is this OK?"
if [ $DIAL -ne 0 ] ; then
/usr/bin/echo -e -n "\n${message}\n\nEnter y or Y for OK, anything else is NO and the script will terminate : "
read answ
else
$dialog1 --yesno "${message}\nSelecting NO will terminate the script" 7 80
[ $? -eq 0 ] && answ="y"
fi
case $answ in
"y" | "Y" ) ;;
* ) echo "" > /etc/hostname
grep DOMAINNAME_done /etc/genpdsdm/parameters
[ $? -eq 0 ] && sed -i "/^DOMAINNAME_done/ d" /etc/genpdsdm/parameters
exitmsg "The host name in /etc/hostname will be cleared,\n\
so when you invoke the script again, you will be asked again\n\
for the host name and the domain name."
;;
esac
DOMAINNAME_done="yes"
wrren DOMAINNAME_done
fi
dlog "Check $HOSTNAME.$DOMAINNAME is OK."
if [ "$HOSTNAME.$DOMAINNAME" != "$(hostname --fqdn)" ] ; then
message="The command (hostname --fqdn) does NOT provide $HOSTNAME.$DOMAINNAME.\n\
This means the system needs to reboot to establish that."
if [ $DIAL -ne 0 ] ; then
/usr/bin/echo -e -n "\n\
${message}\nPress Enter to reboot or Ctrl+C to abort : "
read answ
else
$dialog1 --yesno "$message\nUse Yes to reboot or No to abort." 8 80
[ $? -ne 0 ] && exitmsg "Aborted on user request."
fi
reboot
exit
fi
}
#
# Message size limit
#
getmessagelimit() {
message="Do you want a limit on the message size? The standard limit is 10240000.\n\
A recommended value is 30M, equivalent to 30000000.\n\
A value less than the default will not be accepted."
n=10
while true
do
dlog "Start setting MESSLIMIT, MESSLIMIT=$MESSLIMIT"
[ -z "$MESSLIMIT" ] && lmes=30000000 || lmes=$MESSLIMIT
if [ $DIAL -ne 0 ] ; then
/usr/bin/echo -e -n "\n${message}\nEnter the limit on the message size : "
read lmes
else
$dialog1 --form "$message" $n 80 1 "Message size limit : " 1 5 "$lmes" 1 28 15 15 2>/tmp/msize.txt
dlog "Returncode from dialog=$?"
lmes=$(head -1 /tmp/msize.txt)
rm /tmp/msize.txt
fi
dlog "lmes=$lmes"
lmes=$(($lmes+0))
if [ $lmes -lt 10240000 ] ; then
if [ "${message:0:1}" != "I" ] ; then
message="Input is wrong. Try again.\n${message}"
n=11
fi
else
MESSLIMIT=$lmes
break
fi
done
wrren MESSLIMIT
dlog "Einde MESSLIMIT=$MESSLIMIT"
}
#
# Also port 465?
#
alsoport465() {
message="The original port for clients to submit messages to the email server via\n\
an encrypted connection is 465. This one is now obsolete. But you may have\n\
clients that still use this port. Messages submitted via this port will not\n\
be DKIM signed. Do you want this port to be enabled?"
n=8
if [ -n "$PORT465" ] ; then
[ $PORT465 = yes ] && message="${message}\nPrevious answer was Yes." || message="${message}\nPrevious answer was No."
n=9
fi
if [ $DIAL -ne 0 ] ; then
/usr/bin/echo -e -n "\n${message}\nAnswer y or Y, anything else means No : "
read port465
else
$dialog1 --yesno "$message" $n 80
[ $? -eq 0 ] && port465="y" || port465="n"
fi
[ "$port465" = "y" -o "$port465" = "Y" ] && PORT465="yes" || PORT465="no"
wrren PORT365
}
#
# Relay host
#
getrelayhostpar() {
message="Questions about the relay host of your provider\n\
We assume the relay host is accessible via port 587\n\
(submission) and requires a user name and password.\n\
An MX record for this name will not be used."
n=0
while true ; do
if [ $DIAL -ne 0 ] ; then
/usr/bin/echo -e "\n$message"
[ $OLD -eq 0 -o $n -ne 0 -a ! -z "$RELAYHOST" ] && /usr/bin/echo -e "\nA single Enter will take \"$RELAYHOST\" as its value"
echo -n -e "\nPlease enter the name of the relayhost: "
read relayhost
[ -z $relayhost ] && relayhost="$RELAYHOST"
[ $OLD -eq 0 -o $n -ne 0 -a ! -z "$USERNAME" ] && /usr/bin/echo -e "\nA single Enter will take \"$USERNAME\" as its value"
/usr/bin/echo -e -n "\nPlease enter your user name on the relay host, might be an e-mail address: "
read username
[ -z "$username" ] && username="$USERNAME"
[ $OLD -eq 0 -o $n -ne 0 -a ! -z "$PASSWORD" ] && /usr/bin/echo -e "\nA single Enter will take \"$PASSWORD\" as its value"
echo -n -e "\nPlease enter the password of your account on the relay host: "
read password
[ -z "$password" ] && password="$PASSWORD"
else
[ $n -eq 0 ] && n=6
dlog "n=$n, message=$message"
$dialog1 --form "${message}\n\
The username may be an email address." $(($n+8)) 65 3 \
"Relayhost : " 1 5 "$RELAYHOST" 1 20 20 20 \
"Username : " 2 5 "$USERNAME" 2 20 20 20 \
"Password : " 3 5 "$PASSWORD" 3 20 20 20 2>/tmp/rup.tmp
[ $? -ne 0 ] && exitmsg "Script aborted by user or other error"
relayhost="$(head -1 /tmp/rup.tmp)"
username="$(head -2 /tmp/rup.tmp | tail -1 )"
password="$(tail -1 /tmp/rup.tmp)"
rm /tmp/rup.tmp
fi
n=0
message=""
RELAYHOST="$relayhost"
dlog "relayhost=$RELAYHOST, username=$USERNAME, password=$PASSWORD"
if [ -z "$RELAYHOST" ] ; then
message="The relay host is empty.\n" && n=$(($n+1))
else
nslookup $RELAYHOST > /tmp/relayhost
rcrh=$?
rhipaddress=$(grep "Address: " /tmp/relayhost | tail -1)
[ $rcrh -ne 0 -o -z "$rhipaddress" ] && \
message="${message}The name \"$RELAYHOST\" does not seem to exist in a DNS.\n" && n=$(($n+2))
fi
USERNAME="$username"
dlog "username=$USERNAME"
[ -z "$USERNAME" ] && message="${message}The user name is empty.\n" && n=$(($n+1))
PASSWORD="$password"
dlog "password=$PASSWORD"
[ -z "$PASSWORD" ] && message="${message}The password is empty.\n" && n=$(($n+1))
if [ $n -eq 0 ] ; then
break
else
n=$(($n+3))
fi
done
dlog "End asking relayhost etc."
}
#
# Name administator
#
getnameadmin() {
message="Questions about username and name administrator.\n\n\
The account name of the administrator to be created or\n\
already present in this server. In case it is created, the\n\
password for this account will be 'genpdsdm', but as root you\n\
can easily change it.\n"
n=0
while true ; do
dlog "Asking for administrator etc."
[ $OLD -ne 0 -a $n -eq 0 ] || [ $NEW -eq 0 -a $n -eq 0 ] && LUSERNAME="" && NAME=""
if [ $DIAL -ne 0 ] ; then
/usr/bin/echo -e "\n=====================\n"
[ ! -z "$LUSERNAME" ] && message="${message}\nA single Enter will take \"$LUSERNAME\" as its value"
/usr/bin/echo -e -n "${message}\n\nPlease enter the account name : "
read lusername
[ -z "$lusername" ] && lusername="$LUSERNAME"
if [ -n "$lusername" ] ; then
NAME=$(grep $lusername /etc/passwd)
NAME=${NAME%:*} # remove shell
NAME=${NAME%:*} # remove home folder
NAME=${NAME##*:} # get comment field with name
PNAME=${NAME}
fi
message=""
[ ! -z "$NAME" ] && message="\nA single Enter will take \"$NAME\" as its value"
message="${message}\nPlease enter the name of the administrator\n\
for this account"
[ $n -eq 0 -a -z "$NAME" ] && message="${message}, like 'John P. Doe' : " || message="${message} : "
/usr/bin/echo -e -n "$message"
read name
[ -z "$name" ] && name="$NAME"
else
[ $n -eq 0 -a -z "$NAME" ] && message="${message}The full name is something like 'John P. Doe'."
[ $n -eq 0 ] && m=14 || m=$(($n+8))
$dialog1 --form "$message" $m 65 2 \
"Account name administrator : " 1 5 "$LUSERNAME" 1 35 20 20 \
"Full name : " 2 5 "$NAME" 2 35 20 20 2>/tmp/lu.tmp
[ $? -ne 0 ] && exitmsg "Script aborted by user or other error in asking name administrator."
lusername=$(head -1 /tmp/lu.tmp)
name=$(tail -1 /tmp/lu.tmp)
rm /tmp/lu.tmp
if [ -n "$lusername" ] ; then
PNAME=$(grep $lusername /etc/passwd)
PNAME=${PNAME%:*} # remove shell
PNAME=${PNAME%:*} # remove home folder
PNAME=${PNAME##*:} # get comment field with name
fi
fi
n=0
dlog "lusername=$lusername, name=$name, PNAME=$PNAME"
LUSERNAME="$lusername"
message=""
[ -z "$LUSERNAME" ] && message="The account name of the administator is empty.\n" && n=$(($n+1))
NAME="$name"
[ -z "$NAME" ] && message="${message}The full name, comment in /etc/passwd, is empty.\n" && n=$(($n+1))
if [ $n -eq 0 ] ; then
break
else
message="${message}\nPlease try again.\n"
n=$(($n+2))
fi
done
grep -q "$LUSERNAME" /etc/passwd
if [ $? -eq 0 ] ; then
message="The user \"$LUSERNAME\" already exists.\n"
if [ -n "$PNAME" ] ; then
if [ "$PNAME" = "$NAME" ] ; then
message="${message}The full name did not change.\n"
else
message="${message}The full name has been replaced.\n"
fi
message="${message}The password remains the same."
fi
[ $DIAL -ne 0 ] && /usr/bin/echo -e "\n$message" || $dialog1 --infobox "$message" 5 65
[ $DIAL -eq 0 ] && sleep 5
usermod -c "$NAME" "$LUSERNAME" > /dev/null
else
useradd -c "$NAME" -m -p genpdsdm "$LUSERNAME" > /dev/null
message="The user $LUSERNAME has been created with password \"genpdsdm\"."
[ $DIAL -ne 0 ] && /usr/bin/echo -e "\n$message" || $dialog1 --msgbox "$message" 6 50
fi
dlog "lusername=$LUSERNAME,name=$NAME"
k=11
message="When sending an email as this user the sender address\n\
will currently be \"${LUSERNAME}@${DOMAINNAME}\"\n\
This will be changed in a canonical name like\n \"john.p.doe@${DOMAINNAME}\"."
[ $OLD -ne 0 ] && ENAME=""
while true ; do
if [ $DIAL -ne 0 ] ; then
[ $OLD -eq 0 -a ! -z "$ENAME" ] && message="${message}\nA single Enter will take \"$ENAME\" as its value"
echo -n -e "${message}\nEnter the part you want before the @ : "
read ename
[ -z $ename ] && ename="$ENAME"
else
$dialog1 --form "${message}" $k 60 1 "Part before @ : " 1 5 "$ENAME" 1 25 25 25 2> /tmp/fn.tmp
[ $? -ne 0 ] && exitmsg "Script aborted on user request or other error."
ename=$(head -1 /tmp/fn.tmp)
rm /tmp/fn.tmp
fi
n=0 # indicates success
k=10 # height of window
ENAME="$ename"
[ -z "$ENAME" ] && message="The part before the @ is empty.\n\nPlease try again\n" && n=1 # means failure
[ $n -eq 0 ] && break
done
dlog "ename=$ENAME"
}
#
# Question about additional domains to be considered local
#
getaddomains() {
# When OLD is true there might be LDOMAIN values, count number
ad=0
while [ "${LDOMAIN[$ad]}" != "" ] ; do
ad=$(($ad+1))
done
message="Currently the server will consider email messages to the following domains as local:\n\
smtp.$DOMAINNAME, $DOMAINNAME, localhost, localhost.$DOMAINNAME, $HOSTNAME.$DOMAINNAME\n"
i=0
while [ $i -lt $ad ] ; do
[ $i -eq 0 ] && message="${message}and additional domain(s): "
message="${message}${LDOMAIN[$i]} "
i=$(($i+1))
done
while true ; do
[ $OLD -eq 0 -a $ad -ne 0 ] && \
message="${message}\nAre these additional domains OK? Else you need to enter all (again)." || \
message="${message}\nDo you want additional domains?"
if [ $DIAL -ne 0 ] ; then
/usr/bin/echo -e -n "\n${message}\nY and y means OK, anything else means No : "
read answ
else
$dialog1 --yesno "$message" 8 110
[ $? -eq 0 ] && answ="y"
fi
case $answ in
"y" | "Y" ) [ $OLD -eq 0 -a $ad -ne 0 ] && break
;;
* ) if [ $OLD -eq 0 -a $ad -ne 0 ] ; then
LDOMAIN[0]=""
else
break
fi
;;
esac
ad=0 # new additional domains
while true ; do
message="Enter the additional domain name; DNS entry will be checked.\nLeave empty to finish asking.\n"
if [ $DIAL -ne 0 ] ; then
/usr/bin/echo -e -n "\n${message}Domain name: "
read ldomain
else
$dialog1 --form "$message" 9 75 1 "Domain name: " 1 1 "" 1 15 20 0 2> /tmp/ldomain.tmp
ldomain=$(head -1 /tmp/ldomain.tmp)
rm /tmp/ldomain.tmp
fi
[ "$ldomain" = "" ] && break
message=""
nslookup -query=MX $ldomain > /tmp/MXdomain
if [ $? -ne 0 ] ; then
message="$ldomain does not have an MX record\nPlease try again"
else
grep -q smtp.$DOMAINNAME /tmp/MXdomain
[ $? -ne 0 ] && message="MX record of $ldomain does not point to smtp.$DOMAINNAME\nPlease try again"
rm /tmp/MXdomain
fi
if [ "$message" != "" ] ; then
if [ $DIAL -ne 0 ] ; then
/usr/bin/echo -e -n "$message"
else
$dialog1 --infobox "$message" 0 0
sleep 5
fi
continue
else
LDOMAIN[$ad]="$ldomain"
ad=$(($ad+1))
fi
done
break
done
#
# Write one empty LDOMAIN in case the number has been less than before
j=-1
until [ $j -eq $ad ] ; do
j=$(($j+1))
wrren LDOMAIN[$j]
done
}
#
# Adding hosts with list for blacklisted hosts
#
getbllhosts() {
dlog "Adding hosts with list for blacklisted hosts"
answ="y"
if [ $OLD -eq 0 ] ; then
if [ -n "$BLACKLISTHOSTS" ] ; then
message="Host(s) with blacklists is/are:\n$BLACKLISTHOSTS\n"
if [ "${BLACKLISTHOSTS#* }" = "$BLACKLISTHOSTS" ] ; then
message="Host with blacklists is:\n$BLACKLISTHOSTS\nIs this one OK?"
else
message="Hosts with blacklists are:\n$BLACKLISTHOSTS\nAre these OK?"
fi
if [ $DIAL -ne 0 ] ; then
/usr/bin/echo -e -n "$message y or Y is OK,\n\
anything else is no and you need to specify again. : "
read answ
[ "$answ" = "Y" ] && answ="y"
else
$dialog1 --yesno "${message}\nNo means you have to specify again." 8 60
[ $? -eq 0 ] && answ="y" || answ="n"
fi
else
answ="n"
fi
else
answ="n"
fi
if [ "$answ" != "y" ] ; then
message="Do you want any server with blacklisted hosts?"
if [ $DIAL -ne 0 ] ; then
/usr/bin/echo -e -n "\n$message\nAnswer y or Y for yes, no is anything else : "
read answ
else
$dialog1 --yesno "$message" 5 50
[ $? -eq 0 ] && answ="y"
fi
if [ "${answ:0:1}" = "y" -o "${answ:0:1}" = "Y" ] ; then
if [ $DIAL -ne 0 ] ; then
while true
do
echo -e "\nEnter a combination of 1,2, and 3, which belong to the following options:"
echo "1: server bl.spamcop.net"
echo "2: server cbl.abuseat.org"
echo "3: server zen.spamhaus.org\n: "
read answ
[ -z "$answ" ] && echo "Please enter the proper digits!!" && continue
list=""
error=1
while [ ${#answ} -ne 0 ]
do
case ${answ:0:1} in
"1" ) list="${list}bl.spamcop.net " ;;
"2" ) list="${list}cbl.abuseat.org " ;;
"3" ) list="${list}zen.spamhaus.org " ;;
* ) echo "Please enter the proper digits!!" && error=0 && break ;;
esac
answ="${answ:1}"
done
[ $error -eq 0 ] && continue
[ -n "$list" ] && list="${list% }"
break
done
else
message="Please select one or more of the given hosts with blacklists"
n=10
while true
do
$dialog1 --checklist "$message" $n 65 3 'bl.spamcop.net' 1 'off' 'cbl.abuseat.org' 2 'off'\
'zen.spamhaus.org' 3 'on' 2>/tmp/blacklist.tmp
list="$(cat /tmp/blacklist.tmp)"
if [ -z "$list" ] ; then
[ "${message:0:1}" != "N" ] && message="No host selected, please try again\n$message" && n=11
else
break
fi
done
fi
else
list=""
fi
BLACKLISTHOSTS="$list"
wrren BLACKLISTHOSTS
fi
}
#
# Parameters for self signed certificates
#
getparselfsigned() {
dlog "Parameters for self signed certificates"
message="\
Questions about self signed certificates\n\n\
In certificates usually parameters like Country, State, Locality/City, Organization\n\
and Organizational Unit are present.\n\
The script will use \"Certificate Authority\" as the Organizational Unit\n\
for the signing certificate and \"IMAP server\" and \"Email server\"\n\
respectively for Dovecot and Postfix certificates.\n\
Common Names (CN) will be imap.$DOMAINNAME and smtp.$DOMAINNAME.\n"
n=0
while true ; do
if [ $OLD -ne 0 -a $n -eq 0 ] || [ $NEW -eq 0 -a $n -eq 0 ] ; then
COUNTRYCODE=""
STATEPROVINCE=""
LOCALITYCITY=""
ORGANIZATION=""
fi
if [ $DIAL -ne 0 ] ; then
#
# Country code
#
[ ! -z "$COUNTRYCODE" ] && \
message="${message}\nA single Enter will take \"$COUNTRYCODE\" as its value"
echo -n -e "\n${message}\nEnter the two character country code: "
read countrycode
[ -z $countrycode ] && countrycode="$COUNTRYCODE"
#
# State or Province
#
[ ! -z "$STATEPROVINCE" ] && \
echo "A single Enter will take \"$STATEPROVINCE\" as its value"
echo -n "Enter the name of the STATE or PROVINCE: "
read stateprovince
[ -z "$stateprovince" ] && stateprovince="$STATEPROVINCE"
#
# Locality or City
#
[ ! -z "$LOCALITYCITY" ] && \
echo "A single Enter will take \"$LOCALITYCITY\" as its value"
echo -n "Enter the name of the LOCALITY/CITY: "
read localitycity
[ -z "$localitycity" ] && localitycity="$LOCALITYCITY"
#
# Organization
#
[ ! -z "$ORGANIZATION" ] && \
echo "A single Enter will take \"$ORGANIZATION\" as its value"
echo -n "Enter the name of the ORGANIZATION: "
read organization
[ -z "$organization" ] && organization="$ORGANIZATION"
else