Compare commits

..

118 Commits

Author SHA1 Message Date
cb9e958d39 install_update_dovecot-2.4.sh: fix errors Correct errors relating to database access. 2025-08-23 17:28:28 +02:00
761a3a3b34 Merge branch 'master' of git.oopen.de:install/mailsystem 2025-08-23 11:49:42 +02:00
ae06305069 install_update_dovecot-2.4.sh: Set 'quota_storage_size' to 9 (unlimited) - We only use personalized quotas. 2025-08-23 11:49:29 +02:00
e50851b519 install_update_dovecot-2.4.sh: fix errors concerning mail location settings of shared folders, 2025-08-23 02:19:37 +02:00
c82ff77bbe Add DOC/dovecot/README.maildir-size-fix.pl. 2025-08-22 00:18:41 +02:00
f4c7453675 install_update_dovecot-2.4.sh: add parameter 'maildir_broken_filename_sizes = yes' and 'auth_allow_weak_schemes = yes'. 2025-08-21 23:38:55 +02:00
06914fcade install_postfix_advanced.sh: add parameters for 'Postfix DSN Support' to file 'main.cf'. 2025-08-21 00:06:17 +02:00
230ab94ca6 install_update_dovecot-2.4.sh: fix quota relating errors. 2025-08-14 12:43:33 +02:00
7cc2369ea0 install_update_dovecot-2.4.sh: initial versionm. 2025-08-14 01:41:47 +02:00
4aaeae3b1a install_update_dovecot-2.4.sh: another intermediate version. 2025-08-13 01:54:56 +02:00
692e76ad1d install_update_dovecot-2.4.sh: another intermediate version. 2025-08-12 02:03:37 +02:00
6f02a45023 Rename 'README.test_mailprotocolls' to 'README.test_mailprotocols'. 2025-08-03 11:01:44 +02:00
e971f26c75 README.test_mailprotocolls: adjust / expand documentation. 2025-08-03 11:00:31 +02:00
bbc3cf87f1 install_update_dovecot-2.4.sh: another intermediate version. 2025-07-23 01:57:24 +02:00
195e3f65ee install_update_dovecot-2.4.sh: another imtermediate update. 2025-07-22 03:01:11 +02:00
0270997761 install_update_dovecot-2.4.sh: another imtermediate update 2025-07-20 13:19:59 +02:00
6e19d1a938 install_update_dovecot-2.4.sh: another intermediate version. 2025-07-19 01:46:06 +02:00
5a9dcc4b8f install_update_dovecot-2.4.sh: another intermediate version. 2025-07-18 02:31:55 +02:00
94a1895873 install_update_dovecot-2.4.sh: another intermediate version. 2025-07-14 15:17:45 +02:00
e00ba6f4ce install_update_dovecot-2.4.sh: intermediate version. 2025-07-14 01:41:53 +02:00
845325eac8 ignore '.env' files. 2025-07-14 01:41:03 +02:00
ba20cb36fe Add initial not yet running installscript for dovecot version 2.4.x 2025-07-12 12:55:16 +02:00
83ad91f77d install_update_dovecot.sh:cleanup fron debug code.. 2025-07-12 12:54:08 +02:00
3a98ac15f7 Merge branch 'master' of https://git.oopen.de/install/mailsystem 2025-07-12 11:10:26 +02:00
d811cbfbd1 Backup 'BAK/install_update_dovecot.sh' bevor uploading a new one. 2025-07-12 11:10:17 +02:00
5eebd200f4 install_update_dovecot.sh: some minor changes. 2025-07-12 11:07:57 +02:00
14ae5a3ebf install_postfix_advanced.sh: workarround for error: the query to zen.spamhaus.org was blocked due to usage of an open resolver. 2025-05-15 02:59:51 +02:00
e24fb4cad3 install_postfix_advanced.sh: fix error in creating master.cf (+policy-spf). 2025-05-14 11:18:56 +02:00
cc06fe5cfa install_amavis.sh: fix errors in if statements: replace ':' with ';'. 2025-05-14 10:26:50 +02:00
4442c6230e install_postfix_advanced.s - policyd-spf h: increase 'void lookup limit'fro '2' to '5'. 2025-04-29 17:09:27 +02:00
3f141499dc install_postfix_base.sh: update file 'sasl_passwd' instead ao renewing it. 2025-03-12 14:43:41 +01:00
9b12e32853 install_amavis.sh: Moving SPAM policies into an external file. 2025-03-03 17:57:22 +01:00
894ff4eced install_opendmarc.sh: adjust configuration file. 2025-03-03 15:42:04 +01:00
99b1205d1b install_opendkim.sh: adjust configuration file. 2025-03-03 15:41:40 +01:00
ae2b6540af install_postfix_advanced.sh: add support for postfix-policyd-spf-python . 2025-03-02 02:17:25 +01:00
6cc1848e45 install_opendkim.sh: Add an Authentication-Results: header field. 2025-02-26 12:26:19 +01:00
07231ac1c7 install_postfix_advanced.sh: ix.dnsbl.manitu.net (also known as NixSpam) has been shutdown on 2025-01-16. 2025-02-14 14:29:14 +01:00
7b6e4c36d0 install_amavis.sh,install_postfix_advanced.sh: support additional smtp port in case of relay host. 2025-01-27 18:50:01 +01:00
ee41a335b1 install_postfix_base.sh: some really minor changes.. 2025-01-27 17:48:36 +01:00
0b410ad6d8 install_postfix_base.sh: support relaying to non standard port (other than 25). 2025-01-27 17:02:08 +01:00
aa092ea841 install_postfixadmin.sh: orioginal script now has the right charset (utf8). 2025-01-05 01:15:39 +01:00
da6c7fca0e install_postfix_base.sh: fix error if IPv4 address is a loopback address (127.x). 2024-12-18 12:04:04 +01:00
f1f56f48f6 install_amavis.sh: fix error in if statement. 2024-10-01 17:27:21 +02:00
765b16fd59 Merge branch 'master' of git.oopen.de:install/mailsystem 2024-10-01 00:21:35 +02:00
6a34a5b74c README.test_mailprotocolls: add test of RSA based TLS connection. 2024-10-01 00:21:16 +02:00
ad1d844b54 install_postfix_advanced.sh: some minor changes in writing 'main.cf'. 2024-10-01 00:20:04 +02:00
aa38ae7d76 install_postfix_advanced.sh: some realy minor changes. 2024-09-30 17:55:26 +02:00
f6482795c4 install_postfix_advanced.sh: get rid of trailling blanks. 2024-09-28 22:53:45 +02:00
361ccefd9a install_postfix_advanced.sh: adjust defaulr 'main.cf' file. 2024-09-26 17:44:21 +02:00
307c47d4a5 install_amavis.sh: adjust '_needed_packages_clamav'. 2024-09-26 16:19:25 +02:00
8670eb3dba Merge branch 'master' of https://git.oopen.de/install/mailsystem 2024-09-18 23:10:34 +02:00
8a66f11f49 install_postfix_advanced.sh: change comments for some tls parameters. 2024-09-18 23:05:30 +02:00
1d78a7e4b3 Merge branch 'master' of https://git.oopen.de/install/mailsystem 2024-09-18 19:38:15 +02:00
6c3c0c596b install_amavis.sh: fix error in adding SecuriteInfo signatures to freshclam.conf. 2024-09-18 19:37:54 +02:00
b069fdac30 install_amavis.sh: SecuriteInfo was moved to ClamAV's Freshclam. Also get rid of trailling spaces. 2024-09-18 16:46:38 +02:00
240dfbb54a install_postfix_advanced.sh, install_postfix_base.sh: adjust tls parameters of 'main.cf'. 2024-09-17 16:28:25 +02:00
3eb53b5463 install_postfix_base.sh,install_postfix_advanced.sh: adjust second time '/etc/rsyslog.d/postfix.conf'. 2024-09-15 22:18:20 +02:00
e976d0e3ef install_postfix_base.sh,install_postfix_advanced.sh: adjust '/etc/rsyslog.d/postfix.conf'. 2024-09-15 22:07:54 +02:00
da37fc1938 install_amavis.sh: add support for SecuriteInfo signatur databases at clamav-freshclam. 2024-08-31 22:59:44 +02:00
d189d8c4e9 install_amavis.sh: change cooment for SecuritoInfo accounts. 2024-08-31 22:17:25 +02:00
d0816ecf1c install_amavis.sh: change variable DEFAULT_SI_AUTHORISATION_SIGNATURE_OOPEN. 2024-08-31 22:01:08 +02:00
8a9ea4141b install_roundcube.sh: Change way to determin 'MYSQL_CREDENTIALS'. 2024-08-10 21:35:13 +02:00
46ea239260 upgrade_roundcube.sh: delete unused statement.. 2024-08-10 21:33:22 +02:00
f766e859f7 upgrade_roundcube.sh: Change settimgs of var 'MYSQL_CREDENTIALS'. 2024-08-10 16:43:51 +02:00
3785baa94a install_postfixadmin.sh: some changes in determinatiom MySQL installed Version. 2024-08-02 18:16:36 +02:00
a792c623bd Change determination of MySQL credentials. 2024-08-02 17:47:06 +02:00
2110953673 install_update_dovecot.sh: fix minor error restarting rsyslog. 2024-07-04 00:38:36 +02:00
aad56b6497 install_update_dovecot.sh: fix error on quota warnings. 2024-05-15 16:27:47 +02:00
97898ca194 Merge branch 'master' of git.oopen.de:install/mailsystem 2024-05-11 16:03:50 +02:00
520a1c115d Call of 'check_sender_access' and 'check_recipient_access' already with 'smtpd_client_restrictions' before querying blacklists. 2024-05-11 16:03:36 +02:00
e70949f6ec Add suport for sender domain rewriting. 2024-05-07 13:41:32 +02:00
397c6304e8 install_postfix_*: add support for 'smtp_generic_maps'. 2024-05-07 12:23:58 +02:00
5365eb8e18 Add file 'README.disable-milter-mail-filter'. 2024-05-07 12:23:26 +02:00
0c5c9915f8 install_postfix_*: add support for 'smtp_generic_maps'. 2024-05-07 12:23:00 +02:00
015cba6d05 Add 'README.default-rate-limits'. 2024-04-17 14:43:06 +02:00
b4cbe3989c install_opendmarc.sh: change default value for 'RequiredHeaders' to 'false'. 2024-03-22 22:03:09 +01:00
ba486f22db install_postfix_advanced.sh: add support for allowing extra hosts (ip-addresses) for relaying. 2024-03-22 01:54:45 +01:00
44317f0b57 Add support for disabling milter mail filters. 2024-03-20 16:50:31 +01:00
0f6fa53e6d upgrade_roundcube.sh: fix error using internal field separator IFS. 2024-03-17 18:34:07 +01:00
0c4dd7b5e9 README.virtual-do-not-reply: minor changes. 2024-02-28 18:28:08 +01:00
e93a4783a2 install_postfix_advanced.sh: add support for lookup tables 'virtual_alias_domains' and 'virtual_alias_maps'. 2024-02-28 18:26:56 +01:00
5261828376 Add 'README.virtual-do-not-reply'. 2024-02-28 17:59:55 +01:00
3f3ef95240 install_postfixadmin.sh: change '$CONF['password_expiration']' to 'NO'. 2024-01-03 22:37:41 +01:00
cda7fb08da install_postfix_advanced.sh: remove 127.0.0.25 from inte_interfaces. 2023-12-09 01:08:03 +01:00
83a4e631b5 install_postfix_advanced.sh: add comment for '127.0.0.25'. 2023-12-08 23:58:32 +01:00
b1f4cdc84d install_roundcube.sh: change location of php-socket to directory '/run/php/'. 2023-12-08 23:57:00 +01:00
1f05685af9 install_update_dovecot.sh: creating DH parameter changes if debian version is 12 or above. 2023-12-08 18:53:30 +01:00
e48b35bdd1 install_amavis.sh: fix error on data input. 2023-12-08 18:09:12 +01:00
e595f034d8 install_amavis.sh: fix error in writing 'master.cf' in case of SASL AUTH enabled. 2023-11-21 21:03:14 +01:00
d5d3bddb8c install_postfix_base.sh: change function dectec_os to dectect_os_1. 2023-11-15 18:36:51 +01:00
b717e88130 update_postfix_dh_parameters.sh: change function dectec_os to dectect_os_1. 2023-11-15 18:35:48 +01:00
ccc527abc2 Add script 'update_postfix_dh_parameters.sh'. 2023-11-15 17:49:01 +01:00
2291f6efa9 install_postfix_advanced.sh: fix error detecting os distribution/version. 2023-11-15 17:20:34 +01:00
bb464c1686 install_postfix_base.sh: minor chanmges on script output. 2023-11-15 16:42:53 +01:00
23165653f5 install_postfix_advanced.sh: fix error icreatunf / installing DH parameters. 2023-11-15 16:42:05 +01:00
ba988c63bc install_postfix_base.sh: fix error on script output. 2023-11-15 16:37:47 +01:00
4dd9611151 fix error creating / installing DH parameters. 2023-11-15 15:50:06 +01:00
0bde654616 install_postfix_advanced.sh: exclude TLSv1 for smtp server and TLSv1 and TLSv1.1 for smtp client. 2023-11-13 09:25:54 +01:00
190b0d0fcb install_postfix_advanced.sh: add message headers that include information about the protocol and cipher used. 2023-11-13 09:22:18 +01:00
30db99c91e install_amavis.sh: adjust spamassassin's local.cnf file. 2023-11-07 11:44:59 +01:00
25d24ccdfc install_amavis.sh: add debian package 'libnet-patricia-perl'. 2023-10-23 01:08:10 +02:00
e50d23d9e8 install_amavis.sh: some minor changes/fixes 2023-10-22 18:56:34 +02:00
2984da58c9 install_amavis.sh: some fixes to support debian version 12. 2023-10-22 17:54:47 +02:00
4a6d7034f2 install_postfixadmin.sh: Change use of virtual vacation from 'YES' to 'NO'. 2023-08-30 18:57:44 +02:00
0e9f2d739b install_amavis.sh: install 'libclamunrar11' in case of debian 12 (bookworm). 2023-06-24 09:57:44 +02:00
58cd085f59 install_postfixadmin.sh: some minor changes in script output. 2023-06-24 02:16:53 +02:00
a0f75035ad install_postfixadmin.sh: support transfer 'setup_password' from old installation. 2023-06-24 02:14:45 +02:00
db1c2fd72b install_amavis.sh: some changes (i.e. port number) for whitelisted sender addresses. 2023-05-18 12:51:27 +02:00
058ea39ce7 install_amavis.sh: forgot to add tcp port 10026 .. 2023-05-17 02:16:44 +02:00
225d8f83c6 install_amavis.sh: do virus check on whitelisted addresses. 2023-05-17 01:52:02 +02:00
93a7f2fe62 add 'README.smtp-over-tor-hidden-services'. 2023-04-27 00:02:13 +02:00
5f554c8bbd install_roundcube.sh: replace 'smtp_server' with 'smtp_host' in configuration file. 2023-03-06 22:57:13 +01:00
cc146aa5fc install_postfixadmin.sh: some minor dhanges in script output. 2023-03-06 13:00:33 +01:00
1f34f1eaaa upgrade_roundcube.sh: install new version of composer. 2023-03-06 12:48:49 +01:00
eed8497faa upgrade_roundcube.sh: change default variables 'DEFAULT_DEBIAN_MYSQL_CREDENTIALS' and 'DEFAULT_MYSQL_CREDENTIALS'. 2023-03-06 09:50:16 +01:00
4dc221a1dd install_roundcube.sh: correct default value 'DEFAULT_DEBIAN_MYSQL_CREDENTIALS'. 2023-03-06 09:49:16 +01:00
4b9ba22a0e install_roundcube.sh: change setting of 'DEFAULT_MYSQL_CREDENTIALS ' to support MairaDB installation from debian package system. 2023-03-05 18:38:30 +01:00
36c79de191 install_update_dovecot.sh: fix error setting 'dbhost' in case og MySQL. 2023-03-05 18:34:07 +01:00
21 changed files with 19426 additions and 985 deletions

1
.gitignore vendored
View File

@ -3,6 +3,7 @@
*.log *.log
*.swp *.swp
conf/*.conf conf/*.conf
conf/*.env
# - Postfixadmin # - Postfixadmin
postfixadmin-* postfixadmin-*

4554
BAK/install_update_dovecot.sh.00 Executable file

File diff suppressed because it is too large Load Diff

View File

@ -1,16 +0,0 @@
## -------------------------------------- ##
## - some litle tests ##
## -------------------------------------- ##
## - test smtp (STARTTLS), submission (587) (STARTTLS), smtp (SSL),
## - pop3 (SSL), pop3 (STARTTLS), imap (SSL) and imap (STARTTLS)
## -
openssl s_client -crlf -starttls smtp -connect localhost:25 [-state -debug]
openssl s_client -crlf -starttls smtp -connect localhost:587
openssl s_client -crlf -connect localhost:465
openssl s_client -crlf -connect localhost:995
openssl s_client -crlf -starttls pop3 -connect localhost:110
openssl s_client -crlf -connect localhost:993
openssl s_client -crlf -starttls imap -connect localhost:143

View File

@ -0,0 +1,44 @@
## -------------------------------------- ##
## - some litle tests ##
## -------------------------------------- ##
## -
## - test smtp (STARTTLS), submission (587) (STARTTLS), smtp (SSL),
## - pop3 (SSL), pop3 (STARTTLS), imap (SSL) and imap (STARTTLS)
## -
# ---
# test - localhost
# ---
openssl s_client -crlf -starttls smtp -connect localhost:25 [-state -debug]
openssl s_client -crlf -starttls smtp -connect localhost:587
openssl s_client -crlf -connect localhost:465
openssl s_client -crlf -connect localhost:995
openssl s_client -crlf -starttls pop3 -connect localhost:110
openssl s_client -crlf -connect localhost:993
openssl s_client -crlf -starttls imap -connect localhost:143
# ---
# tests - remote mailserver
# ---
mailserver="mx.gemeinschaft-altenschlirf.de"
openssl s_client -crlf -starttls smtp -connect ${mailserver}:25 [-state -debug]
openssl s_client -crlf -starttls smtp -connect ${mailserver}:587
openssl s_client -crlf -connect ${mailserver}:465
openssl s_client -crlf -connect ${mailserver}:995
openssl s_client -crlf -starttls pop3 -connect ${mailserver}:110
openssl s_client -crlf -connect ${mailserver}:993
openssl s_client -crlf -starttls imap -connect ${mailserver}:143
# Test RSA based TLS connection
#
echo "quit" | openssl s_client -connect ${mailserver}:25 -starttls smtp -tls1_2 -cipher ECDHE-RSA-AES256-GCM-SHA384
echo "quit" | openssl s_client -connect ${mailserver}:25 -starttls smtp -tls1_2
echo "quit" | openssl s_client -connect ${mailserver}:25 -starttls smtp

View File

@ -0,0 +1,61 @@
# ----------
# Fix Maildir Size
#
# falls sich die tatsächliche Größe einer E-mail im Maildir Format
# von der Größenangabe im Dateinamen unterscheidet, dann läuft
# dovecot auf fehler.
#
# Es gibt 2 Möglichekeiten das zu verhindern:
#
# 1. in der dovecot.conf (z.Bsp. in 10-mail.conf deb Parameter
# 'maildir_broken_filename_sizes' auf 'yes' setzen
#
# maildir_broken_filename_sizes = yes
#
#
# 2. Die Größenangaben im Dateinamen korrigieren. Dafür gint es ein Skript
# namens 'maildir-size-fix.pl'. Dieses Skript steht bei Githup's
# 'dovecot/tools' zur Verfügung:
#
# https://github.com/dovecot/tools
#
# Das Perl-Skript maildir-size-fix.pl ist ein Werkzeug, das im Dovecot-Projekt
# verwendet wird, um Probleme mit der Größe von Maildir-Dateien zu beheben.
#
# Nützliche Optionen
#
# - add_missing_size: Fügt die Größeninformation hinzu, wenn sie fehlt.
#
# - fix_existing_size: Überprüft und korrigiert bestehende Größeninformationen.
#
# - recursive: Scannt das Maildir rekursiv, um auch Unterordner zu berücksichtigen.
#
# - verbose: Ermöglicht detaillierte Protokollierung der Vorgänge.
#
#
# ---------------------------------------------------------------------------------------
#
# Jede E.Mail in einem Maildir Ordner ist eine eigene Datei, dess dateiname üblicherweise
# die Größe der datei selbst enthält (..,S=<dateigrösse>,W=..)
#
# ein typische Datei innerhalb eines Maildirordners sieht so aus:
#
# 1755713024.M837247P2624513.rage,S=38568,W=39101:2,Sc
# | | |
# Zeitstempel | Hostname
# eind. ID
#
# S= und ,W=: Dateigröße und "Weighted size" (für IMAP/Quota).
#
# wobei die flags folgende bedeitung haben:
#
# +-------+-----------------------------+
# | Flag | Bedeutung |
# +-------+-----------------------------+
# | S | Seen (gelesen) |
# | R | Replied (beantwortet) |
# | F | Flagged (markiert / wichtig)|
# | T | Trashed (zum Löschen mark.) |
# | D | Draft (Entwurf) |
# | P | Passed (weitergeleitet) |
# +-------+-----------------------------+

View File

@ -0,0 +1,18 @@
default rate limits
===================
- von unbekannten Server 5 Empfänger pro 5 Minuten
Message: only 5 recipients per 5 minutes allowed
- von einer IP-Adresse nicht mehr als 50 Nachrichten pro Minute
Message: Too many connections from <IP-Adress>
- Pro Nachricht nicht mehr als 50 Empfänger
Message: Too many recipients, please reduce to less than 50 or consider using a mailing list
- von einem User (also z.Bsp. cloud@oopen.de) nicht mehr 50 Nachrichten/Stunde
Message: Number messages per hour exceeded
- von einem User (also z.Bsp. cloud@oopen.de) nicht mehr 250 Empfänger/Stunde
Message: Number recipients per hour exceeded

View File

@ -0,0 +1,10 @@
# ----------
# Disable Milter (mail filter) for (remote) SMTP client IP address(es).
# see:
# https://www.postfix.org/MILTER_README.html
# https://www.postfix.org/MILTER_README.html#per-client
#
# https://www.postfix.org/postconf.5.html#smtpd_milter_maps

View File

@ -0,0 +1,3 @@
#
# see: https://www.void.gr/kargig/blog/2014/05/10/smtp-over-hidden-services-with-postfix/
#

159
README.virtual-do-not-reply Normal file
View File

@ -0,0 +1,159 @@
# ====================
# Forward E-Mails to 'do-not-reply@..' address to (file) /dev/null
# ====================
# ---
# Example for this readme:
#
# Create a forwarding to /dev/null for the address no-reply@cloud-01.oopen.de
# ---
DOMAIN=""cloud-01.oopen.de
E_MAIL="no-reply@cloud-01.oopen.de"
# see also:
# https://www.postfix.org/VIRTUAL_README.html
#
# https://think.unblog.ch/weiterleiten-von-postfix-alias-an-dev-null/
# https://think.unblog.ch/en/forward-postfix-alias-to-dev-null/
#
# https://www.serverwatch.com/guides/forwarding-a-postfix-virtual-alias-to-dev-null/
# Notice:
# the usual solution is to forward to (file) /dev/null. In a local-only setup you could do
# that in /etc/aliases.
#
# However, if your're using Postfix virtual domains, it gets a little more complicated. With
# virtual domains/users, you can't forward mail to a file (like /dev/null).
# ---
# 1. Set up an alias user 'do-not-reply'that forwards incoming e-mails to /dev/null.
# ---
# Add to file '/etc/aliases' a line like:
# do-not-reply: /dev/null
if ! $(grep -q -E "^\s*do-not-reply:" /etc/aliases 2>/devnull) ; then
cat <<EOF >> /etc/aliases
do-not-reply: /dev/null
EOF
fi
# Renew alias database:
#
newaliases
# ---
# 2. Set up the domain (domain part of not-reply address)
# ---
# Create file '/etc/postfix/virtual_alias_domains' and add your domain '@cloud-01.oopen.de'
#
# ${DOMAIN} OK
#
if [[ ! -f "/etc/postfix/virtual_alias_domains" ]] ; then
cat <<EOF >> /etc/postfix/virtual_alias_domains
# - File: /etc/postfix/virtual_alias_domains
# -
# - Note:
# - a mapping file always has two columns. In such a 'one-dimensional' mapping (list of domains)
# - Postfix does not care about your second column. It does not even have to be 'OK', it can be
# - anything.
# -
# - Example:
# - <domain> OK
${DOMAIN} OK
EOF
else
if ! $(grep -q -E "^\s*${DOMAIN}" /etc/postfix/virtual_alias_domains 2> /dev/null) ; then
cat <<EOF >> /etc/postfix/virtual_alias_domains
${DOMAIN} OK
EOF
fi
fi
# Create Postfix lookup table (database file) from '/etc/postfix/virtual_alias_domains'
#
postmap btree:/etc/postfix/virtual_alias_domains
# Add virtual_alias_domains to Postfix main Configuration
#
# ...
# virtual_alias_domains =
# btree:/etc/postfix/virtual_alias_domains
# ...
#
if ! $(grep -q -E "^\s*virtual_alias_domains\s*=\s*btree:/etc/postfix/virtual_alias_domains" /etc/postfix/main.cf) \
&& ! $(grep -q -E "^\s*btree:/etc/postfix/virtual_alias_domains" /etc/postfix/main.cf); then
perl -i -n -p -e "s#^(\s*virtual_alias_domains\s*=.*)#\1\n btree:/etc/postfix/virtual_alias_domains#" /etc/postfix/main.cf
fi
# ---
# 3. Set up adress mapping
# ---
# - Create file '/etc/postfix/virtual_alias_maps' and add your address mapping
# -
# - ${E_MAIL} do-not-reply
# -
if [[ ! -f "/etc/postfix/virtual_alias_maps" ]] ; then
cat <<EOF >> /etc/postfix/virtual_alias_maps
# - File: /etc/postfix/virtual_alias_maps
# -
# - Redirect mail for one address to one or more addresses.
# -
# - Example:
# - # incomming address 'no-reply@cloud-01.oopen.de' to local 'do-not-reply' address
# - no-reply@cloud-01.oopen.de do-not-reply
# -
${E_MAIL} do-not-reply
EOF
else
if ! $(grep -q -E "^\s*${E_MAIL}" /etc/postfix/virtual_alias_maps 2> /dev/null) ; then
cat <<EOF >> /etc/postfix/virtual_alias_maps
${E_MAIL} do-not-reply
EOF
fi
fi
# Create Postfix lookup table (database file) from '/etc/postfix/virtual_alias_maps'
#
postmap btree:/etc/postfix/virtual_alias_maps
# Add virtual_alias_maps to Postfix main Configuration
#
# ...
# virtual_alias_maps =
# btree:/etc/postfix/virtual_alias_maps
# ...
#
if ! $(grep -q -E "^\s*virtual_alias_maps\s*=\s*btree:/etc/postfix/virtual_alias_maps" /etc/postfix/main.cf) \
&& ! $(grep -q -E "^\s*btree:/etc/postfix/virtual_alias_maps" /etc/postfix/main.cf); then
perl -i -n -p -e "s#^(\s*virtual_alias_maps\s*=.*)#\1\n btree:/etc/postfix/virtual_alias_maps#" /etc/postfix/main.cf
fi
# ---
# 4. Reload Postfix
# ---
systemctl reload postfix

View File

@ -6,6 +6,8 @@ _HOSTNAME=
_IPV4= _IPV4=
_IPV6= _IPV6=
_SASL_AUTH_ENABLED=no
_QUARANTINE_DIR=/var/QUARANTINE _QUARANTINE_DIR=/var/QUARANTINE
_QUARANTINE_ADMIN=postmaster\@$mydomain _QUARANTINE_ADMIN=postmaster\@$mydomain

File diff suppressed because it is too large Load Diff

View File

@ -189,6 +189,13 @@ else
cat <<EOF > $opendkim_conf_file 2> $log_file cat <<EOF > $opendkim_conf_file 2> $log_file
# Datei $opendkim_conf_file # Datei $opendkim_conf_file
# Sets the "authserv-id" to use when generating the Authentication-Results:
# header field after verifying a message. The default is to use the name of
# the MTA processing the message. If the string "HOSTNAME" is provided, the
# name of the host running the filter (as returned by the gethostname(3)
# function) will be used.
AuthservID "DKIM check $(hostname -f)"
# OpenDKIM agiert als Mail Filter (= Milter) in den # OpenDKIM agiert als Mail Filter (= Milter) in den
# Modi signer (s) und verifier (v) und verwendet eine # Modi signer (s) und verifier (v) und verwendet eine
# Socket-Datei zur Kommunikation (alternativ: lokaler Port) # Socket-Datei zur Kommunikation (alternativ: lokaler Port)
@ -237,6 +244,21 @@ SignatureAlgorithm rsa-sha256
# because it is often the identity key used by reputation systems and thus # because it is often the identity key used by reputation systems and thus
# somewhat security sensitive. # somewhat security sensitive.
OversignHeaders From OversignHeaders From
# Add an "Authentication-Results:" header field even to unsigned messages
# from domains with no "signs all" policy. The reported DKIM result will be
# "none" in such cases. Normally unsigned mail from non-strict domains does
# not cause the results header field to be added.
AlwaysAddARHeader yes
# Causes opendkim to fork and exits immediately, leaving the service running
# in the background. The default is "true".
Background yes
# Sets the DNS timeout in seconds. A value of 0 causes an infinite wait. The
# default is 5. Ignored if not using an asynchronous resolver package. See
# also the NOTES section below.
DNSTimeout 5
EOF EOF
opendkim_needs_restart=true opendkim_needs_restart=true
if [[ $? -eq 0 ]] ; then if [[ $? -eq 0 ]] ; then

View File

@ -23,7 +23,7 @@ opendmarc_socket_dir="${postfix_spool_dir}/opendmarc"
opendmarc_socket_file="${opendmarc_socket_dir}/opendmarc.sock" opendmarc_socket_file="${opendmarc_socket_dir}/opendmarc.sock"
config_file_name_value_parameters=" config_file_name_value_parameters="
AuthservID|OpenDMARC AuthservID|DMARC check $(hostname -f)
PidFile|/run/opendmarc/opendmarc.pid PidFile|/run/opendmarc/opendmarc.pid
RejectFailures|true RejectFailures|true
Syslog|true Syslog|true
@ -31,11 +31,12 @@ config_file_name_value_parameters="
TrustedAuthservIDs|$(hostname -f) TrustedAuthservIDs|$(hostname -f)
IgnoreHosts|/etc/opendmarc/ignore.hosts IgnoreHosts|/etc/opendmarc/ignore.hosts
IgnoreAuthenticatedClients|true IgnoreAuthenticatedClients|true
RequiredHeaders|true RequiredHeaders|false
UMask|002 UMask|002
FailureReports|false FailureReports|false
AutoRestart|true AutoRestart|true
HistoryFile|/run/opendmarc/opendmarc.dat HistoryFile|/run/opendmarc/opendmarc.dat
SPFIgnoreResults|false
SPFSelfValidate|true SPFSelfValidate|true
Socket|${opendmarc_socket_file} Socket|${opendmarc_socket_file}
" "
@ -182,6 +183,200 @@ else
fi fi
# - Add 'IgnoreHosts' with default value to the original opendmarc.conf file
#
echononl " Add 'IgnoreHosts' with default value to the opendmarc.conf file.."
if ! $(grep -q -E "^IgnoreHosts\s+" ${opendmarc_conf_file} 2> /dev/null) ; then
cat << EOF >> ${opendmarc_conf_file}
## Specifies the path to a file that contains a list of hostnames, IP addresses,
## and/or CIDR expressions identifying hosts whose SMTP connections are to be
## ignored by the filter. If not specified, defaults to "127.0.0.1" only.
#
IgnoreHosts 127.0.0.1
EOF
if [[ $? -eq 0 ]] ; then
echo_ok
else
echo_failed
error "$(cat $log_file)"
fi
else
echo_skipped
fi
# - Add 'IgnoreAuthenticatedClients' with default value to the original opendmarc.conf file
#
_param="IgnoreAuthenticatedClients"
echononl " Add '${_param}' with default value to the opendmarc.conf file.."
if ! $(grep -q -E "^${_param}\s+" ${opendmarc_conf_file} 2> /dev/null) ; then
cat << EOF >> ${opendmarc_conf_file}
## If set, causes mail from authenticated clients (i.e., those that used
## SMTP AUTH) to be ignored by the filter. The default is "false".
#
IgnoreAuthenticatedClients false
EOF
if [[ $? -eq 0 ]] ; then
echo_ok
else
echo_failed
error "$(cat $log_file)"
fi
else
echo_skipped
fi
# - Add 'RequiredHeaders' with default value to the original opendmarc.conf file
#
_param="IgnoreAuthenticatedClients"
echononl " Add '${_param}' with default value to the opendmarc.conf file.."
if ! $(grep -q -E "^${_param}\s+" ${opendmarc_conf_file} 2> /dev/null) ; then
cat << EOF >> ${opendmarc_conf_file}
## If set, causes mail from authenticated clients (i.e., those that used
## SMTP AUTH) to be ignored by the filter. The default is "false".
#
IgnoreAuthenticatedClients false
EOF
if [[ $? -eq 0 ]] ; then
echo_ok
else
echo_failed
error "$(cat $log_file)"
fi
else
echo_skipped
fi
# - Add 'RequiredHeaders' with default value to the original opendmarc.conf file
#
_param="RequiredHeaders"
echononl " Add '${_param}' with default value to the opendmarc.conf file.."
if ! $(grep -q -E "^${_param}\s+" ${opendmarc_conf_file} 2> /dev/null) ; then
cat << EOF >> ${opendmarc_conf_file}
## If set, the filter will ensure the header of the message conforms to the basic
## header field count restrictions laid out in RFC5322, Section 3.6. Messages
## failing this test are rejected without further processing. A From: field from
## which no domain name could be extracted will also be rejected.
#
RequiredHeaders false
EOF
if [[ $? -eq 0 ]] ; then
echo_ok
else
echo_failed
error "$(cat $log_file)"
fi
else
echo_skipped
fi
# - Add 'AutoRestart' with default value to the original opendmarc.conf file
#
_param="AutoRestart"
echononl " Add '${_param}' with default value to the opendmarc.conf file.."
if ! $(grep -q -E "^${_param}\s+" ${opendmarc_conf_file} 2> /dev/null) ; then
cat << EOF >> ${opendmarc_conf_file}
## Automatically re-start on failures. Use with caution; if the filter fails
## instantly after it starts, this can cause a tight fork(2) loop.
#
AutoRestart false
EOF
if [[ $? -eq 0 ]] ; then
echo_ok
else
echo_failed
error "$(cat $log_file)"
fi
else
echo_skipped
fi
# - Add 'HistoryFile' with default value to the original opendmarc.conf file
#
_param="HistoryFile"
echononl " Add '${_param}' with default value to the opendmarc.conf file.."
if ! $(grep -q -E "^${_param}\s+" ${opendmarc_conf_file} 2> /dev/null) ; then
cat << EOF >> ${opendmarc_conf_file}
## If set, specifies the location of a text file to which records are written
## that can be used to generate DMARC aggregate reports. Records are batches of
## rows containing information about a single received message, and include all
## relevant information needed to generate a DMARC aggregate report. It is
## expected that this will not be used in its raw form, but rather periodically
## imported into a relational database from which the aggregate reports can be
## extracted using opendmarc-importstats(8).
#
HistoryFile /run/opendmarc/opendmarc.dat
EOF
if [[ $? -eq 0 ]] ; then
echo_ok
else
echo_failed
error "$(cat $log_file)"
fi
else
echo_skipped
fi
# - Add 'SPFIgnoreResults' with default value to the original opendmarc.conf file
#
_param="SPFIgnoreResults"
echononl " Add '${_param}' with default value to the opendmarc.conf file.."
if ! $(grep -q -E "^${_param}\s+" ${opendmarc_conf_file} 2> /dev/null) ; then
cat << EOF >> ${opendmarc_conf_file}
## Causes the filter to ignore any SPF results in the header of the message. This
## is useful if you want the filter to perform SPF checks itself, or because you
## don't trust the arriving header. The default is "false".
#
SPFIgnoreResults false
EOF
if [[ $? -eq 0 ]] ; then
echo_ok
else
echo_failed
error "$(cat $log_file)"
fi
else
echo_skipped
fi
# - Add 'SPFSelfValidate' with default value to the original opendmarc.conf file
#
_param="SPFSelfValidate"
echononl " Add '${_param}' with default value to the opendmarc.conf file.."
if ! $(grep -q -E "^${_param}\s+" ${opendmarc_conf_file} 2> /dev/null) ; then
cat << EOF >> ${opendmarc_conf_file}
## Causes the filter to perform a fallback SPF check itself when it can find no
## SPF results in the message header. If SPFIgnoreResults is also set, it never
## looks for SPF results in headers and always performs the SPF check itself when
## this is set. The default is "false".
#
SPFSelfValidate false
EOF
if [[ $? -eq 0 ]] ; then
echo_ok
else
echo_failed
error "$(cat $log_file)"
fi
else
echo_skipped
fi
# - Save configuration file from distribution # - Save configuration file from distribution
# - # -
echononl " Save configuration file from distribution" echononl " Save configuration file from distribution"

File diff suppressed because it is too large Load Diff

View File

@ -78,6 +78,50 @@ echo_skipped() {
echo -e "\033[80G[ \033[33m\033[1mskipped\033[m ]" echo -e "\033[80G[ \033[33m\033[1mskipped\033[m ]"
} }
blank_line() {
if $terminal ; then
echo ""
fi
}
trim() {
local var="$*"
var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters
var="${var%"${var##*[![:space:]]}"}" # remove trailing whitespace characters
echo -n "$var"
}
detect_os_1 () {
if $(which lsb_release > /dev/null 2>&1) ; then
os_dist="$(lsb_release -i | awk '{print tolower($3)}')"
os_version="$(lsb_release -r | awk '{print tolower($2)}')"
os_codename="$(lsb_release -c | awk '{print tolower($2)}')"
if [[ "$os_dist" = "debian" ]]; then
if $(echo "$os_version" | grep -q '\.') ; then
os_version=$(echo "$os_version" | cut --delimiter='.' -f1)
fi
fi
elif [[ -e "/etc/os-release" ]]; then
. /etc/os-release
os_dist=$ID
os_version=${VERSION_ID}
fi
# remove whitespace from os_dist and os_version
os_dist="${os_dist// /}"
os_version="${os_version// /}"
}
# ------------- # -------------
# --- Some default settings # --- Some default settings
@ -85,7 +129,9 @@ echo_skipped() {
DEFAULT_ADMIN_EMAIL="argus@oopen.de" DEFAULT_ADMIN_EMAIL="argus@oopen.de"
DEFAULT_RELAY_HOST="b.mx.oopen.de" DEFAULT_RELAY_HOST="b.mx.oopen.de"
DEFAULT_RELAY_PORT=25
DEFAULT_SASL_AUTH=false DEFAULT_SASL_AUTH=false
DEFAULT_REWRITE_SENDER_DOMAIN=None
# - Is this a systemd system? # - Is this a systemd system?
@ -118,8 +164,19 @@ if [[ -z "$_HOSTNAME" ]] ; then
[[ "$_HOSTNAME" = "$_HOSTNAME_SHORT" ]] && _HOSTNAME="" [[ "$_HOSTNAME" = "$_HOSTNAME_SHORT" ]] && _HOSTNAME=""
fi fi
blank_line
echononl "Detect distribution/release of running OS.."
detect_os_1 > /dev/null 2>&1
if [[ $? -ne 0 ]]; then
echo_failed
else
echo_ok
fi
blank_line
blank_line
clear
#clear
echo -e "\033[21G\033[32mInstallation script for Postfix basic mailsystem \033[m" echo -e "\033[21G\033[32mInstallation script for Postfix basic mailsystem \033[m"
echo echo
@ -208,7 +265,7 @@ else
fi fi
done done
fi fi
if [ "X$IPV6" = "Xnone" -o "X$IPV6" = "XNone" ]; then if [ "X$IPV6" = "Xnone" -o "X$IPV6" = "XNone" ]; then
IPV6=disabled IPV6=disabled
fi fi
@ -221,7 +278,7 @@ echo "Insert e-mail address where messages to local root should be forwarded"
echo "" echo ""
echo "" echo ""
if [[ -n "$_ADMIN_EMAIL" ]]; then if [[ -n "$_ADMIN_EMAIL" ]]; then
echononl "Admin e-mail address [$_ADMIN_EMAIL]: " echononl "Admin e-mail address [$_ADMIN_EMAIL]: "
read ADMIN_EMAIL read ADMIN_EMAIL
if [[ "X${ADMIN_EMAIL}" = "X" ]]; then if [[ "X${ADMIN_EMAIL}" = "X" ]]; then
ADMIN_EMAIL=$_ADMIN_EMAIL ADMIN_EMAIL=$_ADMIN_EMAIL
@ -284,13 +341,17 @@ fi
# --- Some further default values depending on sasl authentification # --- Some further default values depending on sasl authentification
# ------------- # -------------
# - Set default value for relay host if sasl authentification should be # - Set default value for relay host / relay port if sasl authentification should be
# - supported and value for _RELAY_HOST not given # - supported and value for _RELAY_HOST / _RELAY_PORT not given
# - # -
if [[ "$SASL_AUTH" = "yes" ]] || $SASL_AUTH ; then if [[ "$SASL_AUTH" = "yes" ]] || $SASL_AUTH ; then
[[ -z "$_RELAY_HOST" ]] && _RELAY_HOST="$DEFAULT_RELAY_HOST" [[ -z "$_RELAY_HOST" ]] && _RELAY_HOST="$DEFAULT_RELAY_HOST"
[[ -z "$_RELAY_PORT" ]] && _RELAY_PORT="$DEFAULT_RELAY_PORT"
fi fi
if [[ -z ${_REWRITE_SENDER_DOMAIN} ]] ; then
_REWRITE_SENDER_DOMAIN="${DEFAULT_REWRITE_SENDER_DOMAIN}"
fi
if [[ "$SASL_AUTH" = "yes" ]] || $SASL_AUTH ; then if [[ "$SASL_AUTH" = "yes" ]] || $SASL_AUTH ; then
@ -357,11 +418,57 @@ if [[ "$SASL_AUTH" = "yes" ]] || $SASL_AUTH ; then
fi fi
RELAY_PORT=
echo ""
echo "Insert the target port to connect to ${RELAY_HOST}"
echo ""
if [[ -n "$_RELAY_PORT" ]];then
echononl "(target) Port on ${RELAY_HOST} [$_RELAY_PORT]: "
read RELAY_PORT
if [[ "X${RELAY_PORT}" = "X" ]]; then
RELAY_PORT=$_RELAY_PORT
fi
else
while [[ "X${RELAY_PORT}" = "X" ]]; do
echononl "(target) Port on ${RELAY_HOST}: "
read RELAY_PORT
if [[ "X${RELAY_PORT}" = "X" ]]; then
echo -e "\n\t\033[33m\033[1mi(target) Port of ${RELAY_HOST} is reqired\033[m\n"
fi
done
fi
else else
SASL_AUTH=false SASL_AUTH=false
fi fi
REWRITE_SENDER_DOMAIN=
echo ""
echo ""
echo -e "\033[33m** \033[32m-- \033[33m**\033[m"
echo ""
echo "Change the sender domain"
echo ""
echo -e "\t'\033[33mNone\033[m' if no change is desired"
echo ""
if [[ -n "${_REWRITE_SENDER_DOMAIN}" ]] ; then
echononl "New sender domain [${_REWRITE_SENDER_DOMAIN}]: "
read REWRITE_SENDER_DOMAIN
if [[ "X${REWRITE_SENDER_DOMAIN}" = "X" ]]; then
REWRITE_SENDER_DOMAIN="${_REWRITE_SENDER_DOMAIN}"
fi
else
while [[ "X${IPV6}" = "X" ]]; do
echononl "New sender domain: "
read REWRITE_SENDER_DOMAIN
if [[ "X${REWRITE_SENDER_DOMAIN}" = "X" ]]; then
REWRITE_SENDER_DOMAIN="None"
fi
done
fi
echo ""
echo -e "\033[33m** \033[32m-- \033[33m**\033[m"
echo "" echo ""
echo "" echo ""
@ -372,11 +479,18 @@ echo -e "\tIPv4 address.............: $IPV4"
echo -e "\tIPv6 address.............: $IPV6" echo -e "\tIPv6 address.............: $IPV6"
echo -e "\tAdmin e-mail.............: $ADMIN_EMAIL" echo -e "\tAdmin e-mail.............: $ADMIN_EMAIL"
echo "" echo ""
if [[ "$(trim ${REWRITE_SENDER_DOMAIN,,})" = 'none' ]] ; then
echo -e "\trewrite sender domain....: \033[33mNone\033[m"
else
echo -e "\trewrite sender domain....: $REWRITE_SENDER_DOMAIN"
fi
echo ""
echo -e "\tRelay using sasl auth....: $SASL_AUTH" echo -e "\tRelay using sasl auth....: $SASL_AUTH"
if $SASL_AUTH ; then if $SASL_AUTH ; then
echo -e "\t sasl user.............: $SASL_USER" echo -e "\t sasl user.............: $SASL_USER"
echo -e "\t sasl password.........: $SASL_PASS" echo -e "\t sasl password.........: $SASL_PASS"
echo -e "\t Relayhost.............: $RELAY_HOST" echo -e "\t Relayhost.............: $RELAY_HOST"
echo -e "\t Port on Relayhost.....: $RELAY_PORT"
fi fi
echo "" echo ""
echononl "einverstanden (yes/no): " echononl "einverstanden (yes/no): "
@ -397,7 +511,7 @@ cat << EOF > $conf_file
# --- # ---
# - Parameter Settings Postfix Bases System # - Parameter Settings Postfix Bases System
# - # -
# - - automated generated config file - # - - automated generated config file -
# --- # ---
_HOSTNAME=$HOSTNAME _HOSTNAME=$HOSTNAME
@ -408,6 +522,8 @@ _SASL_AUTH=$SASL_AUTH
_SASL_USER=$SASL_USER _SASL_USER=$SASL_USER
_SASL_PASS=$SASL_PASS _SASL_PASS=$SASL_PASS
_RELAY_HOST=$RELAY_HOST _RELAY_HOST=$RELAY_HOST
_RELAY_PORT=$RELAY_PORT
_REWRITE_SENDER_DOMAIN=$REWRITE_SENDER_DOMAIN
EOF EOF
if [[ $? -eq 0 ]] ; then if [[ $? -eq 0 ]] ; then
echo_ok echo_ok
@ -415,7 +531,7 @@ else
echo_failed echo_failed
fi fi
[[ "$IPV6" = "disabled" ]] && IPV6="" [[ "$IPV6" = "disabled" ]] && IPV6=""
# - Synchronise package index files with the repository # - Synchronise package index files with the repository
@ -520,7 +636,7 @@ append_dot_mydomain = no
readme_directory = /usr/share/doc/postfix readme_directory = /usr/share/doc/postfix
html_directory = /usr/share/doc/postfix/html html_directory = /usr/share/doc/postfix/html
## - The Internet protocols Postfix will attempt to use when making ## - The Internet protocols Postfix will attempt to use when making
## - or accepting connections. ## - or accepting connections.
## - DEFAULT: ipv4 ## - DEFAULT: ipv4
EOF EOF
@ -531,7 +647,7 @@ inet_protocols = ipv4, ipv6
#inet_interfaces = all #inet_interfaces = all
inet_interfaces = inet_interfaces =
127.0.0.1 127.0.0.1
::1 ::1
#$IPV4 #$IPV4
@ -539,14 +655,14 @@ inet_interfaces =
myhostname = $HOSTNAME myhostname = $HOSTNAME
mydestination = mydestination =
$HOSTNAME $HOSTNAME
localhost localhost
## - The list of "trusted" SMTP clients that have more ## - The list of "trusted" SMTP clients that have more
## - privileges than "strangers" ## - privileges than "strangers"
## - ## -
mynetworks = mynetworks =
127.0.0.0/8 127.0.0.0/8
[::ffff:127.0.0.0]/104 [::ffff:127.0.0.0]/104
[::1]/128 [::1]/128
@ -574,21 +690,34 @@ inet_interfaces =
myhostname = $HOSTNAME myhostname = $HOSTNAME
mydestination = mydestination =
$HOSTNAME $HOSTNAME
localhost localhost
## - The list of "trusted" SMTP clients that have more ## - The list of "trusted" SMTP clients that have more
## - privileges than "strangers" ## - privileges than "strangers"
## - ## -
mynetworks = mynetworks =
127.0.0.0/8 127.0.0.0/8
${IPV4}/32 EOF
smtp_bind_address = $IPV4 if [[ ${IPV4} =~ ^127 ]] ; then
smtp_bind_address6 = $IPV6
cat <<EOF >> /etc/postfix/main.cf
smtp_bind_address =
smtp_bind_address6 =
EOF EOF
else
cat <<EOF >> /etc/postfix/main.cf
${IPV4}/32
smtp_bind_address = $IPV4
#smtp_bind_address6 =
EOF
fi
fi fi
cat <<EOF >> /etc/postfix/main.cf cat <<EOF >> /etc/postfix/main.cf
@ -596,18 +725,18 @@ cat <<EOF >> /etc/postfix/main.cf
## - The method to generate the default value for the mynetworks parameter. ## - The method to generate the default value for the mynetworks parameter.
## - ## -
## - mynetworks_style = host" when Postfix should "trust" only the local machine ## - mynetworks_style = host" when Postfix should "trust" only the local machine
## - mynetworks_style = subnet (default value) "when Postfix should "trust" SMTP ## - mynetworks_style = subnet (default value) "when Postfix should "trust" SMTP
## - clients in the same IP subnetworks as the local machine. ## - clients in the same IP subnetworks as the local machine.
## - mynetworks_style = class" when Postfix should "trust" SMTP clients in the same ## - mynetworks_style = class" when Postfix should "trust" SMTP clients in the same
## - IP class A/B/C networks as the local machine. ## - IP class A/B/C networks as the local machine.
## - ## -
#mynetworks_style = host #mynetworks_style = host
## - The maximal size of any local(8) individual mailbox or maildir file, ## - The maximal size of any local(8) individual mailbox or maildir file,
## - or zero (no limit). In fact, this limits the size of any file that is ## - or zero (no limit). In fact, this limits the size of any file that is
## - written to upon local delivery, including files written by external ## - written to upon local delivery, including files written by external
## - commands that are executed by the local(8) delivery agent. ## - commands that are executed by the local(8) delivery agent.
## - ## -
mailbox_size_limit = 0 mailbox_size_limit = 0
@ -626,39 +755,51 @@ recipient_delimiter = +
alias_maps = alias_maps =
hash:/etc/aliases hash:/etc/aliases
## - The alias databases for local(8) delivery that are updated ## - The alias databases for local(8) delivery that are updated
## - with "newaliases" or with "sendmail -bi". ## - with "newaliases" or with "sendmail -bi".
## - ## -
alias_database = alias_database =
hash:/etc/aliases hash:/etc/aliases
## - Optional address mapping lookup tables for envelope and header sender ## - Optional address mapping lookup tables for envelope and header sender
## - addresses. The table format and lookups are documented in canonical(5). ## - addresses. The table format and lookups are documented in canonical(5).
## - ## -
## - Example: you want to rewrite the SENDER address "user@ugly.domain" ## - Example: you want to rewrite the SENDER address "user@ugly.domain"
## - to "user@pretty.domain", while still being able to send mail to the ## - to "user@pretty.domain", while still being able to send mail to the
## - RECIPIENT address "user@ugly.domain". ## - RECIPIENT address "user@ugly.domain".
## - ## -
## - Note: \$sender_canonical_maps is processed before \$canonical_maps. ## - Note: \$sender_canonical_maps is processed before \$canonical_maps.
## - ## -
sender_canonical_maps = btree:/etc/postfix/sender_canonical sender_canonical_maps =
btree:/etc/postfix/sender_canonical
## - The maximal time a message is queued before it is sent back as ## - smtp_generic_maps (default: empty)
## -
## - Optional lookup tables that perform address rewriting in the Postfix
## - SMTP client, typically to transform a locally valid address into a
## - globally valid address when sending mail across the Internet. This is
## - needed when the local machine does not have its own Internet domain name,
## -but uses something like localdomain.local instead.
## -
smtp_generic_maps =
btree:/etc/postfix/generic
## - The maximal time a message is queued before it is sent back as
## - undeliverable. Defaults to 5d (5 days) ## - undeliverable. Defaults to 5d (5 days)
## - Specify 0 when mail delivery should be tried only once. ## - Specify 0 when mail delivery should be tried only once.
## - ## -
maximal_queue_lifetime = 3d maximal_queue_lifetime = 3d
bounce_queue_lifetime = \$maximal_queue_lifetime bounce_queue_lifetime = \$maximal_queue_lifetime
## - delay_warning_time (default: 0h) ## - delay_warning_time (default: 0h)
## - ## -
## - The time after which the sender receives a copy of the message ## - The time after which the sender receives a copy of the message
## - headers of mail that is still queued. To enable this feature, ## - headers of mail that is still queued. To enable this feature,
## - specify a non-zero time value (an integral value plus an optional ## - specify a non-zero time value (an integral value plus an optional
## - one-letter suffix that specifies the time unit). ## - one-letter suffix that specifies the time unit).
## - Time units: s (seconds), m (minutes), h (hours), d (days), w (weeks). ## - Time units: s (seconds), m (minutes), h (hours), d (days), w (weeks).
## - The default time unit is h (hours). ## - The default time unit is h (hours).
delay_warning_time = 1d delay_warning_time = 1d
@ -685,9 +826,24 @@ smtp_sasl_auth_enable = yes
# Only offer SMTP AUTH when talking over an encrypted connection # Only offer SMTP AUTH when talking over an encrypted connection
smtpd_tls_auth_only = yes smtpd_tls_auth_only = yes
EOF
if [[ ${RELAY_PORT} -ne 25 ]] ; then
cat <<EOF >> /etc/postfix/main.cf
# Forwarding to the ip-adress of host b.mx.oopen.de
relayhost = [${RELAY_HOST}]:${RELAY_PORT}
EOF
else
cat <<EOF >> /etc/postfix/main.cf
# Forwarding to the ip-adress of host b.mx.oopen.de # Forwarding to the ip-adress of host b.mx.oopen.de
relayhost = [${RELAY_HOST}] relayhost = [${RELAY_HOST}]
EOF
fi
cat <<EOF >> /etc/postfix/main.cf
# File including login data # File including login data
smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
@ -696,7 +852,7 @@ smtp_sasl_password_maps = hash:/etc/postfix/sasl_passwd
smtp_sasl_security_options = noanonymous smtp_sasl_security_options = noanonymous
smtpd_sasl_tls_security_options = \$smtpd_sasl_security_options smtpd_sasl_tls_security_options = \$smtpd_sasl_security_options
# Report the SASL authenticated user name in the smtpd(8) Received message header. # Report the SASL authenticated user name in the smtpd(8) Received message header.
smtpd_sasl_authenticated_header = no smtpd_sasl_authenticated_header = no
@ -706,11 +862,11 @@ smtpd_sasl_authenticated_header = no
## - Aktiviert TLS für den Mailempfang ## - Aktiviert TLS für den Mailempfang
## - ## -
## - may: ## - may:
## - Opportunistic TLS. Use TLS if this is supported by the remote ## - Opportunistic TLS. Use TLS if this is supported by the remote
## - SMTP server, otherwise use plaintext ## - SMTP server, otherwise use plaintext
## - ## -
## - This overrides the obsolete parameters smtpd_use_tls and ## - This overrides the obsolete parameters smtpd_use_tls and
## - smtpd_enforce_tls. This parameter is ignored with ## - smtpd_enforce_tls. This parameter is ignored with
## - "smtpd_tls_wrappermode = yes". ## - "smtpd_tls_wrappermode = yes".
#smtpd_use_tls=yes #smtpd_use_tls=yes
smtp_tls_security_level=encrypt smtp_tls_security_level=encrypt
@ -730,11 +886,11 @@ relayhost =
## - Aktiviert TLS für den Mailempfang ## - Aktiviert TLS für den Mailempfang
## - ## -
## - may: ## - may:
## - Opportunistic TLS. Use TLS if this is supported by the remote ## - Opportunistic TLS. Use TLS if this is supported by the remote
## - SMTP server, otherwise use plaintext ## - SMTP server, otherwise use plaintext
## - ## -
## - This overrides the obsolete parameters smtpd_use_tls and ## - This overrides the obsolete parameters smtpd_use_tls and
## - smtpd_enforce_tls. This parameter is ignored with ## - smtpd_enforce_tls. This parameter is ignored with
## - "smtpd_tls_wrappermode = yes". ## - "smtpd_tls_wrappermode = yes".
#smtpd_use_tls=yes #smtpd_use_tls=yes
smtp_tls_security_level=may smtp_tls_security_level=may
@ -746,16 +902,16 @@ cat <<EOF >> /etc/postfix/main.cf
## - Aktiviert TLS für den Mailversand ## - Aktiviert TLS für den Mailversand
## - ## -
## - may: ## - may:
## - Opportunistic TLS: announce STARTTLS support to SMTP clients, ## - Opportunistic TLS: announce STARTTLS support to SMTP clients,
## - but do not require that clients use TLS encryption. ## - but do not require that clients use TLS encryption.
# smtp_use_tls=yes # smtp_use_tls=yes
smtpd_tls_security_level=may smtpd_tls_security_level=may
## - 0 Disable logging of TLS activity. ## - 0 Disable logging of TLS activity.
## - 1 Log TLS handshake and certificate information. ## - 1 Log TLS handshake and certificate information.
## - 2 Log levels during TLS negotiation. ## - 2 Log levels during TLS negotiation.
## - 3 Log hexadecimal and ASCII dump of TLS negotiation process. ## - 3 Log hexadecimal and ASCII dump of TLS negotiation process.
## - 4 Also log hexadecimal and ASCII dump of complete transmission after STARTTLS. ## - 4 Also log hexadecimal and ASCII dump of complete transmission after STARTTLS.
## - ## -
smtpd_tls_loglevel = 1 smtpd_tls_loglevel = 1
smtp_tls_loglevel = 1 smtp_tls_loglevel = 1
@ -764,7 +920,7 @@ smtpd_tls_cert_file = $_TLS_CERT_FILE
smtpd_tls_key_file = $_TLS_KEY_FILE smtpd_tls_key_file = $_TLS_KEY_FILE
## - File with DH parameters that the Postfix SMTP server should use with EDH ciphers. ## - File with DH parameters that the Postfix SMTP server should use with EDH ciphers.
## - ## -
## - Dont't forget to create it, e.g with openssl: ## - Dont't forget to create it, e.g with openssl:
## - openssl dhparam -out /etc/postfix/ssl/dh_1024.pem -2 1024 ## - openssl dhparam -out /etc/postfix/ssl/dh_1024.pem -2 1024
## - ## -
@ -773,92 +929,136 @@ smtpd_tls_key_file = $_TLS_KEY_FILE
## - ## -
smtpd_tls_dh1024_param_file = /etc/postfix/ssl/dh_2048.pem smtpd_tls_dh1024_param_file = /etc/postfix/ssl/dh_2048.pem
## - File with DH parameters that the Postfix SMTP server should use with EDH ciphers. ## - File with DH parameters that the Postfix SMTP server should use with EDH ciphers.
## - ## -
## - Dont't forget to create it, e.g with openssl: ## - Dont't forget to create it, e.g with openssl:
## - openssl dhparam -out /etc/postfix/ssl/dh_512.pem -2 512 ## - openssl dhparam -out /etc/postfix/ssl/dh_512.pem -2 512
## - ## -
smtpd_tls_dh512_param_file = /etc/postfix/ssl/dh_512.pem smtpd_tls_dh512_param_file = /etc/postfix/ssl/dh_512.pem
## - File containing CA certificates of root CAs trusted to sign either remote SMTP ## - File containing CA certificates of root CAs trusted to sign either remote SMTP
## - server certificates or intermediate CA certificates. These are loaded into ## - server certificates or intermediate CA certificates. These are loaded into
## - memory !! BEFORE !! the smtp(8) client enters the chroot jail. ## - memory !! BEFORE !! the smtp(8) client enters the chroot jail.
## - ## -
smtp_tls_CAfile = $_TLS_CA_FILE smtp_tls_CAfile = $_TLS_CA_FILE
## - Directory with PEM format certificate authority certificates that the Postfix SMTP ## - Directory with PEM format certificate authority certificates that the Postfix SMTP
## - client uses to verify a remote SMTP server certificate. Don't forget to create the ## - client uses to verify a remote SMTP server certificate. Don't forget to create the
## - necessary "hash" links with, for example, " ## - necessary "hash" links with, for example, "
## - $OPENSSL_HOME/bin/c_rehash /etc/postfix/certs". ## - $OPENSSL_HOME/bin/c_rehash /etc/postfix/certs".
## - ## -
## - !! Note !! ## - !! Note !!
## - To use this option in chroot mode, this directory (or a copy) must be inside ## - To use this option in chroot mode, this directory (or a copy) must be inside
## - the chroot jail. ## - the chroot jail.
## - ## -
## - Note that a chrooted daemon resolves all filenames relative to the Postfix ## - Note that a chrooted daemon resolves all filenames relative to the Postfix
## - queue directory (/var/spool/postfix) ## - queue directory (/var/spool/postfix)
## - ## -
#smtpd_tls_CApath = /etc/postfix/certs #smtpd_tls_CApath = /etc/postfix/certs
# Disable SSLv2 SSLv3 - Postfix SMTP server # Disable SSLv2 SSLv3 - Postfix SMTP server
#
# List of TLS protocols that the Postfix SMTP server will exclude or
# include with opportunistic TLS encryption.
smtpd_tls_protocols = !SSLv2, !SSLv3
#
# The SSL/TLS protocols accepted by the Postfix SMTP server
# with mandatory TLS encryption.
smtpd_tls_mandatory_protocols = !SSLv2, !SSLv3
# Disable SSLv2 SSLv3 - Postfix SMTP client
#
# List of TLS protocols that the Postfix SMTP client will exclude or
# include with opportunistic TLS encryption.
smtp_tls_protocols = !SSLv2, !SSLv3
#
# List of SSL/TLS protocols that the Postfix SMTP client will use
# with mandatory TLS encryption
smtp_tls_mandatory_protocols = !SSLv2, !SSLv3
## - Activate des "Ephemeral Elliptic Curve Diffie-Hellman" (EECDH) key exchange
## - openssl > 1.0
## -
smtpd_tls_eecdh_grade = strong
# standard list cryptographic algorithm
tls_preempt_cipherlist = yes
# Disable ciphers which are less than 256-bit:
# #
#smtpd_tls_mandatory_ciphers = high # List of TLS protocols that the Postfix SMTP server will exclude or
# include with opportunistic TLS encryption.
#smtpd_tls_protocols = !SSLv2, !SSLv3, !TLSv1
# TLS protocols accepted by the Postfix SMTP server with opportunistic TLS encryption.
# #
# opportunistic #smtpd_tls_protocols = >=TLSv1
smtpd_tls_ciphers = high
# TLS protocols accepted by the Postfix SMTP server with mandatory TLS encryption.
#
#smtpd_tls_mandatory_protocols = >=TLSv1
# TLS protocols that the Postfix SMTP client will use with opportunistic TLS encryption.
#
#smtp_tls_protocols = >=TLSv1
# The minimum TLS cipher grade that the Postfix SMTP server will use with mandatory TLS encryption.
#
smtp_tls_mandatory_protocols = >=TLSv1.2
# Exclude ciphers # The Postfix SMTP server security grade for ephemeral elliptic-curve
# Diffie-Hellman (EECDH) key exchange. As of Postfix 3.6, the value of this
# parameter is always ignored, and Postfix behaves as though the auto value
# (described below) was chosen.
#
# auto
# Use the most preferred curve that is supported by both the client and the server.
# This setting requires Postfix ≥ 3.2 compiled and linked with OpenSSL ≥ 1.0.2. This
# is the default setting under the above conditions (and the only setting used with
# Postfix ≥ 3.6).
#
# none
# Don't use EECDH. Ciphers based on EECDH key exchange will be disabled. This is the
# default in Postfix versions 2.6 and 2.7.
#
# strong
# Use EECDH with approximately 128 bits of security at a reasonable computational cost.
# This is the default in Postfix versions 2.8-3.5.
#
# ultra
# Use EECDH with approximately 192 bits of security at computational cost that is
# approximately twice as high as 128 bit strength ECC.
#
smtpd_tls_eecdh_grade = auto
# With SSLv3 and later, use the Postfix SMTP server's cipher preference order instead
# of the remote client's cipher preference order.
#
# By default, the OpenSSL server selects the client's most preferred cipher that the
# server supports. With SSLv3 and later, the server may choose its own most preferred
# cipher that is supported (offered) by the client.
#
# Setting "tls_preempt_cipherlist = yes" enables server cipher preferences.
#
# default: no
#
#tls_preempt_cipherlist = no
# The minimum TLS cipher grade that the Postfix SMTP server will use with mandatory
# TLS encryption. The default grade ("medium") is sufficiently strong that any benefit
# from globally restricting TLS sessions to a more stringent grade is likely negligible,
# especially given the fact that many implementations still do not offer any stronger
# ("high" grade) ciphers, while those that do, will always use "high" grade ciphers.
# So insisting on "high" grade ciphers is generally counter-productive. Allowing "export"
# or "low" ciphers is typically not a good idea, as systems limited to just these are
# limited to obsolete browsers. No known SMTP clients fail to support at least one
# "medium" or "high" grade cipher.
#
# default: medium
#
#smtpd_tls_mandatory_ciphers = medium
# The minimum TLS cipher grade that the Postfix SMTP server will use with opportunistic
# TLS encryption. Cipher types listed in smtpd_tls_exclude_ciphers are excluded from the
# base definition of the selected cipher grade.
#
# default: medium
#
#smtpd_tls_ciphers = medium
# List of ciphers or cipher types to exclude from the SMTP server cipher list at all
# TLS security levels.
#
# DO NOT exclude ciphers unless it is essential to do so. This is not an OpenSSL cipherlist;
# it is a simple list separated by whitespace and/or commas. The elements are a single cipher,
# or one or more "+" separated cipher properties, in which case only ciphers matching all the
# properties are excluded.
#
#smtpd_tls_exclude_ciphers = #smtpd_tls_exclude_ciphers =
# RC4
# aNULL # Additional list of ciphers or cipher types to exclude from the Postfix SMTP client cipher
# SEED-SHA # list at mandatory TLS security levels. This list works in addition to the exclusions listed
# EXP # with smtp_tls_exclude_ciphers
# MD5 #
smtpd_tls_exclude_ciphers = #smtp_tls_mandatory_exclude_ciphers =
aNULL
eNULL
EXPORT
DES
RC4
MD5
PSK
aECDH
EDH-DSS-DES-CBC3-SHA
EDH-RSA-DES-CDC3-SHA
KRB5-DE5, CBC3-SHA
smtpd_tls_session_cache_database = btree:\${data_directory}/smtpd_scache smtpd_tls_session_cache_database = btree:\${data_directory}/smtpd_scache
@ -870,8 +1070,8 @@ smtp_tls_session_cache_database = btree:\${data_directory}/smtp_scache
# smtpd_relay_restrictions # smtpd_relay_restrictions
# #
# IMPORTANT: Either the smtpd_relay_restrictions or the smtpd_recipient_restrictions # IMPORTANT: Either the smtpd_relay_restrictions or the smtpd_recipient_restrictions
# parameter must specify at least one of the following restrictions. Otherwise Postfix # parameter must specify at least one of the following restrictions. Otherwise Postfix
# will refuse to receive mail: # will refuse to receive mail:
# #
# reject, reject_unauth_destination # reject, reject_unauth_destination
@ -881,20 +1081,20 @@ smtp_tls_session_cache_database = btree:\${data_directory}/smtp_scache
# #
# The upstream default is: # The upstream default is:
# #
# smtpd_relay_restrictions = \${{\$compatibility_level} < {1} ? {} : # smtpd_relay_restrictions = \${{\$compatibility_level} < {1} ? {} :
# {permit_mynetworks, permit_sasl_authenticated, defer_unauth_destination}} # {permit_mynetworks, permit_sasl_authenticated, defer_unauth_destination}}
# #
# AGAIN, that means: if parameter compatibility_level is not set or compatibility_level is # AGAIN, that means: if parameter compatibility_level is not set or compatibility_level is
# set to '0', you MUST specify this value. Otherwise Postfix will refuse to receive mail # set to '0', you MUST specify this value. Otherwise Postfix will refuse to receive mail
# and you get the following error message: # and you get the following error message:
# #
# fatal: in parameter smtpd_relay_restrictions or smtpd_recipient_restrictions, specify # fatal: in parameter smtpd_relay_restrictions or smtpd_recipient_restrictions, specify
# at least one working instance of: reject_unauth_destination, defer_unauth_destination, # at least one working instance of: reject_unauth_destination, defer_unauth_destination,
# reject, defer, defer_if_permit or check_relay_domains # reject, defer, defer_if_permit or check_relay_domains
# #
#smtpd_relay_restrictions = #smtpd_relay_restrictions =
# permit_mynetworks, # permit_mynetworks,
# permit_sasl_authenticated, # permit_sasl_authenticated,
# defer_unauth_destination # defer_unauth_destination
EOF EOF
@ -903,8 +1103,21 @@ echo_ok
echononl " Configure SASL authentification" echononl " Configure SASL authentification"
if $SASL_AUTH ; then if $SASL_AUTH ; then
_sasl_pw_file="/etc/postfix/sasl_passwd"
if [[ -f "${_sasl_pw_file}" ]] && $(grep -q -E "^\[${RELAY_HOST}\]" ${_sasl_pw_file} 2> /dev/null); then
sed -i "/^\[${RELAY_HOST}/d" ${_sasl_pw_file}
if [[ "$?" != "0" ]]; then
error "Setting \"/etc/postfix/sasl_passwd\" failed! "
_failed=true
fi
fi
_failed=false _failed=false
echo "[$RELAY_HOST] ${SASL_USER}@${RELAY_HOST}:$SASL_PASS" > /etc/postfix/sasl_passwd if [[ ${RELAY_PORT} -ne 25 ]] ; then
echo "[$RELAY_HOST]:${RELAY_PORT} ${SASL_USER}@${RELAY_HOST}:$SASL_PASS" >> /etc/postfix/sasl_passwd
else
echo "[$RELAY_HOST] ${SASL_USER}@${RELAY_HOST}:$SASL_PASS" >> /etc/postfix/sasl_passwd
fi
if [[ "$?" != "0" ]]; then if [[ "$?" != "0" ]]; then
error "Setting \"/etc/postfix/sasl_passwd\" failed! " error "Setting \"/etc/postfix/sasl_passwd\" failed! "
_failed=true _failed=true
@ -978,7 +1191,7 @@ else
fi fi
## - create directory for certificates and copy certificates ## - create directory for certificates and copy certificates
## - and coresponding keys to /etc/postfix/ssl/ ## - and coresponding keys to /etc/postfix/ssl/
## - ## -
echononl " Create directory for certificates \"/etc/postfix/ssl\"" echononl " Create directory for certificates \"/etc/postfix/ssl\""
@ -994,45 +1207,95 @@ else
fi fi
## - generate DH parameters that the Postfix SMTP server should use ## - generate DH parameters that the Postfix SMTP server should use
## - with EDH ciphers (length 512 and 1024 ## - with EDH ciphers (length 512 and 1024
## - ## -
echononl " Generate DH key length=512 \"/etc/postfix/ssl/dh_512.pem\"" echononl " Generate DH key length=512 \"/etc/postfix/ssl/dh_512.pem\""
if [ ! -f /etc/postfix/ssl/dh_512.pem ]; then if [[ ! -f /etc/postfix/ssl/dh_512.pem ]]; then
#openssl dhparam -out /etc/postfix/ssl/dh_512.pem -2 512 > /dev/null 2>&1 if [[ "$os_dist" = "debian" ]] && [[ $os_version -gt 11 ]] ; then
openssl dhparam -dsaparam -out /etc/postfix/ssl/dh_512.pem 512 > /dev/null 2>&1 openssl dhparam -out /etc/postfix/ssl/dh_512.pem 512 > /dev/null 2>&1
else
openssl dhparam -dsaparam -out /etc/postfix/ssl/dh_512.pem 512 > /dev/null 2>&1
fi
if [[ $? -eq 0 ]] ; then if [[ $? -eq 0 ]] ; then
echo_ok echo_ok
else else
echo_failed echo_failed
fi fi
else else
echo_skipped if [[ "$os_dist" = "debian" ]] && [[ $os_version -gt 11 ]] ; then
if $(grep -q -E "X9.42" /etc/postfix/ssl/dh_512.pem 2> /dev/null); then
openssl dhparam -out /etc/postfix/ssl/dh_512.pem 512 > /dev/null 2>&1
if [[ $? -eq 0 ]] ; then
echo_ok
else
echo_failed
fi
else
echo_skipped
fi
else
echo_skipped
fi
fi fi
echononl " Generate DH key length=1024 \"/etc/postfix/ssl/dh_1024.pem\"" echononl " Generate DH key length=1024 \"/etc/postfix/ssl/dh_1024.pem\""
if [ ! -f /etc/postfix/ssl/dh_1024.pem ]; then if [[ ! -f /etc/postfix/ssl/dh_1024.pem ]]; then
#openssl dhparam -out /etc/postfix/ssl/dh_1024.pem -2 1024 > /dev/null 2>&1 if [[ "$os_dist" = "debian" ]] && [[ $os_version -gt 11 ]] ; then
openssl dhparam -dsaparam -out /etc/postfix/ssl/dh_1024.pem 1024 > /dev/null 2>&1 openssl dhparam -out /etc/postfix/ssl/dh_1024.pem 1024 > /dev/null 2>&1
else
openssl dhparam -dsaparam -out /etc/postfix/ssl/dh_1024.pem 1024 > /dev/null 2>&1
fi
if [[ $? -eq 0 ]] ; then if [[ $? -eq 0 ]] ; then
echo_ok echo_ok
else else
echo_failed echo_failed
fi fi
else else
echo_skipped if [[ "$os_dist" = "debian" ]] && [[ $os_version -gt 11 ]] ; then
if $(grep -q -E "X9.42" /etc/postfix/ssl/dh_1024.pem 2> /dev/null); then
openssl dhparam -out /etc/postfix/ssl/dh_1024.pem 1024 > /dev/null 2>&1
if [[ $? -eq 0 ]] ; then
echo_ok
else
echo_failed
fi
else
echo_skipped
fi
else
echo_skipped
fi
fi fi
echononl " Generate DH key length=2048 \"/etc/postfix/ssl/dh_2048.pem\"" echononl " Generate DH key length=2048 \"/etc/postfix/ssl/dh_2048.pem\""
if [ ! -f /etc/postfix/ssl/dh_2048.pem ]; then if [[ ! -f /etc/postfix/ssl/dh_2048.pem ]]; then
#openssl dhparam -out /etc/postfix/ssl/dh_2048.pem -2 2048 > /dev/null 2>&1 if [[ "$os_dist" = "debian" ]] && [[ $os_version -gt 11 ]] ; then
openssl dhparam -dsaparam -out /etc/postfix/ssl/dh_2048.pem 2048 > /dev/null 2>&1 openssl dhparam -out /etc/postfix/ssl/dh_2048.pem 2048 > /dev/null 2>&1
else
openssl dhparam -dsaparam -out /etc/postfix/ssl/dh_2048.pem 2048 > /dev/null 2>&1
fi
if [[ $? -eq 0 ]] ; then if [[ $? -eq 0 ]] ; then
echo_ok echo_ok
else else
echo_failed echo_failed
fi fi
else else
echo_skipped if [[ "$os_dist" = "debian" ]] && [[ $os_version -gt 11 ]] ; then
if $(grep -q -E "X9.42" /etc/postfix/ssl/dh_2048.pem 2> /dev/null); then
openssl dhparam -out /etc/postfix/ssl/dh_2048.pem 2048 > /dev/null 2>&1
if [[ $? -eq 0 ]] ; then
echo_ok
else
echo_failed
fi
else
echo_skipped
fi
else
echo_skipped
fi
fi fi
echononl " Create Symlink \"$_TLS_CERT_FILE\"" echononl " Create Symlink \"$_TLS_CERT_FILE\""
if [ ! -h "$_TLS_CERT_FILE" ]; then if [ ! -h "$_TLS_CERT_FILE" ]; then
ln -s /etc/ssl/certs/ssl-cert-snakeoil.pem $_TLS_CERT_FILE ln -s /etc/ssl/certs/ssl-cert-snakeoil.pem $_TLS_CERT_FILE
@ -1121,6 +1384,21 @@ else
echo_failed echo_failed
fi fi
echononl " Create file \"generic\""
if [[ "$(trim ${REWRITE_SENDER_DOMAIN,,})" = 'none' ]] ; then
touch /etc/postfix/generic
else
cat <<EOF > /etc/postfix/generic
@$(cat cat /etc/mailname) $(hostname)@$(trim ${REWRITE_SENDER_DOMAIN,,})
EOF
fi
postmap btree:/etc/postfix/generic
if [[ $? -eq 0 ]] ; then
echo_ok
else
echo_failed
fi
## - restart postfix ## - restart postfix
## - ## -
@ -1145,15 +1423,19 @@ fi
## - Omitt logging into system.log ## - Omitt logging into system.log
## - ## -
echononl " Create \"/etc/rsyslog.d/postfix.conf\"" echononl " Create \"/etc/rsyslog.d/postfix.conf\""
cat << EOF >> /etc/rsyslog.d/postfix.conf cat << EOF > /etc/rsyslog.d/postfix.conf
# Create an additional socket in postfix's chroot in order not to break
# mail logging when rsyslog is restarted. If the directory is missing,
# rsyslog will silently skip creating the socket.
\$AddUnixListenSocket /var/spool/postfix/dev/log
# #
# Logging for the mail system. Split it up so that # Logging for the mail system. Split it up so that
# it is easy to write scripts to parse these files. # it is easy to write scripts to parse these files.
# #
mail.info -/var/log/mail.info #mail.info -/var/log/mail.info
mail.warn -/var/log/mail.warn #mail.warn -/var/log/mail.warn
mail.err /var/log/mail.err #mail.err /var/log/mail.err
mail.* -/var/log/mail.log mail.* -/var/log/mail.log
& stop & stop
@ -1181,6 +1463,12 @@ else
fi fi
fi fi
if [[ ${RELAY_PORT} -ne 25 ]] ; then
echo ""
warn "Please do not forget to allow port \033[1m${RELAY_PORT}\033[m on both sides, outgoing
on this host here and incoming on the relay host '${RELAY_HOST}'."
fi
echo "" echo ""
clean_up 0 clean_up 0

View File

@ -126,6 +126,61 @@ detect_os_1 () {
} }
detect_mysql_version () {
_MYSQLD_VERSION="$(mysqld -V 2>/dev/null)"
if [[ -z "$_MYSQLD_VERSION" ]]; then
fatal "No installed MySQL server or distribution found!"
elif [[ -d "/usr/local/mysql" ]] && [[ "$(basename "$(realpath "/usr/local/mysql")")" =~ percona- ]]; then
MYSQL_CUR_DISTRIBUTION="Percona"
elif [[ "$_MYSQLD_VERSION" =~ MariaDB ]]; then
MYSQL_CUR_DISTRIBUTION="MariaDB"
elif [[ "$_MYSQLD_VERSION" =~ MySQL ]]; then
MYSQL_CUR_DISTRIBUTION="MySQL"
elif [[ -d "/usr/local/mysql" ]] && [[ "$(basename "$(realpath "/usr/local/mysql")")" =~ mysql- ]]; then
MYSQL_CUR_DISTRIBUTION="MySQL"
elif [[ -d "/usr/local/mysql" ]] && [[ "$(basename "$(realpath "/usr/local/mysql")")" =~ mariadb- ]]; then
MYSQL_CUR_DISTRIBUTION="MariaDB"
else
error "MySQL Instalation found, but cannot determin the distribution!"
MYSQL_CUR_DISTRIBUTION=
echo ""
echo " Select the installed MySQL distribution."
echo ""
echo " [1] MySQL (the original community edition)"
echo " [2] Percona Server for MySQL"
echo " [3] MariaDB"
echo ""
echononl " Eingabe [1/2/3]: "
while [ "$MYSQL_CUR_DISTRIBUTION" != "MySQL" -a "$MYSQL_CUR_DISTRIBUTION" != "MariaDB" -a "$MYSQL_CUR_DISTRIBUTION" != "Percona" ];do
read OPTION
case $OPTION in
1) MYSQL_CUR_DISTRIBUTION="MySQL"
;;
2) MYSQL_CUR_DISTRIBUTION="Percona"
;;
3) MYSQL_CUR_DISTRIBUTION="MariaDB"
;;
*) echo ""
echo -e "\tFalsche Eingabe ! [ 1 = MySQL ; 2 = Percona ; 3 = MariaDB ]"
echo ""
echononl " Eingabe:"
;;
esac
done
fi
MYSQL_VERSION="$(echo $_MYSQLD_VERSION | grep -o -E "[0-9]+\.[0-9]+\.[0-9]+(-[0-9]+)?" | head -n 1)"
MYSQL_MAJOR_VERSION="$(echo $MYSQL_VERSION | cut -d '.' -f1)"
MYSQL_MINOR_VERSION="$(echo $MYSQL_VERSION | cut -d '.' -f2)"
MYSQL_PATCH_LEVEL="$(echo $MYSQL_VERSION | cut -d '.' -f3)"
MYSQL_MAIN_VERSION="$(echo $MYSQL_VERSION | cut -d '.' -f1,2)"
}
# - Is 'systemd' supported on this system # - Is 'systemd' supported on this system
@ -228,14 +283,14 @@ else
fi fi
DEFAULT_POSTFIX_DB_NAME="postfix" DEFAULT_POSTFIX_DB_NAME="postfix"
DEFAULT_POSTFIX_DB_USER="postfix" DEFAULT_POSTFIX_DB_USER="postfix"
if [[ -f "/usr/local/mysql/sys-maint.cnf" ]] ; then #if [[ -f "/usr/local/mysql/sys-maint.cnf" ]] ; then
DEFAULT_MYSQL_CREDENTIALS="--defaults-file=/usr/local/mysql/sys-maint.cnf" # DEFAULT_MYSQL_CREDENTIALS="--defaults-file=/usr/local/mysql/sys-maint.cnf"
elif [[ -f "/etc/mysql/debian.cnf" ]] ; then #elif [[ -f "/etc/mysql/debian.cnf" ]] ; then
DEFAULT_MYSQL_CREDENTIALS="--defaults-file=/etc/mysql/debian.cnf" # DEFAULT_MYSQL_CREDENTIALS="--defaults-file=/etc/mysql/debian.cnf"
else #else
DEFAULT_MYSQL_CREDENTIALS="" # DEFAULT_MYSQL_CREDENTIALS=""
fi #fi
DEFAULT_DEBIAN_MYSQL_CREDENTIALS="/etc/mysql/debian.cnf" #DEFAULT_DEBIAN_MYSQL_CREDENTIALS="/etc/mysql/debian.cnf"
DEFAULT_DOVEADM_PW="/usr/local/dovecot/bin/doveadm pw" DEFAULT_DOVEADM_PW="/usr/local/dovecot/bin/doveadm pw"
DEFAULT_DELETED_MAILBOX_DIR="/var/deleted-maildirs" DEFAULT_DELETED_MAILBOX_DIR="/var/deleted-maildirs"
@ -341,11 +396,64 @@ fi
[[ -n "$MYSQL_DEBIAN_INSTALLATION" ]] || MYSQL_DEBIAN_INSTALLATION=false [[ -n "$MYSQL_DEBIAN_INSTALLATION" ]] || MYSQL_DEBIAN_INSTALLATION=false
if [[ "$POSTFIX_DB_TYPE" = "mysql" ]]; then if [[ "$POSTFIX_DB_TYPE" = "mysql" ]] ; then
if $MYSQL_DEBIAN_INSTALLATION ; then
[[ -n "$MYSQL_CREDENTIALS" ]] || MYSQL_CREDENTIALS="$DEFAULT_DEBIAN_MYSQL_CREDENTIALS" if [[ -z ${MYSQL_CREDENTIALS} ]] ; then
else
[[ -n "$MYSQL_CREDENTIALS" ]] || MYSQL_CREDENTIALS="$DEFAULT_MYSQL_CREDENTIALS" detect_mysql_version
if [[ "$MYSQL_CUR_DISTRIBUTION" = "MariaDB" ]] && ([[ $MYSQL_MAJOR_VERSION -gt 10 ]] \
|| ( [[ $MYSQL_MAJOR_VERSION -eq 10 ]] && [[ $MYSQL_MINOR_VERSION -gt 3 ]] )) ; then
if [[ -S "/tmp/mysql.sock" ]]; then
MYSQL_CREDENTIALS="-u root -S /tmp/mysql.sock"
elif [[ -S "/run/mysqld/mysqld.sock" ]]; then
MYSQL_CREDENTIALS="-u root -S /run/mysqld/mysqld.sock"
elif [[ -S "/var/run/mysqld/mysqld.sock" ]]; then
MYSQL_CREDENTIALS="-u root -S /var/run/mysqld/mysqld.sock"
else
fatal "Parameter 'MYSQL_CREDENTIALS' cannot be determined automated.
Use configuration file "$conf_file" to set
parameter manually."
fi
else
echononl "\tGet MySQL command.."
mysql_command="$(which mysql)"
if [[ $? -eq 0 ]]; then
echo_ok
else
if [[ -x "/usr/local/mysql/bin/mysql" ]]; then
mysql_command="/usr/local/mysql/bin/mysql"
echo_ok
else
echo_failed
fatal "$(cat $tmp_log_file)"
fi
fi
if $(${mysql_command} --login-path=local -e ";" > /dev/null 2>&1) ; then
MYSQL_CREDENTIALS="--login-path=local"
elif [[ -f "/usr/local/mysql/sys-maint.cnf" ]] ; then
MYSQL_CREDENTIALS="--defaults-file=/usr/local/mysql/sys-maint.cnf"
elif [[ -f "/etc/mysql/debian.cnf" ]] ; then
MYSQL_CREDENTIALS="--defaults-file=/etc/mysql/debian.cnf"
else
fatal "Parameter 'MYSQL_CREDENTIALS' cannot be determined automated.
Use configuration file "$conf_file" to set
parameter manually."
fi
fi
#if $MYSQL_DEBIAN_INSTALLATION ; then
# [[ -n "$MYSQL_CREDENTIALS" ]] || MYSQL_CREDENTIALS="$DEFAULT_DEBIAN_MYSQL_CREDENTIALS"
#else
# [[ -n "$MYSQL_CREDENTIALS" ]] || MYSQL_CREDENTIALS="$DEFAULT_MYSQL_CREDENTIALS"
#fi
fi fi
else else
[[ "$POSTFIX_DB_TYPE" = "pgsql" ]] || fatal "Unknown Database Type '$POSTFIX_DB_TYPE' (POSTFIX_DB_TYPE)" [[ "$POSTFIX_DB_TYPE" = "pgsql" ]] || fatal "Unknown Database Type '$POSTFIX_DB_TYPE' (POSTFIX_DB_TYPE)"
@ -406,12 +514,103 @@ else
fi fi
fi fi
# - Get activ PHP version, means that on which is part of $PATH environment
# -
echononl "\tGet PHP version in PATH environment.."
if $(which php > /dev/null 2>&1) ; then
php_version_in_path="$(php --version 2> /dev/null | head -1 | cut -d' ' -f2 | cut -d '-' -f1 2> /dev/null)"
if [[ $? -eq 0 ]] && [[ -n "${php_version_in_path}" ]]; then
echo_ok
else
echo_failed
fatal "Failed getting PHP Version.."
fi
else
echo_skipped
fatal "No PHP binary found in PATH environment.."
fi
_actual_config_file=""
_actual_password_hash=""
_actual_pfa_dir=""
_actual_pfa_documentroot=""
if [[ -d "${WEBSITE_BASEDIR}/htdocs" ]] ; then
PFA_UPDATE=true
_actual_pfa_documentroot="$(realpath "${WEBSITE_BASEDIR}/htdocs")"
if [[ "$(basename "$(dirname "${_actual_pfa_documentroot}")")" =~ ^postfixadmin ]]; then
_actual_pfa_dir="$(dirname "${_actual_pfa_documentroot}")"
else
_actual_pfa_dir="${_actual_pfa_documentroot}"
fi
else
PFA_UPDATE=false
fi
echononl "\tKeep passwordhasch from actual installation in mind.."
if [[ -n "$_actual_pfa_dir" && -d "$_actual_pfa_dir" ]] ; then
if [[ -f "${_actual_pfa_dir}/config.local.php" ]]; then
_actual_config_file="${_actual_pfa_dir}/config.local.php"
else
_actual_config_file="${_actual_pfa_dir}/config.inc.php"
fi
fi
if [[ -f "$_actual_config_file" ]]; then
_actual_password_hash="$(grep -E "^\s*\\\$CONF\['setup_password'\]" $_actual_config_file 2> /dev/null \
| grep -v changeme \
| awk -F '=' '{print$2}'\
| awk -F ';' '{print$1}')"
_actual_password_hash="${_actual_password_hash#"${_actual_password_hash%%[![:space:]]*}"}"
# - Remove trailing whitespace characters
_actual_password_hash="${_actual_password_hash%"${_actual_password_hash##*[![:space:]]}"}"
# - Remove leading single quote
_actual_password_hash="${_actual_password_hash#"${_actual_password_hash%%[!\']*}"}"
# - Remove trailing single quote
_actual_password_hash="${_actual_password_hash%"${_actual_password_hash##*[!\']}"}"
# - Remove leading double quote
_actual_password_hash="${_actual_password_hash#"${_actual_password_hash%%[!\"]*}"}"
# - Remove trailing double quote
_actual_password_hash="${_actual_password_hash%"${_actual_password_hash##*[!\"]}"}"
echo_ok
else
echo_skipped
fi
_installed_version=""
if $PFA_UPDATE ; then
echononl "\tDetermine installed version of PFA .."
_installed_version="$(echo "$(basename "${_actual_pfa_dir}")" | cut -d'-' -f2)"
echo_ok
fi
echo "" echo ""
echo "" echo ""
echo -e "\033[1;32mSettings for installation of \033[1;37mPostfix Admin / Vacation\033[m" echo -e "\033[1;32mSettings for installation of \033[1;37mPostfix Admin / Vacation\033[m"
echo "" echo ""
echo -e "\tPostfix Admin Version................: $PF_ADMIN_VERSION" if $PFA_UPDATE ; then
echo -e "\tUpdate Postfixadmin..................: YES"
if [[ -n "${_installed_version}" ]] ; then
echo -e "\tinstalled PFA verion.................: $_installed_version"
else
echo -e "\tinstalled PFA verion.................: "** \033[33mnot detected\033[m **
fi
if [[ -n "$_actual_password_hash" ]]; then
echo -e "\tactual Passwordhash..................: $_actual_password_hash"
else
echo -e "\tactual Passwordhash..................: ** \033[33mnot found\033[m **"
fi
else
echo -e "\tInstall Postfixadmin first time......: YES"
fi
echo ""
echo -e "\tPostfix Admin new Version............: $PF_ADMIN_VERSION"
echo "" echo ""
echo -e "\tName of the Website..................: $WEBSITE_NAME" echo -e "\tName of the Website..................: $WEBSITE_NAME"
echo "" echo ""
@ -439,8 +638,18 @@ echo ""
if $PHP_DEBIAN_INSTALLATION ; then if $PHP_DEBIAN_INSTALLATION ; then
echo -e "\tInstalled PHP version................: $php_major_version" echo -e "\tInstalled PHP version................: $php_major_version"
else else
echo -e "\tInstalled PHP versions...............: $php_major_versions" declare -i index=1
for _ver in $php_major_versions ; do
if [[ $index -eq 1 ]] ; then
echo -en "\tInstalled PHP versions...............: $_ver"
else
echo -en " $_ver"
fi
((index++))
done
echo ""
echo -e "\tNewest PHP Version...................: $php_latest_ver" echo -e "\tNewest PHP Version...................: $php_latest_ver"
echo -e "\tPHP Version of php binary in PATH....: $php_version_in_path"
fi fi
echo "" echo ""
if [[ "$POSTFIX_DB_TYPE" = "mysql" ]]; then if [[ "$POSTFIX_DB_TYPE" = "mysql" ]]; then
@ -509,45 +718,6 @@ _failed=false
> $log_file > $log_file
_actual_config_file=""
_actual_password_hash=""
_actual_pfa_dir=""
if [[ -d "${WEBSITE_BASEDIR}/htdocs" ]] ; then
_actual_pfa_dir="$(realpath "${WEBSITE_BASEDIR}/htdocs")"
fi
echononl "\tKeep passwordhasch from actual installation in mind.."
if [[ -n "$_actual_pfa_dir" && -d "$_actual_pfa_dir" ]] ; then
if [[ -f "${_actual_pfa_dir}/config.local.php" ]]; then
_actual_config_file="${_actual_pfa_dir}/config.local.php"
else
_actual_config_file="${_actual_pfa_dir}/config.inc.php"
fi
fi
if [[ -f "$_actual_config_file" ]]; then
_actual_password_hash="$(grep -E "^\s*\\\$CONF\['setup_password'\]" $_actual_config_file 2> /dev/null \
| grep -v changeme \
| awk -F '=' '{print$2}'\
| awk -F ';' '{print$1}')"
_actual_password_hash="${_actual_password_hash#"${_actual_password_hash%%[![:space:]]*}"}"
# - Remove trailing whitespace characters
_actual_password_hash="${_actual_password_hash%"${_actual_password_hash##*[![:space:]]}"}"
# - Remove leading single quote
_actual_password_hash="${_actual_password_hash#"${_actual_password_hash%%[!\']*}"}"
# - Remove trailing single quote
_actual_password_hash="${_actual_password_hash%"${_actual_password_hash##*[!\']}"}"
# - Remove leading double quote
_actual_password_hash="${_actual_password_hash#"${_actual_password_hash%%[!\"]*}"}"
# - Remove trailing double quote
_actual_password_hash="${_actual_password_hash%"${_actual_password_hash##*[!\"]}"}"
echo_ok
else
echo_skipped
fi
if [[ "$POSTFIX_DB_TYPE" = "mysql" ]] ; then if [[ "$POSTFIX_DB_TYPE" = "mysql" ]] ; then
echononl "\tCheck if database '$POSTFIX_DB_NAME' already exists.." echononl "\tCheck if database '$POSTFIX_DB_NAME' already exists.."
_db_response="$(mysql $MYSQL_CREDENTIALS -N -s -e \ _db_response="$(mysql $MYSQL_CREDENTIALS -N -s -e \
@ -630,9 +800,14 @@ else
if [[ ! -d "${WEBSITE_BASEDIR}" ]] ; then if [[ ! -d "${WEBSITE_BASEDIR}" ]] ; then
echo_skipped echo_skipped
else else
if [[ -n "$_installed_version" ]] ; then
_db_backup_file_name="${POSTFIX_DB_NAME}-pfa-${_installed_version}.${backup_date}.sql"
else
_db_backup_file_name="${POSTFIX_DB_NAME}-pfa.${backup_date}.sql"
fi
if [[ "$POSTFIX_DB_TYPE" = "mysql" ]]; then if [[ "$POSTFIX_DB_TYPE" = "mysql" ]]; then
echo -n " (MySQL).." echo -n " (MySQL).."
mysqldump $MYSQL_CREDENTIALS --opt $POSTFIX_DB_NAME > ${WEBSITE_BASEDIR}/${POSTFIX_DB_NAME}.${backup_date}.sql 2> $log_file mysqldump $MYSQL_CREDENTIALS --opt $POSTFIX_DB_NAME > ${WEBSITE_BASEDIR}/${_db_backup_file_name} 2> $log_file
if [[ $? -eq 0 ]]; then if [[ $? -eq 0 ]]; then
echo_ok echo_ok
else else
@ -646,7 +821,7 @@ else
fi fi
elif [[ "$POSTFIX_DB_TYPE" = "pgsql" ]]; then elif [[ "$POSTFIX_DB_TYPE" = "pgsql" ]]; then
echo -n " (PostgreSQL).." echo -n " (PostgreSQL).."
su - postgres -c "pg_dump -c $POSTFIX_DB_NAME" >> ${WEBSITE_BASEDIR}/${POSTFIX_DB_NAME}.${backup_date}.sql 2> $log_file su - postgres -c "pg_dump -c $POSTFIX_DB_NAME" >> ${WEBSITE_BASEDIR}/${_db_backup_file_name} 2> $log_file
if [[ $? -eq 0 ]]; then if [[ $? -eq 0 ]]; then
echo_ok echo_ok
else else
@ -1377,22 +1552,22 @@ EOF
cat <<EOF >> ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf 2>> $log_file cat <<EOF >> ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf 2>> $log_file
DocumentRoot "${WEBSITE_BASEDIR}/htdocs/" DocumentRoot "${WEBSITE_BASEDIR}/htdocs/"
<FilesMatch \.php$>
EOF EOF
if $PHP_DEBIAN_INSTALLATION ; then if $PHP_DEBIAN_INSTALLATION ; then
php_socket_file="/run/php/php${php_major_version}-fpm.sock" php_socket_file="/run/php/php${php_major_version}-fpm.sock"
if [[ -S "/run/php$(echo $php_major_version | cut -d'.' -f1)-fpm.sock" ]]; then if [[ -S "/run/php$(echo $php_major_version | cut -d'.' -f1)-fpm.sock" ]]; then
php_socket_file="/run/php$(echo $php_major_version | cut -d'.' -f1)-fpm.sock" php_socket_file="/run/php$(echo $php_major_version | cut -d'.' -f1)-fpm.sock"
fi fi
cat <<EOF >> ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf 2>> $log_file
SetHandler "proxy:unix:${php_socket_file}|fcgi://127.0.0.1"
EOF
else else
cat <<EOF >> ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf 2>> $log_file php_socket_file="/run/php/php-${php_latest_ver}-fpm.www.sock"
SetHandler "proxy:unix:/tmp/php-${php_latest_ver}-fpm.www.sock|fcgi://127.0.0.1" if [[ -S "/tmp/php-${php_latest_ver}-fpm.www.sock" ]]; then
EOF php_socket_file="/run/php/php-${php_latest_ver}-fpm.www.sock"
fi
fi fi
cat <<EOF >> ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf 2>> $log_file cat <<EOF >> ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf 2>> $log_file
<FilesMatch \.php$>
SetHandler "proxy:unix:${php_socket_file}|fcgi://127.0.0.1"
</FilesMatch> </FilesMatch>
<IfModule dir_module> <IfModule dir_module>
@ -1667,23 +1842,25 @@ fi
# - Encoding does not work as exspected. # - Encoding does not work as exspected.
# - # -
# - Update: Encoding seems to works now
# -
# - NOTE: # - NOTE:
# - this IS NOT a fix, but a workaround # - this IS NOT a fix, but a workaround
# - # -
echononl "\tWorkaround, because encoding does not work as exspected." #echononl "\tWorkaround, because encoding does not work as exspected."
# - Vacation script changed. Since Version 3.2 we need another perl regexp. ## - Vacation script changed. Since Version 3.2 we need another perl regexp.
# - The old one was: ## - The old one was:
# - perl -i -n -p -e "s/(\s*\'ctype\'\s* =>\s*)\'text\/plain.*$/\1\'text\/plain; charset=iso-8859-1\',/" \ ## - perl -i -n -p -e "s/(\s*\'ctype\'\s* =>\s*)\'text\/plain.*$/\1\'text\/plain; charset=iso-8859-1\',/" \
# - ## -
perl -i -n -p -e "s/(\s*\'Content-Type\'\s* =>\s*)\"text\/plain.*$/\1\"text\/plain; charset=iso-8859-1\",/" \ ##perl -i -n -p -e "s/(\s*\'Content-Type\'\s* =>\s*)\"text\/plain.*$/\1\"text\/plain; charset=iso-8859-1\",/" \
/var/spool/vacation/vacation.pl > "$log_file" 2>&1 ## /var/spool/vacation/vacation.pl > "$log_file" 2>&1
if [[ $? -eq 0 ]];then #if [[ $? -eq 0 ]];then
echo_ok # echo_ok
info "This IS NOT a fix, but a workaround." # info "This IS NOT a fix, but a workaround."
else #else
echo_failed # echo_failed
error "$(cat $log_file)" # error "$(cat $log_file)"
fi #fi
echononl "\tSet Permission on vacation script" echononl "\tSet Permission on vacation script"
_failed=false _failed=false
@ -2187,8 +2364,9 @@ fi
## - 'relay' // for backup mx ## - 'relay' // for backup mx
## - ); ## - );
## - $CONF['transport_default'] = 'lmtp:unix:private/dovecot-lmtp'; ## - $CONF['transport_default'] = 'lmtp:unix:private/dovecot-lmtp';
## - $CONF['vacation'] = 'YES'; ## - $CONF['vacation'] = 'NO';
## - $CONF['vacation_domain'] = '$AUTOREPLY_HOSTNAME'; ## - $CONF['vacation_domain'] = '$AUTOREPLY_HOSTNAME';
## - $CONF['password_expiration'] = 'NO';
## - ## -
echononl "\tAdjust Postfix Admin's Configuration - Part 3" echononl "\tAdjust Postfix Admin's Configuration - Part 3"
_failed=false _failed=false
@ -2213,10 +2391,12 @@ cat <<EOF >> $pfa_conf_file 2> $log_file
\$CONF['transport_default'] = 'lmtp:unix:private/dovecot-lmtp'; \$CONF['transport_default'] = 'lmtp:unix:private/dovecot-lmtp';
EOF EOF
perl -i -n -p -e "s#^(\s*\\\$CONF\['vacation'\]\s*=.*)#//!\1\n\\\$CONF['vacation'] = 'YES';#" \ perl -i -n -p -e "s#^(\s*\\\$CONF\['vacation'\]\s*=.*)#//!\1\n\\\$CONF['vacation'] = 'NO';#" \
$pfa_conf_file >> $log_file 2>&1 || _failed=true $pfa_conf_file >> $log_file 2>&1 || _failed=true
perl -i -n -p -e "s#^(\s*\\\$CONF\['vacation_domain'\]\s*=.*)#//!\1\n\\\$CONF['vacation_domain'] = '$AUTOREPLY_HOSTNAME';#" \ perl -i -n -p -e "s#^(\s*\\\$CONF\['vacation_domain'\]\s*=.*)#//!\1\n\\\$CONF['vacation_domain'] = '$AUTOREPLY_HOSTNAME';#" \
$pfa_conf_file >> $log_file 2>&1 || _failed=true $pfa_conf_file >> $log_file 2>&1 || _failed=true
perl -i -n -p -e "s#^(\s*\\\$CONF\['password_expiration'\]\s*=.*)#//!\1\n\\\$CONF['password_expiration'] = 'NO';#" \
$pfa_conf_file >> $log_file 2>&1 || _failed=true
if $_failed ; then if $_failed ; then
echo_failed echo_failed
error "$(cat $log_file)" error "$(cat $log_file)"
@ -2396,13 +2576,47 @@ fi
# - # -
echononl "\tTake passwordhash from previosly installation.." echononl "\tTake passwordhash from previosly installation.."
if [[ -n "$_actual_password_hash" ]] ; then if [[ -n "$_actual_password_hash" ]] ; then
perl -i -n -p -e "s#^(\s*\\\$CONF\['setup_password'\]\s*=.*)#//!\1\n\\\$CONF['setup_password'] = '$_actual_password_hash';#" \
$pfa_conf_file >> $log_file 2>&1 _failed=false
if [[ $? -eq 0 ]] ; then _backup_file="/tmp/$(basename "${pfa_conf_file}")"
echo_ok mv "$pfa_conf_file" "$_backup_file" > $log_file 2>&1
else if [[ $? -ne 0 ]] ; then
echo_failed _failed=true
fi fi
> $pfa_conf_file
_found=false
while IFS='' read -r _line || [[ -n $_line ]] ; do
if echo "$_line" | grep -i -E "^\s*\\\$CONF\['setup_password'\]\s*=.*;" > /dev/null 2>&1 ; then
echo -n '//!' >> $pfa_conf_file
echo "$_line" >> $pfa_conf_file
if ! $_found ; then
echo "\$CONF['setup_password'] = '$_actual_password_hash';" >> $pfa_conf_file
_found=true
fi
else
echo "$_line" >> $pfa_conf_file
fi
done < $_backup_file
if [[ $? -ne 0 ]] ; then
_failed=true
fi
if $_failed ; then
echo_failed
else
echo_ok
fi
#perl -i -n -p -e "s#^(\s*\\\$CONF\['setup_password'\]\s*=.*)#//!\1\n\\\$CONF['setup_password'] = '$_actual_password_hash';#" \
# $pfa_conf_file > $log_file 2>&1
#if [[ $? -eq 0 ]] ; then
# echo_ok
#else
# echo_failed
#fi
else else
echo_skipped echo_skipped
fi fi
@ -3331,6 +3545,11 @@ fi
echo "" echo ""
info "Browse to \033[1mhttp://${WEBSITE_NAME}/setup.php\033[m to create a 'setup password'\n$(cat <<EOF info "Browse to \033[1mhttp://${WEBSITE_NAME}/setup.php\033[m to create a 'setup password'\n$(cat <<EOF
\t \033[33mIn caes of updating postfix.admin browse this URL and \033[1mlogin with your
\t setup_password\033[m\033[33m, because only after that the database '${POSTFIX_DB_NAME}'
\t will be updated. If you don't know this password, create a new one. This is also
\t done within this interface.\033[m
\t If this is a fresh new installation, you have also to ceate one (ore more) \t If this is a fresh new installation, you have also to ceate one (ore more)
\t superadmin account(s). \t superadmin account(s).
@ -3354,6 +3573,14 @@ info "Browse to \033[1mhttp://${WEBSITE_NAME}/setup.php\033[m to create a 'setup
EOF EOF
)" )"
if [[ -n "$_actual_password_hash" ]] ; then
info "The Parameter \$CONF['setup_password'] was set as follows:\n$(cat <<EOF
\t \$CONF['setup_password'] = '${_actual_password_hash}';
EOF
)"
fi
echo "" echo ""
clean_up 0 clean_up 0

View File

@ -108,6 +108,62 @@ is_number() {
#return $([[ ! -z "${1##*[!0-9]*}" ]]) #return $([[ ! -z "${1##*[!0-9]*}" ]])
} }
detect_mysql_version () {
_MYSQLD_VERSION="$(mysqld -V 2>/dev/null)"
if [[ -z "$_MYSQLD_VERSION" ]]; then
fatal "No installed MySQL server or distribution found!"
elif [[ -d "/usr/local/mysql" ]] && [[ "$(basename "$(realpath "/usr/local/mysql")")" =~ percona- ]]; then
MYSQL_CUR_DISTRIBUTION="Percona"
elif [[ "$_MYSQLD_VERSION" =~ MariaDB ]]; then
MYSQL_CUR_DISTRIBUTION="MariaDB"
elif [[ "$_MYSQLD_VERSION" =~ MySQL ]]; then
MYSQL_CUR_DISTRIBUTION="MySQL"
elif [[ -d "/usr/local/mysql" ]] && [[ "$(basename "$(realpath "/usr/local/mysql")")" =~ mysql- ]]; then
MYSQL_CUR_DISTRIBUTION="MySQL"
elif [[ -d "/usr/local/mysql" ]] && [[ "$(basename "$(realpath "/usr/local/mysql")")" =~ mariadb- ]]; then
MYSQL_CUR_DISTRIBUTION="MariaDB"
else
error "MySQL Instalation found, but cannot determin the distribution!"
MYSQL_CUR_DISTRIBUTION=
echo ""
echo " Select the installed MySQL distribution."
echo ""
echo " [1] MySQL (the original community edition)"
echo " [2] Percona Server for MySQL"
echo " [3] MariaDB"
echo ""
echononl " Eingabe [1/2/3]: "
while [ "$MYSQL_CUR_DISTRIBUTION" != "MySQL" -a "$MYSQL_CUR_DISTRIBUTION" != "MariaDB" -a "$MYSQL_CUR_DISTRIBUTION" != "Percona" ];do
read OPTION
case $OPTION in
1) MYSQL_CUR_DISTRIBUTION="MySQL"
;;
2) MYSQL_CUR_DISTRIBUTION="Percona"
;;
3) MYSQL_CUR_DISTRIBUTION="MariaDB"
;;
*) echo ""
echo -e "\tFalsche Eingabe ! [ 1 = MySQL ; 2 = Percona ; 3 = MariaDB ]"
echo ""
echononl " Eingabe:"
;;
esac
done
fi
MYSQL_VERSION="$(echo $_MYSQLD_VERSION | grep -o -E "[0-9]+\.[0-9]+\.[0-9]+(-[0-9]+)?" | head -n 1)"
MYSQL_MAJOR_VERSION="$(echo $MYSQL_VERSION | cut -d '.' -f1)"
MYSQL_MINOR_VERSION="$(echo $MYSQL_VERSION | cut -d '.' -f2)"
MYSQL_PATCH_LEVEL="$(echo $MYSQL_VERSION | cut -d '.' -f3)"
MYSQL_MAIN_VERSION="$(echo $MYSQL_VERSION | cut -d '.' -f1,2)"
}
trim() { trim() {
local var="$*" local var="$*"
var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters
@ -157,7 +213,7 @@ fi
while IFS='' read -r -d '' _conf_file ; do while IFS='' read -r -d '' _conf_file ; do
WEBSITE_NAME="$(grep -E "^WEBSITE_NAME" "${_conf_file}" 2>/dev/null | cut -d"=" -f2)" WEBSITE_NAME="$(grep -E "^WEBSITE_NAME" "${_conf_file}" 2>/dev/null | cut -d"=" -f2)"
#Remove leading / trailling double quotes #Remove leading / trailling double quotes
@ -208,7 +264,7 @@ read _IN
conf_file=${_arr[1]} conf_file=${_arr[1]}
_OK=true _OK=true
else else
echo "" echo ""
echo -e "\tFalsche Eingabe !" echo -e "\tFalsche Eingabe !"
echo "" echo ""
echononl " Eingabe: " echononl " Eingabe: "
@ -296,8 +352,6 @@ DEFAULT_APACHE_VHOST_DIR="/usr/local/apache2/conf/vhosts"
DEFAULT_DB_HOST="localhost" DEFAULT_DB_HOST="localhost"
DEFAULT_DB_NAME="roundcubemail" DEFAULT_DB_NAME="roundcubemail"
DEFAULT_DB_USER="roundcube" DEFAULT_DB_USER="roundcube"
DEFAULT_DEBIAN_MYSQL_CREDENTIALS="--defaults-file=/etc/mysql/debian.cnf"
DEFAULT_MYSQL_CREDENTIALS="--defaults-file=/usr/local/mysql/sys-maint.cnf"
[[ -n "$ROUNDCUBE_VERSION" ]] || fatal "Roundcube Version (ROUNDCUBE_VERSION) not present!" [[ -n "$ROUNDCUBE_VERSION" ]] || fatal "Roundcube Version (ROUNDCUBE_VERSION) not present!"
[[ -n "$WEBSITE_NAME" ]] || fatal "Website's name (WEBSITE_NAME) not present!" [[ -n "$WEBSITE_NAME" ]] || fatal "Website's name (WEBSITE_NAME) not present!"
@ -316,8 +370,8 @@ HOSTNAME_SHORT=${_tmp_string%%.*}
if [[ -z "$IPV4" ]] && [[ -z "$IPV6" ]] ; then if [[ -z "$IPV4" ]] && [[ -z "$IPV6" ]] ; then
fatal "Neither an IPv4 nor an IPv6 address are given.!" fatal "Neither an IPv4 nor an IPv6 address are given.!"
else else
[[ -n "$IPV4" ]] || warn "IPv4 Address not present!" [[ -n "$IPV4" ]] || warn "IPv4 Address not present!"
[[ -n "$IPV6" ]] || warn "IPv6 Address not present!" [[ -n "$IPV6" ]] || warn "IPv6 Address not present!"
fi fi
[[ -n "$APACHE_DEBIAN_INSTALLATION" ]] || APACHE_DEBIAN_INSTALLATION=false [[ -n "$APACHE_DEBIAN_INSTALLATION" ]] || APACHE_DEBIAN_INSTALLATION=false
@ -349,12 +403,12 @@ if [ -x "$httpd_binary" ];then
IS_HTTPD_RUNNING=true IS_HTTPD_RUNNING=true
fi fi
fi fi
[[ -n "$HTTP_USER" ]] || HTTP_USER=$DEFAULT_HTTP_USER [[ -n "$HTTP_USER" ]] || HTTP_USER=$DEFAULT_HTTP_USER
[[ -n "$HTTP_GROUP" ]] || HTTP_GROUP=$DEFAULT_HTTP_GROUP [[ -n "$HTTP_GROUP" ]] || HTTP_GROUP=$DEFAULT_HTTP_GROUP
[[ -n "$WEBMASTER_EMAIL" ]] || fatal "E-Mail (WEBMASTER_EMAIL) for webmaster not present!" [[ -n "$WEBMASTER_EMAIL" ]] || fatal "E-Mail (WEBMASTER_EMAIL) for webmaster not present!"
[[ -n "$WEBSITE_BASEDIR" ]] || WEBSITE_BASEDIR=$DEFAULT_WEBSITE_BASEDIR [[ -n "$WEBSITE_BASEDIR" ]] || WEBSITE_BASEDIR=$DEFAULT_WEBSITE_BASEDIR
if [[ -z "$APACHE_CERT_DIR" ]] ; then if [[ -z "$APACHE_CERT_DIR" ]] ; then
if $APACHE_DEBIAN_INSTALLATION ; then if $APACHE_DEBIAN_INSTALLATION ; then
@ -395,16 +449,76 @@ fi
[[ -n "$MYSQL_DEBIAN_INSTALLATION" ]] || MYSQL_DEBIAN_INSTALLATION=false [[ -n "$MYSQL_DEBIAN_INSTALLATION" ]] || MYSQL_DEBIAN_INSTALLATION=false
if [[ "$DB_TYPE" = "mysql" ]]; then
if $MYSQL_DEBIAN_INSTALLATION ; then if [ "$DB_TYPE" = "postgres" -o "$DB_TYPE" = "postgresql" -o "$DB_TYPE" = "pgsql" -o "$DB_TYPE" = "psql" ];then
[[ -n "$MYSQL_CREDENTIALS" ]] || MYSQL_CREDENTIALS="$DEFAULT_DEBIAN_MYSQL_CREDENTIALS" DB_TYPE="pgsql"
else fi
[[ -n "$MYSQL_CREDENTIALS" ]] || MYSQL_CREDENTIALS="$DEFAULT_MYSQL_CREDENTIALS"
if [[ "$DB_TYPE" = "mysql" ]] ; then
if [[ -z ${MYSQL_CREDENTIALS} ]] ; then
detect_mysql_version
if [[ "$MYSQL_CUR_DISTRIBUTION" = "MariaDB" ]] && ([[ $MYSQL_MAJOR_VERSION -gt 10 ]] \
|| ( [[ $MYSQL_MAJOR_VERSION -eq 10 ]] && [[ $MYSQL_MINOR_VERSION -gt 3 ]] )) ; then
if [[ -S "/tmp/mysql.sock" ]]; then
MYSQL_CREDENTIALS="-u root -S /tmp/mysql.sock"
elif [[ -S "/run/mysqld/mysqld.sock" ]]; then
MYSQL_CREDENTIALS="-u root -S /run/mysqld/mysqld.sock"
elif [[ -S "/var/run/mysqld/mysqld.sock" ]]; then
MYSQL_CREDENTIALS="-u root -S /var/run/mysqld/mysqld.sock"
else
fatal "Parameter 'MYSQL_CREDENTIALS' cannot be determined automated.
Use configuration file "$conf_file" to set
parameter manually."
fi
else
echononl "\tGet MySQL command.."
mysql_command="$(which mysql)"
if [[ $? -eq 0 ]]; then
echo_ok
else
if [[ -x "/usr/local/mysql/bin/mysql" ]]; then
mysql_command="/usr/local/mysql/bin/mysql"
echo_ok
else
echo_failed
fatal "$(cat $tmp_log_file)"
fi
fi
if $(${mysql_command} --login-path=local -e ";" > /dev/null 2>&1) ; then
MYSQL_CREDENTIALS="--login-path=local"
elif [[ -f "/usr/local/mysql/sys-maint.cnf" ]] ; then
MYSQL_CREDENTIALS="--defaults-file=/usr/local/mysql/sys-maint.cnf"
elif [[ -f "/etc/mysql/debian.cnf" ]] ; then
MYSQL_CREDENTIALS="--defaults-file=/etc/mysql/debian.cnf"
else
fatal "Parameter 'MYSQL_CREDENTIALS' cannot be determined automated.
Use configuration file "$conf_file" to set
parameter manually."
fi
fi
#if $MYSQL_DEBIAN_INSTALLATION ; then
# [[ -n "$MYSQL_CREDENTIALS" ]] || MYSQL_CREDENTIALS="$DEFAULT_DEBIAN_MYSQL_CREDENTIALS"
#else
# [[ -n "$MYSQL_CREDENTIALS" ]] || MYSQL_CREDENTIALS="$DEFAULT_MYSQL_CREDENTIALS"
#fi
fi fi
else else
[[ "$DB_TYPE" = "pgsql" ]] || fatal "Unknown Database Type '$DB_TYPE' (DB_TYPE)" [[ "$DB_TYPE" = "pgsql" ]] || fatal "Unknown Database Type '$DB_TYPE' (DB_TYPE)"
fi fi
[[ -n "$SPAM_FOLDER_NAME" ]] || SPAM_FOLDER_NAME=$DEFAULT_SPAM_FOLDER_NAME [[ -n "$SPAM_FOLDER_NAME" ]] || SPAM_FOLDER_NAME=$DEFAULT_SPAM_FOLDER_NAME
[[ -n "$SUPPORT_URL" ]] || SUPPORT_URL="http://www.${MAIN_DOMAIN}.$TLD" [[ -n "$SUPPORT_URL" ]] || SUPPORT_URL="http://www.${MAIN_DOMAIN}.$TLD"
@ -598,7 +712,7 @@ _log_dir=${_src_base_dir}/log-roundcube-$_version
# - REQUIREMENTS # - REQUIREMENTS
# - ============ # - ============
# - # -
# - * An IMAP, HTTP and SMTP server # - * An IMAP, HTTP and SMTP server
# - * .htaccess support allowing overrides for DirectoryIndex # - * .htaccess support allowing overrides for DirectoryIndex
# - * PHP Version 5.4 or greater including: # - * PHP Version 5.4 or greater including:
@ -695,7 +809,7 @@ if $PHP_DEBIAN_INSTALLATION ; then
echo_skipped echo_skipped
fi fi
done done
else else
for _version in $php_major_versions ; do for _version in $php_major_versions ; do
@ -995,7 +1109,7 @@ if $SKIN_LOGO_PRESENT ; then
cp -a "$(realpath "${tmp_dir}/${SKIN_LOGO_DIR}/${SKIN_LOGO_FILE}")" \ cp -a "$(realpath "${tmp_dir}/${SKIN_LOGO_DIR}/${SKIN_LOGO_FILE}")" \
"${WEBSITE_BASEDIR}/htdocs/${SKIN_LOGO_DIR}/${SKIN_LOGO_FILE}" >> $log_file 2>&1 "${WEBSITE_BASEDIR}/htdocs/${SKIN_LOGO_DIR}/${SKIN_LOGO_FILE}" >> $log_file 2>&1
fi fi
fi fi
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
echo_failed echo_failed
@ -1162,13 +1276,13 @@ if [[ "$PHP_TYPE" = "fcgid" ]] ; then
#!/bin/sh #!/bin/sh
export PHPRC="${WEBSITE_BASEDIR}/conf/" export PHPRC="${WEBSITE_BASEDIR}/conf/"
export TMPDIR="${WEBSITE_BASEDIR}/tmp" export TMPDIR="${WEBSITE_BASEDIR}/tmp"
# PHP child process management (PHP_FCGI_CHILDREN) should # PHP child process management (PHP_FCGI_CHILDREN) should
# always be disabled with mod_fcgid, which will only route one # always be disabled with mod_fcgid, which will only route one
# request at a time to application processes it has spawned; # request at a time to application processes it has spawned;
# thus, any child processes created by PHP will not be used # thus, any child processes created by PHP will not be used
# effectively. (Additionally, the PHP child processes may not # effectively. (Additionally, the PHP child processes may not
# be terminated properly.) By default, and with the environment # be terminated properly.) By default, and with the environment
# variable setting PHP_FCGI_CHILDREN=0, PHP child process # variable setting PHP_FCGI_CHILDREN=0, PHP child process
# management is disabled. # management is disabled.
PHP_FCGI_CHILDREN=0 PHP_FCGI_CHILDREN=0
export PHP_FCGI_CHILDREN export PHP_FCGI_CHILDREN
@ -1246,7 +1360,7 @@ EOF
fi fi
echononl "\tCreate file '${WEBSITE_BASEDIR}/logs/php_errors.log'.." echononl "\tCreate file '${WEBSITE_BASEDIR}/logs/php_errors.log'.."
if [[ ! -f "${WEBSITE_BASEDIR}/logs/php_errors.log" ]]; then if [[ ! -f "${WEBSITE_BASEDIR}/logs/php_errors.log" ]]; then
touch ${WEBSITE_BASEDIR}/logs/php_errors.log > $log_file 2>&1 touch ${WEBSITE_BASEDIR}/logs/php_errors.log > $log_file 2>&1
if [[ $? -ne 0 ]]; then if [[ $? -ne 0 ]]; then
@ -1333,7 +1447,7 @@ EOF
_failed=true _failed=true
error "$(cat $log_file)" error "$(cat $log_file)"
fi fi
if ! $_failed ; then if ! $_failed ; then
echo_ok echo_ok
fi fi
@ -1344,11 +1458,11 @@ fi
echo -e "\n\n\t\033[37m\033[1mConfigure Apache Webservice\033[m\n" echo -e "\n\n\t\033[37m\033[1mConfigure Apache Webservice\033[m\n"
SSLCertificateChainFile="" SSLCertificateChainFile=""
# - Create SSCertificateChainFile rule for apache vhost entry # - Create SSCertificateChainFile rule for apache vhost entry
# - # -
echononl "\tCreate SSCertificateChainFile rule for apache vhost entry" echononl "\tCreate SSCertificateChainFile rule for apache vhost entry"
if [ -n "$CERT_ChainFile" ];then if [ -n "$CERT_ChainFile" ];then
SSLCertificateChainFile="SSLCertificateChainFile ${APACHE_CERT_DIR}/$CERT_ChainFile" SSLCertificateChainFile="SSLCertificateChainFile ${APACHE_CERT_DIR}/$CERT_ChainFile"
echo_ok echo_ok
else else
@ -1474,7 +1588,7 @@ EOF
EOF EOF
else else
cat <<EOF >> ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf 2>> $log_file cat <<EOF >> ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf 2>> $log_file
SetHandler "proxy:unix:/tmp/php-${php_latest_ver}-fpm.www.sock|fcgi://127.0.0.1" SetHandler "proxy:unix:/run/php/php-${php_latest_ver}-fpm.www.sock|fcgi://127.0.0.1"
EOF EOF
fi fi
cat <<EOF >> ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf 2>> $log_file cat <<EOF >> ${APACHE_VHOST_DIR}/${WEBSITE_NAME}.conf 2>> $log_file
@ -1496,17 +1610,17 @@ EOF
# - X-Frame-Options # - X-Frame-Options
# - # -
# - The X-Frame-Options header (RFC), or XFO header, protects your visitors # - The X-Frame-Options header (RFC), or XFO header, protects your visitors
# - against clickjacking attacks. An attacker can load up an iframe on their # - against clickjacking attacks. An attacker can load up an iframe on their
# - site and set your site as the source, it's quite easy: # - site and set your site as the source, it's quite easy:
# - # -
# - <iframe src="https://scotthelme.co.uk"></iframe> # - <iframe src="https://scotthelme.co.uk"></iframe>
# - # -
# - Using some crafty CSS they can hide your site in the background and create some # - Using some crafty CSS they can hide your site in the background and create some
# - genuine looking overlays. When your visitors click on what they think is a harmless # - genuine looking overlays. When your visitors click on what they think is a harmless
# - link, they're actually clicking on links on your website in the background. That # - link, they're actually clicking on links on your website in the background. That
# - might not seem so bad until we realise that the browser will execute those requests # - might not seem so bad until we realise that the browser will execute those requests
# - in the context of the user, which could include them being logged in and authenticated # - in the context of the user, which could include them being logged in and authenticated
# - to your site! # - to your site!
# - # -
# - Troy Hunt has a great blog on 'Clickjack attack the hidden threat right in front : # - Troy Hunt has a great blog on 'Clickjack attack the hidden threat right in front :
@ -1514,49 +1628,49 @@ EOF
# - # -
# - http://www.troyhunt.com/2013/05/clickjack-attack-hidden-threat-right-in.html # - http://www.troyhunt.com/2013/05/clickjack-attack-hidden-threat-right-in.html
# - # -
# - Valid values include DENY meaning your site can't be framed, SAMEORIGIN which allows # - Valid values include DENY meaning your site can't be framed, SAMEORIGIN which allows
# - you to frame your own site or ALLOW-FROM https://example.com/ which lets you specify # - you to frame your own site or ALLOW-FROM https://example.com/ which lets you specify
# -sites that are permitted to frame your own site. # -sites that are permitted to frame your own site.
# - # -
Header always set X-Frame-Options "SAMEORIGIN" Header always set X-Frame-Options "SAMEORIGIN"
# - X-Xss-Protection # - X-Xss-Protection
# - # -
# - This header is used to configure the built in reflective XSS protection found # - This header is used to configure the built in reflective XSS protection found
# - in Internet Explorer, Chrome and Safari (Webkit). Valid settings for the header # - in Internet Explorer, Chrome and Safari (Webkit). Valid settings for the header
# - are 0, which disables the protection, 1 which enables the protection # - are 0, which disables the protection, 1 which enables the protection
# - and 1; mode=block which tells the browser to block the response if it # - and 1; mode=block which tells the browser to block the response if it
# - detects an attack rather than sanitising the script. # - detects an attack rather than sanitising the script.
# - # -
Header always set X-Xss-Protection "1; mode=block" Header always set X-Xss-Protection "1; mode=block"
# - X-Content-Type-Options # - X-Content-Type-Options
# - # -
# - Nice and easy to configure, this header only has one valid value, nosniff. # - Nice and easy to configure, this header only has one valid value, nosniff.
# - It prevents Google Chrome and Internet Explorer from trying to mime-sniff # - It prevents Google Chrome and Internet Explorer from trying to mime-sniff
# - the content-type of a response away from the one being declared by the server. # - the content-type of a response away from the one being declared by the server.
# - It reduces exposure to drive-by downloads and the risks of user uploaded content # - It reduces exposure to drive-by downloads and the risks of user uploaded content
# - that, with clever naming, could be treated as a different content-type, like # - that, with clever naming, could be treated as a different content-type, like
# - an executable. # - an executable.
# - # -
Header always set X-Content-Type-Options "nosniff" Header always set X-Content-Type-Options "nosniff"
# - Content Security Policy # - Content Security Policy
# - # -
# - The CSP header allows you to define a whitelist of approved sources of content # - The CSP header allows you to define a whitelist of approved sources of content
# - for your site. By restricting the assets that a browser can load for your site, # - for your site. By restricting the assets that a browser can load for your site,
# - like js and css, CSP can act as an effective countermeasure to XSS attacks. I # - like js and css, CSP can act as an effective countermeasure to XSS attacks. I
# - have covered CSP in a lot more detail in my blog Content Security Policy - An # - have covered CSP in a lot more detail in my blog Content Security Policy - An
# - Introduction (https://scotthelme.co.uk/content-security-policy-an-introduction/). # - Introduction (https://scotthelme.co.uk/content-security-policy-an-introduction/).
# - # -
# - Here is a basic policy to enforce TLS on all assets and prevent # - Here is a basic policy to enforce TLS on all assets and prevent
# - mixed content warnings. # - mixed content warnings.
# - # -
# - Allow Google Analytics, Google AJAX CDN and Same Origin # - Allow Google Analytics, Google AJAX CDN and Same Origin
# - script-src 'self' www.google-analytics.com ajax.googleapis.com; # - script-src 'self' www.google-analytics.com ajax.googleapis.com;
# - # -
# - Emmbedding Google Fonts # - Emmbedding Google Fonts
# - style-src 'self' 'unsafe-inline' https://fonts.googleapis.com; # - style-src 'self' 'unsafe-inline' https://fonts.googleapis.com;
# - # -
# - Allow YouTube Videos (iframe embedded) # - Allow YouTube Videos (iframe embedded)
# - frame-src 'self' https://www.youtube.com # - frame-src 'self' https://www.youtube.com
@ -1566,9 +1680,9 @@ EOF
# - Referrer-Policy # - Referrer-Policy
# - # -
# - The HTTP referer (originally a misspelling of referrer[1]) is an HTTP header # - The HTTP referer (originally a misspelling of referrer[1]) is an HTTP header
# - field that identifies the address of the webpage (i.e. the URI or IRI) that # - field that identifies the address of the webpage (i.e. the URI or IRI) that
# - linked to the resource being requested. By checking the referrer, the new # - linked to the resource being requested. By checking the referrer, the new
# - webpage can see where the request originated. # - webpage can see where the request originated.
# - # -
Header set Referrer-Policy "strict-origin-when-cross-origin" Header set Referrer-Policy "strict-origin-when-cross-origin"
@ -1775,7 +1889,7 @@ if ! $database_exists ; then
else else
echo_failed echo_failed
fi fi
elif [[ "$DB_TYPE" = "pgsql" ]]; then elif [[ "$DB_TYPE" = "pgsql" ]]; then
echo -n " (PostgreSQL).." echo -n " (PostgreSQL).."
echo "CREATE ROLE $DB_USER WITH LOGIN NOCREATEDB NOCREATEROLE NOSUPERUSER ENCRYPTED PASSWORD '$DB_PASS'" \ echo "CREATE ROLE $DB_USER WITH LOGIN NOCREATEDB NOCREATEROLE NOSUPERUSER ENCRYPTED PASSWORD '$DB_PASS'" \
| su - postgres -c "psql" > /dev/null | su - postgres -c "psql" > /dev/null
@ -1826,7 +1940,7 @@ info "Now browse to the intaller site and continue installation.\n$(cat <<EOF
Browse to site: \033[1mhttps://${WEBSITE_NAME}/installer\033[m Browse to site: \033[1mhttps://${WEBSITE_NAME}/installer\033[m
Maybe you want to change some values as follows Maybe you want to change some values as follows
General configuration: General configuration:
product_name...........: $PRODUCT_NAME product_name...........: $PRODUCT_NAME
@ -1850,10 +1964,9 @@ info "Now browse to the intaller site and continue installation.\n$(cat <<EOF
junk_mbox..............: $SPAM_FOLDER_NAME junk_mbox..............: $SPAM_FOLDER_NAME
SMTP Settings: SMTP Settings:
smtp_server............: tls://$(hostname -f) smtp_host..............: tls://$(hostname -f):587
smtp_port..............: 587
smtp_user/smtp_pass....: smtp_user/smtp_pass....:
[x] Use the current IMAP username and password for SMTP authentication [x] Use the current IMAP username and password for SMTP authentication
Display settings & user prefs: Display settings & user prefs:
@ -1923,7 +2036,7 @@ echononl "\tSet.. 'des_key', 'login_autocomplete', and more.."
cat <<EOF >>$WEBSITE_BASEDIR/roundcubemail-${ROUNDCUBE_VERSION}/config/config.inc.php 2> $log_file cat <<EOF >>$WEBSITE_BASEDIR/roundcubemail-${ROUNDCUBE_VERSION}/config/config.inc.php 2> $log_file
// ================================== // ==================================
// Added after basic installation // Added after basic installation
// ================================== // ==================================
\$config['skin_logo'] = '${SKIN_LOGO}'; \$config['skin_logo'] = '${SKIN_LOGO}';
@ -1966,9 +2079,10 @@ cat <<EOF >>$WEBSITE_BASEDIR/roundcubemail-${ROUNDCUBE_VERSION}/config/config.in
// SMTP // SMTP
// ---------------------------------- // ----------------------------------
// SMTP server host (for sending mails). // SMTP server host (and optional port number) for sending mails.
// Enter hostname with prefix tls:// to use STARTTLS, or use // Enter hostname with prefix ssl:// to use Implicit TLS, or use
// prefix ssl:// to use the deprecated SSL over SMTP (aka SMTPS) // prefix tls:// to use STARTTLS.
// If port number is omitted it will be set to 465 (for ssl://) or 587 otherwise.
// Supported replacement variables: // Supported replacement variables:
// %h - user's IMAP hostname // %h - user's IMAP hostname
// %n - hostname (\$_SERVER['SERVER_NAME']) // %n - hostname (\$_SERVER['SERVER_NAME'])
@ -1976,11 +2090,9 @@ cat <<EOF >>$WEBSITE_BASEDIR/roundcubemail-${ROUNDCUBE_VERSION}/config/config.in
// %d - domain (http hostname \$_SERVER['HTTP_HOST'] without the first part) // %d - domain (http hostname \$_SERVER['HTTP_HOST'] without the first part)
// %z - IMAP domain (IMAP hostname without the first part) // %z - IMAP domain (IMAP hostname without the first part)
// For example %n = mail.domain.tld, %t = domain.tld // For example %n = mail.domain.tld, %t = domain.tld
\$config['smtp_server'] = 'tls://$(hostname -f)'; // To specify different SMTP servers for different IMAP hosts provide an array
// of IMAP host (no prefix or port) and SMTP server e.g. ['imap.example.com' => 'smtp.example.net']
// SMTP port (default is 25; use 587 for STARTTLS or 465 for the \$config['smtp_host'] = 'tls://$(hostname -f):587';
// deprecated SSL over SMTP (aka SMTPS))
\$config['smtp_port'] = 587;
// SMTP username (if required) if you use %u as the username Roundcube // SMTP username (if required) if you use %u as the username Roundcube
// will use the current username for login // will use the current username for login
@ -2088,7 +2200,7 @@ cat <<EOF >>$WEBSITE_BASEDIR/roundcubemail-${ROUNDCUBE_VERSION}/config/config.in
// - 'pspell' - requires the PHP Pspell module and aspell installed // - 'pspell' - requires the PHP Pspell module and aspell installed
// - 'enchant' - requires the PHP Enchant module // - 'enchant' - requires the PHP Enchant module
// - 'atd' - install your own After the Deadline server or check with the people at http://www.afterthedeadline.com before using their API // - 'atd' - install your own After the Deadline server or check with the people at http://www.afterthedeadline.com before using their API
// Since Google shut down their public spell checking service, you need to // Since Google shut down their public spell checking service, you need to
// connect to a Nox Spell Server when using 'googie' here. Therefore specify the 'spellcheck_uri' // connect to a Nox Spell Server when using 'googie' here. Therefore specify the 'spellcheck_uri'
\$config['spellcheck_engine'] = 'pspell'; \$config['spellcheck_engine'] = 'pspell';
@ -2166,7 +2278,7 @@ if $INCLUDE_ACL_PLUGIN ; then
fi fi
echo -e "\tNothing more to do here. Plugin '$_plugin' will be added to array plugins later.." echo -e "\tNothing more to do here. Plugin '$_plugin' will be added to array plugins later.."
fi fi
@ -2213,7 +2325,7 @@ else
fi fi
echo -e "\tNothing more to do here. Plugin '$_plugin' will be added to array plugins later.." echo -e "\tNothing more to do here. Plugin '$_plugin' will be added to array plugins later.."
# - jqueryui # - jqueryui
# - # -
@ -2804,12 +2916,12 @@ if $VACATION_PLUGIN ; then
echo "$_line" >> $_config_file echo "$_line" >> $_config_file
echo "*/" >> $_config_file echo "*/" >> $_config_file
echo "\$config['${_key}'] = array(" >> $_config_file echo "\$config['${_key}'] = array(" >> $_config_file
if [[ "$POSTFIX_DB_TYPE" = "pgsql" ]]; then if [[ "$POSTFIX_DB_TYPE" = "pgsql" ]]; then
cat <<EOF >> $_config_file 2>> $log_file cat <<EOF >> $_config_file 2>> $log_file
"SELECT "SELECT
subject AS vacation_subject, subject AS vacation_subject,
body AS vacation_message, body AS vacation_message,
date(activefrom) AS vacation_start, date(activefrom) AS vacation_start,
date(activeuntil) AS vacation_end, date(activeuntil) AS vacation_end,
CASE WHEN vacation.active = TRUE THEN true ELSE false END AS vacation_enable, CASE WHEN vacation.active = TRUE THEN true ELSE false END AS vacation_enable,
@ -2882,7 +2994,7 @@ EOF
echo "$_line" >> $_config_file echo "$_line" >> $_config_file
echo "*/" >> $_config_file echo "*/" >> $_config_file
echo "\$config['${_key}'] = array(" >> $_config_file echo "\$config['${_key}'] = array(" >> $_config_file
if [[ "$POSTFIX_DB_TYPE" = "pgsql" ]]; then if [[ "$POSTFIX_DB_TYPE" = "pgsql" ]]; then
if $VAC_GUI_FORWARDER ; then if $VAC_GUI_FORWARDER ; then
@ -3144,7 +3256,7 @@ EOF
else else
echo_ok echo_ok
fi fi
fi fi
# - Create postfix trigger function udf_set_active # - Create postfix trigger function udf_set_active
@ -3243,7 +3355,7 @@ EOF
else else
echo_ok echo_ok
fi fi
fi fi
# - Create postfix trigger function udf_forwarders_in # - Create postfix trigger function udf_forwarders_in
@ -3342,7 +3454,7 @@ EOF
else else
echo_ok echo_ok
fi fi
fi fi
else else
echononl "\tCreate function 'FORWARDERS_OUT'" echononl "\tCreate function 'FORWARDERS_OUT'"
@ -3426,5 +3538,5 @@ else
fi fi
echo "" echo ""
clean_up 0 clean_up 0

11117
install_update_dovecot-2.4.sh Executable file

File diff suppressed because it is too large Load Diff

View File

@ -115,6 +115,35 @@ echo_skipped() {
echo -e "\033[71G[ \033[33m\033[1mskipped\033[m ]" echo -e "\033[71G[ \033[33m\033[1mskipped\033[m ]"
} }
detect_os_1 () {
if $(which lsb_release > /dev/null 2>&1) ; then
os_dist="$(lsb_release -i | awk '{print tolower($3)}')"
os_version="$(lsb_release -r | awk '{print tolower($2)}')"
os_codename="$(lsb_release -c | awk '{print tolower($2)}')"
if [[ "$os_dist" = "debian" ]]; then
if $(echo "$os_version" | grep -q '\.') ; then
os_version=$(echo "$os_version" | cut --delimiter='.' -f1)
fi
fi
elif [[ -e "/etc/os-release" ]]; then
. /etc/os-release
os_dist=$ID
os_version=${VERSION_ID}
fi
# remove whitespace from os_dist and os_version
os_dist="${os_dist// /}"
os_version="${os_version// /}"
}
# - Support systemd ? # - Support systemd ?
@ -134,6 +163,14 @@ else
fi fi
# - Detect OS - Set variable
# - os_dist
# - os_version
# - os_codename
# -
detect_os_1
echo echo
echononl "\tInclude Configuration file.." echononl "\tInclude Configuration file.."
if [[ ! -f $conf_file ]]; then if [[ ! -f $conf_file ]]; then
@ -203,7 +240,7 @@ fi
[[ -n "$dbname" ]] || dbname="postfix" [[ -n "$dbname" ]] || dbname="postfix"
[[ -n "$dbuser" ]] || dbuser="postfix" [[ -n "$dbuser" ]] || dbuser="postfix"
if [[ -z "$dbhost" ]] ; then if [[ -z "$dbhost" ]] ; then
[[ "$database" = "mysql" ]] && dbhost="unix:/run/mysqld/mysqld.sock" [[ "$database" = "mysql" ]] && dbhost="/run/mysqld/mysqld.sock"
[[ "$database" = "postgres" ]] && dbhost="/run/postgresql" [[ "$database" = "postgres" ]] && dbhost="/run/postgresql"
fi fi
@ -250,14 +287,21 @@ dovecot_main_version="$(echo $_version | cut -d '.' -f1,2)"
dovecot_major_version="$(echo $_version | cut -d '.' -f1)" dovecot_major_version="$(echo $_version | cut -d '.' -f1)"
dovecot_minor_version="$(echo $_version | cut -d '.' -f2)" dovecot_minor_version="$(echo $_version | cut -d '.' -f2)"
dovecot_patch_level="$(echo $_version | cut -d '.' -f3)" dovecot_patch_level="$(echo $_version | cut -d '.' -f3)"
dovecot_minor_patch_level="$(echo $_version | cut -d '.' -f4)"
_version_short="${_version%-*}"
#echo "" #echo ""
#echo "_version: $_version" #echo "_version: $_version"
#echo "dovecot_main_version $dovecot_main_version" #echo "dovecot_main_version $dovecot_main_version"
#echo "dovecot_major_version $dovecot_major_version" #echo "dovecot_major_version $dovecot_major_version"
#echo "dovecot_minor_version $dovecot_minor_version" #echo "dovecot_minor_version $dovecot_minor_version"
#echo "dovecot_patch_level $dovecot_patch_level" #echo "dovecot_patch_level $dovecot_patch_level"
#echo "dovecot_minor_patch_level $dovecot_minor_patch_level"
#echo "" #echo ""
#
#clean_up 0
# 'expire plugin'was rRemoved in version 2.3.14: This plugin is not needed. # 'expire plugin'was rRemoved in version 2.3.14: This plugin is not needed.
# Use mailbox { autoexpunge } Mailbox settings instead. # Use mailbox { autoexpunge } Mailbox settings instead.
@ -673,32 +717,72 @@ fi
## - Download Pigeonhole for Dovecot v2.2 ## - Download Pigeonhole for Dovecot v2.2
## - ## -
echononl "\tDownload dovecot-${dovecot_main_version}-pigeonhole-${_pigeonhole}.tar.gz.." if [[ ${dovecot_major_version} -eq 2 ]] && [[ ${dovecot_minor_version} -lt 4 ]] ; then
if [ ! -f "${_src_base_dir}/dovecot-${dovecot_main_version}-pigeonhole-${_pigeonhole}.tar.gz" ]; then
wget --no-check-certificate https://pigeonhole.dovecot.org/releases/${dovecot_main_version}/dovecot-${dovecot_main_version}-pigeonhole-${_pigeonhole}.tar.gz > /dev/null 2>&1 echononl "\tDownload dovecot-${dovecot_main_version}-pigeonhole-${_pigeonhole}.tar.gz.."
if [ "$?" = 0 ]; then if [ ! -f "${_src_base_dir}/dovecot-${dovecot_main_version}-pigeonhole-${_pigeonhole}.tar.gz" ]; then
echo -e "$rc_done" wget --no-check-certificate https://pigeonhole.dovecot.org/releases/${dovecot_main_version}/dovecot-${dovecot_main_version}-pigeonhole-${_pigeonhole}.tar.gz > /dev/null 2>&1
if [ "$?" = 0 ]; then
echo -e "$rc_done"
else
echo -e "$rc_failed"
error "Direct download of 'dovecot-${dovecot_main_version}-pigeonhole-${_pigeonhole}.tar.gz' failed
Download \033[1mdovecot-${dovecot_main_version}-pigeonhole-${_pigeonhole}.tar.gz\033[m manually
and proceed instllation."
echononl "\tProceed instllation [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/no]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Abbruch durch User"
fi
else else
echo -e "$rc_failed" echo -e "$rc_skipped"
error "Direct download of 'dovecot-${dovecot_main_version}-pigeonhole-${_pigeonhole}.tar.gz' failed
Download \033[1mdovecot-${dovecot_main_version}-pigeonhole-${_pigeonhole}.tar.gz\033[m manually
and proceed instllation."
echononl "\tProceed instllation [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/no]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Abbruch durch User"
fi fi
dovecot_pigeonhole_archiv="dovecot-${dovecot_main_version}-pigeonhole-${_pigeonhole}.tar.gz"
else else
echo -e "$rc_skipped"
echononl "\tDownload dovecot-pigeonhole-${_pigeonhole}.tar.gz.."
if [ ! -f "${_src_base_dir}/dovecot-pigeonhole-${_pigeonhole}.tar.gz" ]; then
wget --no-check-certificate https://pigeonhole.dovecot.org/releases/${dovecot_main_version}/dovecot-pigeonhole-${_pigeonhole}.tar.gz > /dev/null 2>&1
if [ "$?" = 0 ]; then
echo -e "$rc_done"
dovecot_pigeonhole_archiv="dovecot-pigeonhole-${_pigeonhole}.tar.gz"
else
echo -e "$rc_failed"
error "Direct download of 'Pigeonhole Sieve and ManageSieve' source archiv failed
Download Pigeonhole Sieve and ManageSieve manually and name it to
\033[1mdovecot-pigeonhole-${_pigeonhole}.tar.gz\033[m\n"
echononl "\tProceed instllation [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/no]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Abbruch durch User"
fi
else
echo -e "$rc_skipped"
fi
dovecot_pigeonhole_archiv="dovecot-pigeonhole-${_pigeonhole}.tar.gz"
fi fi
dovecot_pigeonhole_archiv_prefix="${dovecot_pigeonhole_archiv%.tar.gz}"
dovecot_pigeonhole_archiv_dir="${dovecot_pigeonhole_archiv%.tar.gz}"
if $_new ; then if $_new ; then
@ -864,6 +948,7 @@ config_params="
--prefix=/usr/local/dovecot-${_version} \ --prefix=/usr/local/dovecot-${_version} \
--with-${db_driver} \ --with-${db_driver} \
--with-gssapi=yes --with-gssapi=yes
--with-ldap=yes
--with-rundir=/run/dovecot" --with-rundir=/run/dovecot"
if $systemd_support ; then if $systemd_support ; then
config_params="$config_params \ config_params="$config_params \
@ -1018,20 +1103,20 @@ fi
cd ${_src_base_dir} cd ${_src_base_dir}
echo "" echo ""
echononl "\tExtracting dovecot-${dovecot_main_version}-pigeonhole-${_pigeonhole}.tar.gz.." echononl "\tExtracting dovecot-${dovecot_main_version}-pigeonhole-${_pigeonhole}.tar.gz.."
gunzip < dovecot-${dovecot_main_version}-pigeonhole-${_pigeonhole}.tar.gz | tar -xf - gunzip < ${_src_base_dir}/${dovecot_pigeonhole_archiv} | tar -C ${_src_base_dir} -xf -
if [ "$?" = 0 ]; then if [ "$?" = 0 ]; then
echo -e "$rc_done" echo -e "$rc_done"
else else
echo -e "$rc_failed" echo -e "$rc_failed"
fatal Extracting dovecot-${dovecot_main_version}-pigeonhole-${_pigeonhole}.tar.gz failed fatal Extracting ${dovecot_pigeonhole_archiv} failed
fi fi
cd dovecot-${dovecot_main_version}-pigeonhole-${_pigeonhole} cd ${dovecot_pigeonhole_archiv_dir}
echononl "\tConfigure Pigeonhole ManageSieve.." echononl "\tConfigure Pigeonhole ManageSieve.."
./configure \ ./configure \
--prefix=/usr/local/dovecot-${_version} \ --prefix=/usr/local/dovecot-${_version} \
--with-dovecot=/usr/local/dovecot-${_version}/lib/dovecot > ${_log_dir}/dovecot-${dovecot_main_version}-pigeonhole-${_pigeonhole}-configure.log 2<&1 --with-dovecot=/usr/local/dovecot-${_version}/lib/dovecot > ${_log_dir}/${dovecot_pigeonhole_archiv_prefix}-configure.log 2<&1
if [ "$?" = 0 ]; then if [ "$?" = 0 ]; then
echo -e "$rc_done" echo -e "$rc_done"
else else
@ -1040,7 +1125,7 @@ else
fi fi
echononl "\tCompile Pigeonhole ManageSieve.." echononl "\tCompile Pigeonhole ManageSieve.."
make > ${_log_dir}/dovecot-${dovecot_main_version}-pigeonhole-${_pigeonhole}-make.log 2<&1 make > ${_log_dir}/${dovecot_pigeonhole_archiv_prefix}-make.log 2<&1
if [ "$?" = 0 ]; then if [ "$?" = 0 ]; then
echo -e "$rc_done" echo -e "$rc_done"
else else
@ -1049,7 +1134,7 @@ else
fi fi
echononl "\tInstall Pigeonhole ManageSieve.." echononl "\tInstall Pigeonhole ManageSieve.."
make install > ${_log_dir}/dovecot-${dovecot_main_version}-pigeonhole-${_pigeonhole}-install.log 2<&1 make install > ${_log_dir}/${dovecot_pigeonhole_archiv_prefix}-install.log 2<&1
if [ "$?" = 0 ]; then if [ "$?" = 0 ]; then
echo -e "$rc_done" echo -e "$rc_done"
else else
@ -1058,6 +1143,7 @@ else
fi fi
## ----------------- ## -----------------
## --- Configure dovecot services ## --- Configure dovecot services
@ -1597,7 +1683,11 @@ if [[ $dovecot_major_version -ge 3 ]] \
if [[ ! -f "$dh_pem_file" ]] ; then if [[ ! -f "$dh_pem_file" ]] ; then
echononl "\tCreate SSL DH parameters '$dh_pem_file'.." echononl "\tCreate SSL DH parameters '$dh_pem_file'.."
echo -en "$rc_wait" echo -en "$rc_wait"
openssl dhparam -dsaparam -out "$dh_pem_file" 4096 > /dev/null 2>&1 if [[ "$os_dist" = "debian" ]] && [[ $os_version -gt 11 ]] ; then
openssl dhparam -out "$dh_pem_file" 4096 > /dev/null 2>&1
else
openssl dhparam -dsaparam -out "$dh_pem_file" 4096 > /dev/null 2>&1
fi
if [[ $? -eq 0 ]]; then if [[ $? -eq 0 ]]; then
echo -e "$rc_done" echo -e "$rc_done"
else else
@ -2164,7 +2254,12 @@ EOF
fatal "Creating file /etc/rsyslog.d/dovecot.conf failed" fatal "Creating file /etc/rsyslog.d/dovecot.conf failed"
fi fi
/etc/init.d/rsyslog restart > /dev/null 2>&1 echononl "\tRestart rsyslog Servive"
if $systemd_support ; then
systemctl restart rsyslog.service > /dev/null 2>&1
else
/etc/init.d/rsyslog restart > /dev/null 2>&1
fi
if [ "$?" = 0 ]; then if [ "$?" = 0 ]; then
echo -e "$rc_done" echo -e "$rc_done"
else else
@ -3610,8 +3705,8 @@ fi
## - quota_rule = *:storage=1g ## - quota_rule = *:storage=1g
## - quota_rule2 = trash:storage=+100m ## - quota_rule2 = trash:storage=+100m
## - ## -
## - quota_warning = storage=95%% quota-warning 95 %u ## - quota_warning = storage=80%% quota-warning 80 %u
## - quota_warning2 = storage=80%% quota-warning 80 %u ## - quota_warning2 = storage=95%% quota-warning 95 %u
## - } ## - }
## - ## -
## - service quota-warning { ## - service quota-warning {
@ -3636,8 +3731,8 @@ plugin {
quota_rule = *:storage=1G quota_rule = *:storage=1G
quota_rule2 = Trash:storage=+200M quota_rule2 = Trash:storage=+200M
quota_warning = storage=95%% quota-warning 95 %u quota_warning = storage=80%% quota-warning 80 %u
quota_warning2 = storage=80%% quota-warning 80 %u quota_warning2 = storage=95%% quota-warning 95 %u
} }
service quota-warning { service quota-warning {
@ -4393,6 +4488,16 @@ if [[ -x "/root/bin/monitoring/check_cert_for_dovecot.sh" ]] ; then
else else
echo -e "$rc_failed" echo -e "$rc_failed"
error "$(cat "$log_file")" error "$(cat "$log_file")"
echononl "\tcontinue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/no]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Abbruch durch User"
fi fi
else else
echo -e "$rc_skipped" echo -e "$rc_skipped"

285
update_postfix_dh_parameters.sh Executable file
View File

@ -0,0 +1,285 @@
#!/usr/bin/env bash
script_dir="$(dirname $(realpath $0))"
script_name="$(basename "$0")"
conf_dir=$(dirname $0)/conf
conf_file="${conf_dir}/install_postfix_base.conf"
_TLS_CERT_DIR=/etc/postfix/ssl
_TLS_CERT_FILE="${_TLS_CERT_DIR}/mailserver.crt"
_TLS_KEY_FILE="${_TLS_CERT_DIR}/mailserver.key"
_TLS_CA_FILE=/etc/ssl/certs/ca-certificates.crt
log_file=$(mktemp)
# -------------
# --- Some functions
# -------------
clean_up() {
# Perform program exit housekeeping
rm -f $log_file
exit $1
}
echononl(){
echo X\\c > /tmp/shprompt$$
if [ `wc -c /tmp/shprompt$$ | awk '{print $1}'` -eq 1 ]; then
echo -e -n "$*\\c" 1>&2
else
echo -e -n "$*" 1>&2
fi
rm /tmp/shprompt$$
}
fatal(){
echo ""
echo -e "fatal error: $*"
echo ""
echo -e "\t\033[31m\033[1mInstalllation will be interrupted\033[m\033[m"
echo ""
clean_up 1
}
error(){
echo ""
echo -e "\t[ \033[31m\033[1mFehler\033[m ]: $*"
echo ""
}
warn (){
echo ""
echo -e "\t[ \033[33m\033[1mWarning\033[m ]: $*"
echo ""
}
info (){
echo ""
echo -e "\t[ \033[32m\033[1mInfo\033[m ]: $*"
echo ""
}
echo_done() {
echo -e "\033[80G[ \033[32mdone\033[m ]"
}
echo_ok() {
echo -e "\033[80G[ \033[32mok\033[m ]"
}
echo_warning() {
echo -e "\033[80G[ \033[33m\033[1mwarn\033[m ]"
}
echo_failed(){
echo -e "\033[80G[ \033[1;31mfailed\033[m ]"
}
echo_skipped() {
echo -e "\033[80G[ \033[33m\033[1mskipped\033[m ]"
}
blank_line() {
if $terminal ; then
echo ""
fi
}
detect_os_1 () {
if $(which lsb_release > /dev/null 2>&1) ; then
os_dist="$(lsb_release -i | awk '{print tolower($3)}')"
os_version="$(lsb_release -r | awk '{print tolower($2)}')"
os_codename="$(lsb_release -c | awk '{print tolower($2)}')"
if [[ "$os_dist" = "debian" ]]; then
if $(echo "$os_version" | grep -q '\.') ; then
os_version=$(echo "$os_version" | cut --delimiter='.' -f1)
fi
fi
elif [[ -e "/etc/os-release" ]]; then
. /etc/os-release
os_dist=$ID
os_version=${VERSION_ID}
fi
# remove whitespace from os_dist and os_version
os_dist="${os_dist// /}"
os_version="${os_version// /}"
}
# -------------
# --- Some default settings
# -------------
DEFAULT_ADMIN_EMAIL="argus@oopen.de"
DEFAULT_RELAY_HOST="b.mx.oopen.de"
DEFAULT_SASL_AUTH=false
# - Is this a systemd system?
# -
if [[ "X`which systemd`" = "X" ]]; then
systemd_exists=false
else
systemd_exists=true
fi
echo ""
# - Read Configuration File if exists
# -
if [[ -f "$conf_file" ]]; then
source $conf_file
fi
# -------------
# --- Set default values for some non existent variables (i.e. no configuration file is present)
# -------------
[[ -z "$_ADMIN_EMAIL" ]] && _ADMIN_EMAIL="$DEFAULT_ADMIN_EMAIL"
[[ -z "$_SASL_AUTH" ]] && _SASL_AUTH="$DEFAULT_SASL_AUTH"
if [[ -z "$_HOSTNAME" ]] ; then
_HOSTNAME="$(hostname -f)"
_HOSTNAME_SHORT="$(hostname)"
[[ "$_HOSTNAME" = "$_HOSTNAME_SHORT" ]] && _HOSTNAME=""
fi
blank_line
echononl "Detect distribution/release of running OS.."
detect_os_1 > /dev/null 2>&1
if [[ $? -ne 0 ]]; then
echo_failed
else
echo_ok
fi
blank_line
blank_line
## - create directory for certificates and copy certificates
## - and coresponding keys to /etc/postfix/ssl/
## -
if [[ ! -d "/etc/postfix/ssl" ]] ; then
fatal "Certification directory \033[1m/etc/postfix/ssl\033[m not found!"
fi
## - generate DH parameters that the Postfix SMTP server should use
## - with EDH ciphers (length 512 and 1024
## -
echononl " Generate DH key length=512 \"/etc/postfix/ssl/dh_512.pem\""
if [[ ! -f /etc/postfix/ssl/dh_512.pem ]]; then
if [[ "$os_dist" = "debian" ]] && [[ $os_version -gt 11 ]] ; then
openssl dhparam -out /etc/postfix/ssl/dh_512.pem 512 > /dev/null 2>&1
else
openssl dhparam -dsaparam -out /etc/postfix/ssl/dh_512.pem 512 > /dev/null 2>&1
fi
if [[ $? -eq 0 ]] ; then
echo_ok
else
echo_failed
fi
else
if [[ "$os_dist" = "debian" ]] && [[ $os_version -gt 11 ]] ; then
if $(grep -q -E "X9.42" /etc/postfix/ssl/dh_512.pem 2> /dev/null); then
openssl dhparam -out /etc/postfix/ssl/dh_512.pem 512 > /dev/null 2>&1
if [[ $? -eq 0 ]] ; then
echo_ok
else
echo_failed
fi
else
echo_skipped
fi
else
echo_skipped
fi
fi
echononl " Generate DH key length=1024 \"/etc/postfix/ssl/dh_1024.pem\""
if [[ ! -f /etc/postfix/ssl/dh_1024.pem ]]; then
if [[ "$os_dist" = "debian" ]] && [[ $os_version -gt 11 ]] ; then
openssl dhparam -out /etc/postfix/ssl/dh_1024.pem 1024 > /dev/null 2>&1
else
openssl dhparam -dsaparam -out /etc/postfix/ssl/dh_1024.pem 1024 > /dev/null 2>&1
fi
if [[ $? -eq 0 ]] ; then
echo_ok
else
echo_failed
fi
else
if [[ "$os_dist" = "debian" ]] && [[ $os_version -gt 11 ]] ; then
if $(grep -q -E "X9.42" /etc/postfix/ssl/dh_1024.pem 2> /dev/null); then
openssl dhparam -out /etc/postfix/ssl/dh_1024.pem 1024 > /dev/null 2>&1
if [[ $? -eq 0 ]] ; then
echo_ok
else
echo_failed
fi
else
echo_skipped
fi
else
echo_skipped
fi
fi
echononl " Generate DH key length=2048 \"/etc/postfix/ssl/dh_2048.pem\""
if [[ ! -f /etc/postfix/ssl/dh_2048.pem ]]; then
if [[ "$os_dist" = "debian" ]] && [[ $os_version -gt 11 ]] ; then
openssl dhparam -out /etc/postfix/ssl/dh_2048.pem 2048 > /dev/null 2>&1
else
openssl dhparam -dsaparam -out /etc/postfix/ssl/dh_2048.pem 2048 > /dev/null 2>&1
fi
if [[ $? -eq 0 ]] ; then
echo_ok
else
echo_failed
fi
else
if [[ "$os_dist" = "debian" ]] && [[ $os_version -gt 11 ]] ; then
if $(grep -q -E "X9.42" /etc/postfix/ssl/dh_2048.pem 2> /dev/null); then
openssl dhparam -out /etc/postfix/ssl/dh_2048.pem 2048 > /dev/null 2>&1
if [[ $? -eq 0 ]] ; then
echo_ok
else
echo_failed
fi
else
echo_skipped
fi
else
echo_skipped
fi
fi
## - restart postfix
## -
echononl " Restart postfix"
if $systemd_exists ; then
systemctl restart postfix > /dev/null 2>&1
if [[ $? -eq 0 ]] ; then
echo_ok
else
echo_failed
fi
else
/etc/init.d/postfix restart > /dev/null 2>&1
if [[ $? -eq 0 ]] ; then
echo_ok
else
echo_failed
fi
fi
echo ""
clean_up 0

View File

@ -3,6 +3,8 @@
clear clear
echo -e "\n \033[32mStart script for upgrading Roundcube Webmailer..\033[m" echo -e "\n \033[32mStart script for upgrading Roundcube Webmailer..\033[m"
CUR_IFS="$IFS"
## ----------------------------------------------------------------- ## -----------------------------------------------------------------
## ---------------------------------------------------------------- ## ----------------------------------------------------------------
## --- ## ---
@ -18,7 +20,7 @@ echo -e "\n \033[32mStart script for upgrading Roundcube Webmailer..\033[m"
# - Settings # - Settings
# ------------- # -------------
#_src_base_dir="$(realpath $(dirname $0))" _src_base_dir="$(realpath $(dirname $0))"
#conf_file="${_src_base_dir}/conf/install_upgrade_roundcube.conf" #conf_file="${_src_base_dir}/conf/install_upgrade_roundcube.conf"
script_name="$(basename $(realpath $0))" script_name="$(basename $(realpath $0))"
@ -110,6 +112,62 @@ echo_not_yet_implemented(){
echo -e "\033[85G[ \033[30m\033[1mnot yet implemented\033[m ]" echo -e "\033[85G[ \033[30m\033[1mnot yet implemented\033[m ]"
} }
detect_mysql_version () {
_MYSQLD_VERSION="$(mysqld -V 2>/dev/null)"
if [[ -z "$_MYSQLD_VERSION" ]]; then
fatal "No installed MySQL server or distribution found!"
elif [[ -d "/usr/local/mysql" ]] && [[ "$(basename "$(realpath "/usr/local/mysql")")" =~ percona- ]]; then
MYSQL_CUR_DISTRIBUTION="Percona"
elif [[ "$_MYSQLD_VERSION" =~ MariaDB ]]; then
MYSQL_CUR_DISTRIBUTION="MariaDB"
elif [[ "$_MYSQLD_VERSION" =~ MySQL ]]; then
MYSQL_CUR_DISTRIBUTION="MySQL"
elif [[ -d "/usr/local/mysql" ]] && [[ "$(basename "$(realpath "/usr/local/mysql")")" =~ mysql- ]]; then
MYSQL_CUR_DISTRIBUTION="MySQL"
elif [[ -d "/usr/local/mysql" ]] && [[ "$(basename "$(realpath "/usr/local/mysql")")" =~ mariadb- ]]; then
MYSQL_CUR_DISTRIBUTION="MariaDB"
else
error "MySQL Instalation found, but cannot determin the distribution!"
MYSQL_CUR_DISTRIBUTION=
echo ""
echo " Select the installed MySQL distribution."
echo ""
echo " [1] MySQL (the original community edition)"
echo " [2] Percona Server for MySQL"
echo " [3] MariaDB"
echo ""
echononl " Eingabe [1/2/3]: "
while [ "$MYSQL_CUR_DISTRIBUTION" != "MySQL" -a "$MYSQL_CUR_DISTRIBUTION" != "MariaDB" -a "$MYSQL_CUR_DISTRIBUTION" != "Percona" ];do
read OPTION
case $OPTION in
1) MYSQL_CUR_DISTRIBUTION="MySQL"
;;
2) MYSQL_CUR_DISTRIBUTION="Percona"
;;
3) MYSQL_CUR_DISTRIBUTION="MariaDB"
;;
*) echo ""
echo -e "\tFalsche Eingabe ! [ 1 = MySQL ; 2 = Percona ; 3 = MariaDB ]"
echo ""
echononl " Eingabe:"
;;
esac
done
fi
MYSQL_VERSION="$(echo $_MYSQLD_VERSION | grep -o -E "[0-9]+\.[0-9]+\.[0-9]+(-[0-9]+)?" | head -n 1)"
MYSQL_MAJOR_VERSION="$(echo $MYSQL_VERSION | cut -d '.' -f1)"
MYSQL_MINOR_VERSION="$(echo $MYSQL_VERSION | cut -d '.' -f2)"
MYSQL_PATCH_LEVEL="$(echo $MYSQL_VERSION | cut -d '.' -f3)"
MYSQL_MAIN_VERSION="$(echo $MYSQL_VERSION | cut -d '.' -f1,2)"
}
trap clean_up SIGHUP SIGINT SIGTERM trap clean_up SIGHUP SIGINT SIGTERM
@ -154,8 +212,6 @@ fi
DEFAULT_DB_HOST="localhost" DEFAULT_DB_HOST="localhost"
DEFAULT_DB_NAME="roundcubemail" DEFAULT_DB_NAME="roundcubemail"
DEFAULT_DB_USER="roundcube" DEFAULT_DB_USER="roundcube"
DEFAULT_DEBIAN_MYSQL_CREDENTIALS="--defaults-file=/etc/mysql/debian.cnf"
DEFAULT_MYSQL_CREDENTIALS="--defaults-file=/usr/local/mysql/sys-maint.cnf"
while IFS='' read -r -d '' _conf_file ; do while IFS='' read -r -d '' _conf_file ; do
@ -179,6 +235,7 @@ while IFS='' read -r -d '' _conf_file ; do
fi fi
WEBSITE_NAME="" WEBSITE_NAME=""
done < <(find "${conf_dir}" -maxdepth 1 -type f -name "install_upgrade_roundcube*.conf" -print0) done < <(find "${conf_dir}" -maxdepth 1 -type f -name "install_upgrade_roundcube*.conf" -print0)
IFS="$CUR_IFS"
if [[ ${#unsorted_website_arr} -eq 0 ]]; then if [[ ${#unsorted_website_arr} -eq 0 ]]; then
fatal "No configuration files found in '${script_dir}/conf' or no website configured!" fatal "No configuration files found in '${script_dir}/conf' or no website configured!"
@ -187,7 +244,7 @@ fi
# - Sort array # - Sort array
# - # -
IFS=$'\n' website_arr=($(sort <<<"${unsorted_website_arr[*]}")) IFS=$'\n' website_arr=($(sort <<<"${unsorted_website_arr[*]}"))
IFS=' ' IFS="$CUR_IFS"
WEBSITE_NAME= WEBSITE_NAME=
@ -201,6 +258,8 @@ for _site in ${website_arr[@]} ; do
echo " [$i] ${_arr[0]}" echo " [$i] ${_arr[0]}"
((i++)) ((i++))
done done
IFS="$CUR_IFS"
echo echo
echononl " Eingabe: " echononl " Eingabe: "
while ! $_OK ; do while ! $_OK ; do
@ -216,6 +275,7 @@ read _IN
echononl " Eingabe: " echononl " Eingabe: "
fi fi
done done
IFS="$CUR_IFS"
echo "" echo ""
echononl " Include Configuration file.." echononl " Include Configuration file.."
@ -227,6 +287,7 @@ else
echo_ok echo_ok
fi fi
[[ -n "$WEBSITE_NAME" ]] || fatal "Website's name (WEBSITE_NAME) not present!" [[ -n "$WEBSITE_NAME" ]] || fatal "Website's name (WEBSITE_NAME) not present!"
DEFAULT_WEBSITE_BASEDIR="/var/www/${WEBSITE_NAME}" DEFAULT_WEBSITE_BASEDIR="/var/www/${WEBSITE_NAME}"
@ -262,17 +323,98 @@ if [ "$DB_TYPE" = "postgres" -o "$DB_TYPE" = "postgresql" -o "$DB_TYPE" = "pgsq
fi fi
if [[ "$DB_TYPE" = "mysql" ]]; then if [[ "$DB_TYPE" = "mysql" ]] ; then
if $MYSQL_DEBIAN_INSTALLATION ; then
[[ -n "$MYSQL_CREDENTIALS" ]] || MYSQL_CREDENTIALS="$DEFAULT_DEBIAN_MYSQL_CREDENTIALS" if [[ -z ${MYSQL_CREDENTIALS} ]] ; then
else
[[ -n "$MYSQL_CREDENTIALS" ]] || MYSQL_CREDENTIALS="$DEFAULT_MYSQL_CREDENTIALS" detect_mysql_version
if [[ "$MYSQL_CUR_DISTRIBUTION" = "MariaDB" ]] && ([[ $MYSQL_MAJOR_VERSION -gt 10 ]] \
|| ( [[ $MYSQL_MAJOR_VERSION -eq 10 ]] && [[ $MYSQL_MINOR_VERSION -gt 3 ]] )) ; then
if [[ -S "/tmp/mysql.sock" ]]; then
MYSQL_CREDENTIALS="-u root -S /tmp/mysql.sock"
elif [[ -S "/run/mysqld/mysqld.sock" ]]; then
MYSQL_CREDENTIALS="-u root -S /run/mysqld/mysqld.sock"
elif [[ -S "/var/run/mysqld/mysqld.sock" ]]; then
MYSQL_CREDENTIALS="-u root -S /var/run/mysqld/mysqld.sock"
else
fatal "Parameter 'MYSQL_CREDENTIALS' cannot be determined automated.
Use configuration file "$conf_file" to set
parameter manually."
fi
else
echononl "\tGet MySQL command.."
mysql_command="$(which mysql)"
if [[ $? -eq 0 ]]; then
echo_ok
else
if [[ -x "/usr/local/mysql/bin/mysql" ]]; then
mysql_command="/usr/local/mysql/bin/mysql"
echo_ok
else
echo_failed
fatal "$(cat $tmp_log_file)"
fi
fi
if $(${mysql_command} --login-path=local -e ";" > /dev/null 2>&1) ; then
MYSQL_CREDENTIALS="--login-path=local"
elif [[ -f "/usr/local/mysql/sys-maint.cnf" ]] ; then
MYSQL_CREDENTIALS="--defaults-file=/usr/local/mysql/sys-maint.cnf"
elif [[ -f "/etc/mysql/debian.cnf" ]] ; then
MYSQL_CREDENTIALS="--defaults-file=/etc/mysql/debian.cnf"
else
fatal "Parameter 'MYSQL_CREDENTIALS' cannot be determined automated.
Use configuration file "$conf_file" to set
parameter manually."
fi
fi
#if $MYSQL_DEBIAN_INSTALLATION ; then
# [[ -n "$MYSQL_CREDENTIALS" ]] || MYSQL_CREDENTIALS="$DEFAULT_DEBIAN_MYSQL_CREDENTIALS"
#else
# [[ -n "$MYSQL_CREDENTIALS" ]] || MYSQL_CREDENTIALS="$DEFAULT_MYSQL_CREDENTIALS"
#fi
fi fi
else else
#[[ "$POSTFIX_DB_TYPE" = "pgsql" ]] || fatal "Unknown Database Type '$POSTFIX_DB_TYPE' (POSTFIX_DB_TYPE)"
[[ "$DB_TYPE" = "pgsql" ]] || fatal "Unknown Database Type '$DB_TYPE' (DB_TYPE)" [[ "$DB_TYPE" = "pgsql" ]] || fatal "Unknown Database Type '$DB_TYPE' (DB_TYPE)"
fi fi
if [[ "$DB_TYPE" = "mysql" ]]; then
echononl " Get MySQL command.."
mysql_command="$(which mysql)"
if [[ $? -eq 0 ]]; then
echo_ok
else
if [[ -x "/usr/local/mysql/bin/mysql" ]]; then
mysql_command="/usr/local/mysql/bin/mysql"
echo_ok
else
echo_failed
fatal "$(cat $tmp_log_file)"
fi
fi
elif [[ "$DB_TYPE" = "pgsql" ]] ; then
echononl " Get PostgreSQL command.."
psql_command="$(which psql)"
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
fi
fi
echo -e "\033[32m--\033[m" echo -e "\033[32m--\033[m"
echo "" echo ""
echo "Version of the Roundcube Webmailer to install" echo "Version of the Roundcube Webmailer to install"
@ -323,8 +465,56 @@ else
else else
echo_ok echo_ok
fi fi
IFS="$CUR_IFS"
fi fi
# - Get the latest PHP version
# -
echononl "\tGet major version of latest installed PHP version"
php_latest_ver=""
if $PHP_DEBIAN_INSTALLATION ; then
echo_skipped
else
if [[ -n "$php_major_versions" ]]; then
for _ver in $php_major_versions ; do
if [[ -z "$php_latest_ver" ]] ; then
php_latest_ver=$_ver
elif [[ "${_ver%.*}" -gt "${php_latest_ver%.*}" ]] ; then
php_latest_ver=$_ver
elif [[ "${_ver%.*}" -eq "${php_latest_ver%.*}" ]] ; then
[[ "${_ver#*.}" -gt "${php_latest_ver#*.}" ]] && php_latest_ver=$_ver
fi
done
echo_ok
else
echo_skipped
warn "Getting major version of latest installed PHP version failed! - No installed PHP versiond found!"
fi
fi
# - Get activ PHP version, means that on which is part of $PATH environment
# -
echononl "\tGet PHP version in PATH environment.."
if $(which php > /dev/null 2>&1) ; then
php_version_in_path="$(php --version 2> /dev/null | head -1 | cut -d' ' -f2 | cut -d '-' -f1 2> /dev/null)"
if [[ $? -eq 0 ]] && [[ -n "${php_version_in_path}" ]]; then
echo_ok
else
echo_failed
fatal "Failed getting PHP Version.."
fi
else
echo_skipped
fatal "No PHP binary found in PATH environment.."
fi
# - Log directory containing upgrade log files
# -
_log_dir=${script_dir}/log-upgrade-roundcube-${ROUNDCUBE_VERSION}
echo "" echo ""
echo "" echo ""
@ -376,6 +566,7 @@ else
done done
echo "" echo ""
echo -e "\tNewest PHP Version...................: $php_latest_ver" echo -e "\tNewest PHP Version...................: $php_latest_ver"
echo -e "\tPHP Version of php binary in PATH....: $php_version_in_path"
fi fi
echo "" echo ""
echo -e "\tCrontab backup file..................: $crontab_backup_file" echo -e "\tCrontab backup file..................: $crontab_backup_file"
@ -392,24 +583,86 @@ else
fatal "Abort by user request - Answer as not 'YES'" fatal "Abort by user request - Answer as not 'YES'"
fi fi
echononl "\tCheck Database connection .."
if [[ "$DB_TYPE" = "mysql" ]]; then if [[ "$DB_TYPE" = "mysql" ]]; then
if ! mysql $MYSQL_CREDENTIALS -N -s -e \ ${mysql_command} $MYSQL_CREDENTIALS -N -s -e \
"SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = '$DB_NAME'" 2>> $log_file \ "SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = '$DB_NAME'" 2>> $log_file \
| grep $DB_NAME >> $log_file 2>&1 ; then | grep $DB_NAME >> $log_file 2>&1
fatal "MySQL Database '$DB_NAME' does not exit. (See Parameter 'DB_NAME')"
if [[ "$?" = "0" ]]; then
echo_ok
else
echo_failed
error "$(cat $log_file)"
echononl "continue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/no]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Abbruch durch User"
fi fi
elif [[ "$DB_TYPE" = "pgsql" ]]; then elif [[ "$DB_TYPE" = "pgsql" ]]; then
count=$(su - postgres -c "psql -q -A -t -l" | grep -c -e "^$DB_NAME") count=$(su - postgres -c "${psql_command} -q -A -t -l" | grep -c -e "^$DB_NAME")
if [[ $count -eq 0 ]];then if [[ $count -eq 0 ]];then
fatal "PostgreSQL Database '$DB_NAME' does not exit. (See Parameter 'DB_NAME')" echo_failed
error "$(cat $log_file)"
echononl "continue anyway [yes/no]: "
read OK
OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')"
while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do
echononl "Wrong entry! - repeat [yes/no]: "
read OK
done
[[ $OK = "yes" ]] || fatal "Abbruch durch User"
else
echo_ok
fi fi
else else
fatal "Cannot detect database type (value of DB_TYPE is neither 'mysql' nor 'pgsql')" fatal "Cannot detect database type (value of DB_TYPE is neither 'mysql' nor 'pgsql')"
fi fi
echononl "\tInstall/Update composer to /usr/local/bin"
echononl "\tDownload composer from 'getcomposer.org'.."
php -r "copy('https://getcomposer.org/installer', '${script_dir}/composer-setup.php');" > $log_file 2>&1
if [[ "$?" = "0" ]]; then
echo_ok
else
echo_failed
error "$(cat $log_file)"
fi
echononl "\tInstall composer to /usr/local/bin"
php ${script_dir}/composer-setup.php --install-dir=/usr/local/bin --filename=composer > $log_file 2>&1
if [[ "$?" = "0" ]]; then
echo_ok
else
echo_failed
error "$(cat $log_file)"
fi
echo -e "\n\n \033[37m\033[1mCreate some Backups..\033[m\n" echo -e "\n\n \033[37m\033[1mCreate some Backups..\033[m\n"
echononl " Backup existing upgrade log directory \033[37m\033[1m$(basename "${_log_dir}")\033[m"
if [[ -d "${_log_dir}" ]] ; then
mv "${_log_dir}" "${_log_dir}.${backup_date}" > $log_file 2>&1
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
error "$(cat $log_file)"
fi
else
echo_skipped
fi
echononl " Backup existing Database '$DB_NAME'" echononl " Backup existing Database '$DB_NAME'"
if [[ "$DB_TYPE" = "mysql" ]]; then if [[ "$DB_TYPE" = "mysql" ]]; then
echo -n " (MySQL).." echo -n " (MySQL).."
@ -624,8 +877,8 @@ else
fi fi
echononl " Create log-directory for update log file" echononl " Create log-directory for update log file"
if [[ ! -d "${script_dir}/log" ]]; then if [[ ! -d "${_log_dir}" ]]; then
mkdir "${script_dir}/log" > $log_file 2>&1 mkdir "${_log_dir}" > $log_file 2>&1
if [[ $? -eq 0 ]]; then if [[ $? -eq 0 ]]; then
echo_ok echo_ok
else else
@ -636,10 +889,40 @@ else
echo_skipped echo_skipped
fi fi
echononl "\tRename the composer.json-dist file into composer.json"
cp -a "composer.json-dist" "composer.json" > $log_file 2>&1
if [[ $? -eq 0 ]]; then
echo_ok
else
echo_failed
error "$(cat $log_file)"
fi
echononl "\tInstall composer to ${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}"
php ${script_dir}/composer-setup.php --install-dir=${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION} > $log_file 2>&1
if [[ "$?" = "0" ]]; then
echo_ok
else
echo_failed
error "$(cat $log_file)"
fi
echononl "\tRemove the installer"
php -r "unlink('${script_dir}/composer-setup.php');" > $log_file 2>&1
if [[ "$?" = "0" ]]; then
echo_ok
else
echo_failed
error "$(cat $log_file)"
fi
echo "" echo ""
echo " Update the the roundcube web-directory to version '${ROUNDCUBE_VERSION}'" echo " Update the the roundcube web-directory to version '${ROUNDCUBE_VERSION}'"
echononl " See: ${script_dir}/log/update_roundcube-${ROUNDCUBE_VERSION}.${backup_date}.log" echononl " See: ${_log_dir}/update_roundcube-${ROUNDCUBE_VERSION}.${backup_date}.log"
echo "y" | ${script_dir}/roundcubemail-${ROUNDCUBE_VERSION}/bin/installto.sh "${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}" > ${script_dir}/log/update_roundcube-${ROUNDCUBE_VERSION}.${backup_date}.log 2>&1 echo "y" | ${script_dir}/roundcubemail-${ROUNDCUBE_VERSION}/bin/installto.sh "${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}" > ${_log_dir}/update_roundcube-${ROUNDCUBE_VERSION}.${backup_date}.log 2>&1
if [[ $? -eq 0 ]]; then if [[ $? -eq 0 ]]; then
echo_ok echo_ok
else else
@ -674,12 +957,12 @@ done
echononl " Update dependencies by running 'php composer.phar update --no-dev'" echononl " Update dependencies by running 'php composer.phar update --no-dev'"
php composer.phar --no-interaction update --no-dev > ${script_dir}/log/update_roundcube-${ROUNDCUBE_VERSION}-dependencies.${backup_date}.log 2>&1 php composer.phar --no-interaction update --no-dev > ${_log_dir}/update_roundcube-${ROUNDCUBE_VERSION}-dependencies.${backup_date}.log 2>&1
if [[ $? -eq 0 ]]; then if [[ $? -eq 0 ]]; then
echo_ok echo_ok
else else
echo_failed echo_failed
error "command was:\n\t # cd "${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}"\n\t #php composer.phar --no-interaction update --no-dev\n\n$(cat ${script_dir}/log/update_roundcube-${ROUNDCUBE_VERSION}-dependencies.${backup_date}.log)" error "command was:\n\t # cd "${WEBSITE_BASEDIR}/roundcubemail-${ROUNDCUBE_VERSION}"\n\t #php composer.phar --no-interaction update --no-dev\n\n$(cat ${_log_dir}/update_roundcube-${ROUNDCUBE_VERSION}-dependencies.${backup_date}.log)"
echononl "continue anyway [yes/no]: " echononl "continue anyway [yes/no]: "
read OK read OK