diff --git a/config/dovecot/etc/dovecot/conf.d/10-auth.conf b/config/dovecot/etc/dovecot/conf.d/10-auth.conf new file mode 100644 index 0000000000000000000000000000000000000000..29f5cd6d0f33c8a95c7f8adad48c5286d091a09d --- /dev/null +++ b/config/dovecot/etc/dovecot/conf.d/10-auth.conf @@ -0,0 +1,3 @@ +disable_plaintext_auth = no +auth_mechanisms = plain login +!include auth-static.conf.ext diff --git a/config/dovecot/etc/dovecot/conf.d/10-logging.conf b/config/dovecot/etc/dovecot/conf.d/10-logging.conf new file mode 100644 index 0000000000000000000000000000000000000000..f3f3d0b1d9f24eb43ede08f172d845b7e90086b1 --- /dev/null +++ b/config/dovecot/etc/dovecot/conf.d/10-logging.conf @@ -0,0 +1,114 @@ + +## +## Log destination. +## + +# Log file to use for error messages. "syslog" logs to syslog, +# /dev/stderr logs to stderr. +log_path = /var/log/dovecot/error.log + +# Log file to use for informational messages. Defaults to log_path. +info_log_path = /var/log/dovecot/info.log +# Log file to use for debug messages. Defaults to info_log_path. +# debug_log_path = /var/log/dovecot/debug.log + +# Syslog facility to use if you're logging to syslog. Usually if you don't +# want to use "mail", you'll use local0..local7. Also other standard +# facilities are supported. +#syslog_facility = mail + +## +## Logging verbosity and debugging. +## + +# Log filter is a space-separated list conditions. If any of the conditions +# match, the log filter matches (i.e. they're ORed together). Parenthesis +# are supported if multiple conditions need to be matched together. +# Supported conditions are: +# event:<name wildcard> - Match event name. '*' and '?' wildcards supported. +# source:<filename>[:<line number>] - Match source code filename [and line] +# field:<key>=<value wildcard> - Match field key to a value. Can be specified +# multiple times to match multiple keys. +# cat[egory]:<value> - Match a category. Can be specified multiple times to +# match multiple categories. +# For example: event:http_request_* (cat:error cat:storage) + +# Filter to specify what debug logging to enable. This will eventually replace +# mail_debug and auth_debug settings. +#log_debug = + +# Crash after logging a matching event. For example category:error will crash +# any time an error is logged, which can be useful for debugging. +#log_core_filter = + +# Log unsuccessful authentication attempts and the reasons why they failed. +# auth_verbose = yes + +# In case of password mismatches, log the attempted password. Valid values are +# no, plain and sha1. sha1 can be useful for detecting brute force password +# attempts vs. user simply trying the same password over and over again. +# You can also truncate the value to n chars by appending ":n" (e.g. sha1:6). +#auth_verbose_passwords = no + +# Even more verbose logging for debugging purposes. Shows for example SQL +# queries. +#auth_debug = yes + +# In case of password mismatches, log the passwords and used scheme so the +# problem can be debugged. Enabling this also enables auth_debug. +#auth_debug_passwords = no + +# Enable mail process debugging. This can help you figure out why Dovecot +# isn't finding your mails. +# mail_debug = yes + +# Show protocol level SSL errors. +#verbose_ssl = no + +# mail_log plugin provides more event logging for mail processes. +#plugin { + # Events to log. Also available: flag_change append + #mail_log_events = delete undelete expunge copy mailbox_delete mailbox_rename + # Available fields: uid, box, msgid, from, subject, size, vsize, flags + # size and vsize are available only for expunge and copy events. + #mail_log_fields = uid box msgid size +#} +plugin { + mail_log_events = delete undelete expunge copy flag_change append mailbox_delete mailbox_rename + mail_log_fields = uid box msgid size +} + +## +## Log formatting. +## + +# Prefix for each line written to log file. % codes are in strftime(3) +# format. +#log_timestamp = "%b %d %H:%M:%S " + +# Space-separated list of elements we want to log. The elements which have +# a non-empty variable value are joined together to form a comma-separated +# string. +#login_log_format_elements = user=<%u> method=%m rip=%r lip=%l mpid=%e %c + +# Login log format. %s contains login_log_format_elements string, %$ contains +# the data we want to log. +#login_log_format = %$: %s + +# Log prefix for mail processes. See doc/wiki/Variables.txt for list of +# possible variables you can use. +#mail_log_prefix = "%s(%u)<%{pid}><%{session}>: " + +# Format to use for logging mail deliveries: +# %$ - Delivery status message (e.g. "saved to INBOX") +# %m / %{msgid} - Message-ID +# %s / %{subject} - Subject +# %f / %{from} - From address +# %p / %{size} - Physical size +# %w / %{vsize} - Virtual size +# %e / %{from_envelope} - MAIL FROM envelope +# %{to_envelope} - RCPT TO envelope +# %{delivery_time} - How many milliseconds it took to deliver the mail +# %{session_time} - How long LMTP session took, not including delivery_time +# %{storage_id} - Backend-specific ID for mail, e.g. Maildir filename +#deliver_log_format = msgid=%m: %$ diff --git a/config/dovecot/etc/dovecot/conf.d/10-mail.conf b/config/dovecot/etc/dovecot/conf.d/10-mail.conf new file mode 100644 index 0000000000000000000000000000000000000000..41de850752d963aa17e96efa70a60be58ef4e4bd --- /dev/null +++ b/config/dovecot/etc/dovecot/conf.d/10-mail.conf @@ -0,0 +1,33 @@ +mail_vsize_bg_after_count = 100 +mailbox_list_index = yes +mail_always_cache_fields = body.snippet +mail_location = maildir:~/Maildir +mail_uid = vmail +mail_gid = vmail +mail_plugins = $mail_plugins acl mail_log notify quota old_stats virtual zlib + +namespace inbox { + inbox = yes + prefix = INBOX/ + separator = / +} + +namespace { + type = shared + separator = / + prefix = shared/%%u/ + location = maildir:%%h/Maildir:INDEX=%h/shared/%%u:CONTROL=%h/shared/%%u + subscriptions = yes + list = children +} +namespace virtual { + prefix = virtual/ + separator = / + hidden = yes + list = no + subscriptions = no + location = virtual:/var/lib/dovecot/virtual:INDEX=~/Maildir/virtual + mailbox all { + special_use = \All + } +} diff --git a/config/dovecot/etc/dovecot/conf.d/10-master.conf b/config/dovecot/etc/dovecot/conf.d/10-master.conf new file mode 100644 index 0000000000000000000000000000000000000000..96384a422cef4e3140163e17adbc0e3a3583c245 --- /dev/null +++ b/config/dovecot/etc/dovecot/conf.d/10-master.conf @@ -0,0 +1,7 @@ +#service auth { +# unix_listener auth-userdb { +# mode = 0666 +# user = vmail +# group = vmail +# } +#} diff --git a/config/dovecot/etc/dovecot/conf.d/10-ssl.conf b/config/dovecot/etc/dovecot/conf.d/10-ssl.conf new file mode 100644 index 0000000000000000000000000000000000000000..f3da6d5aad34767311144fdfa6e95aa394c9969c --- /dev/null +++ b/config/dovecot/etc/dovecot/conf.d/10-ssl.conf @@ -0,0 +1,4 @@ +ssl = no +#ssl_cert = </etc/dovecot/private/dovecot.pem +#ssl_key = </etc/dovecot/private/dovecot.key +#ssl_dh = </usr/share/dovecot/dh.pem \ No newline at end of file diff --git a/config/dovecot/etc/dovecot/conf.d/15-lda.conf b/config/dovecot/etc/dovecot/conf.d/15-lda.conf new file mode 100644 index 0000000000000000000000000000000000000000..9a728c6542f3774891906e77d5cc3f5e2bb4858b --- /dev/null +++ b/config/dovecot/etc/dovecot/conf.d/15-lda.conf @@ -0,0 +1,4 @@ +protocol lda { + mail_plugins = $mail_plugins sieve +} +postmaster_address = invalid@invalid.invalid diff --git a/config/dovecot/etc/dovecot/conf.d/20-imap.conf b/config/dovecot/etc/dovecot/conf.d/20-imap.conf new file mode 100644 index 0000000000000000000000000000000000000000..9097fc4b26db1cc07612b9df9c39cce359ee4fdb --- /dev/null +++ b/config/dovecot/etc/dovecot/conf.d/20-imap.conf @@ -0,0 +1,4 @@ +imap_capability = +SEARCH=X-MIMEPART XDOVECOT +protocol imap { + mail_plugins = $mail_plugins imap_acl imap_quota imap_old_stats imap_filter_sieve +} diff --git a/config/dovecot/etc/dovecot/conf.d/20-lmtp.conf b/config/dovecot/etc/dovecot/conf.d/20-lmtp.conf new file mode 100644 index 0000000000000000000000000000000000000000..6a691ec6193b073cf8f03c146fba703fd7258279 --- /dev/null +++ b/config/dovecot/etc/dovecot/conf.d/20-lmtp.conf @@ -0,0 +1,26 @@ +## +## LMTP specific settings +## + +# Support proxying to other LMTP/SMTP servers by performing passdb lookups. +#lmtp_proxy = no + +# When recipient address includes the detail (e.g. user+detail), try to save +# the mail to the detail mailbox. See also recipient_delimiter and +# lda_mailbox_autocreate settings. +#lmtp_save_to_detail_mailbox = no + +# Verify quota before replying to RCPT TO. This adds a small overhead. +#lmtp_rcpt_check_quota = no + +# Which recipient address to use for Delivered-To: header and Received: +# header. The default is "final", which is the same as the one given to +# RCPT TO command. "original" uses the address given in RCPT TO's ORCPT +# parameter, "none" uses nothing. Note that "none" is currently always used +# when a mail has multiple recipients. +#lmtp_hdr_delivery_address = final + +protocol lmtp { + # Space separated list of plugins to load (default is global mail_plugins). + mail_plugins = $mail_plugins sieve +} diff --git a/config/dovecot/etc/dovecot/conf.d/20-managesieve.conf b/config/dovecot/etc/dovecot/conf.d/20-managesieve.conf new file mode 100644 index 0000000000000000000000000000000000000000..9824248f81cc45dbfbd9ed0085fdac98eda990a2 --- /dev/null +++ b/config/dovecot/etc/dovecot/conf.d/20-managesieve.conf @@ -0,0 +1,6 @@ +protocols = $protocols sieve +service managesieve-login { + inet_listener sieve { + port = 4190 + } +} \ No newline at end of file diff --git a/config/dovecot/etc/dovecot/conf.d/90-acl.conf b/config/dovecot/etc/dovecot/conf.d/90-acl.conf new file mode 100644 index 0000000000000000000000000000000000000000..bbb26ae4f527905b10cb33fceb49f8ebfc8f514a --- /dev/null +++ b/config/dovecot/etc/dovecot/conf.d/90-acl.conf @@ -0,0 +1,4 @@ +plugin { + acl = vfile + acl_shared_dict = file:/var/lib/dovecot/db/shared-mailboxes.db +} diff --git a/config/dovecot/etc/dovecot/conf.d/auth-static.conf.ext b/config/dovecot/etc/dovecot/conf.d/auth-static.conf.ext new file mode 100644 index 0000000000000000000000000000000000000000..88124b6b9430aabf0caa2ef500004fe1514b2862 --- /dev/null +++ b/config/dovecot/etc/dovecot/conf.d/auth-static.conf.ext @@ -0,0 +1,9 @@ +passdb { + driver = static + args = password=secret +} + +userdb { + driver = static + args = uid=vmail gid=vmail home=/home/vmail/%u +} diff --git a/config/dovecot/etc/dovecot/dovecot.conf b/config/dovecot/etc/dovecot/dovecot.conf new file mode 100644 index 0000000000000000000000000000000000000000..31cf415906086ec639ebb0a6f18e25c0d1d49e3e --- /dev/null +++ b/config/dovecot/etc/dovecot/dovecot.conf @@ -0,0 +1,103 @@ +## Dovecot configuration file + +# If you're in a hurry, see http://wiki2.dovecot.org/QuickConfiguration + +# "doveconf -n" command gives a clean output of the changed settings. Use it +# instead of copy&pasting files when posting to the Dovecot mailing list. + +# '#' character and everything after it is treated as comments. Extra spaces +# and tabs are ignored. If you want to use either of these explicitly, put the +# value inside quotes, eg.: key = "# char and trailing whitespace " + +# Most (but not all) settings can be overridden by different protocols and/or +# source/destination IPs by placing the settings inside sections, for example: +# protocol imap { }, local 127.0.0.1 { }, remote 10.0.0.0/8 { } + +# Default values are shown for each setting, it's not required to uncomment +# those. These are exceptions to this though: No sections (e.g. namespace {}) +# or plugin settings are added by default, they're listed only as examples. +# Paths are also just examples with the real defaults being based on configure +# options. The paths listed here are for configure --prefix=/usr +# --sysconfdir=/etc --localstatedir=/var + +# Enable installed protocols +!include_try /usr/share/dovecot/protocols.d/*.protocol +protocols = imap lmtp sieve + +# A comma separated list of IPs or hosts where to listen in for connections. +# "*" listens in all IPv4 interfaces, "::" listens in all IPv6 interfaces. +# If you want to specify non-default ports or anything more complex, +# edit conf.d/master.conf. +#listen = *, :: + +# Base directory where to store runtime data. +#base_dir = /var/run/dovecot/ + +# Name of this instance. In multi-instance setup doveadm and other commands +# can use -i <instance_name> to select which instance is used (an alternative +# to -c <config_path>). The instance name is also added to Dovecot processes +# in ps output. +#instance_name = dovecot + +# Greeting message for clients. +#login_greeting = Dovecot ready. + +# Space separated list of trusted network ranges. Connections from these +# IPs are allowed to override their IP addresses and ports (for logging and +# for authentication checks). disable_plaintext_auth is also ignored for +# these networks. Typically you'd specify your IMAP proxy servers here. +#login_trusted_networks = + +# Space separated list of login access check sockets (e.g. tcpwrap) +#login_access_sockets = + +# With proxy_maybe=yes if proxy destination matches any of these IPs, don't do +# proxying. This isn't necessary normally, but may be useful if the destination +# IP is e.g. a load balancer's IP. +#auth_proxy_self = + +# Show more verbose process titles (in ps). Currently shows user name and +# IP address. Useful for seeing who are actually using the IMAP processes +# (eg. shared mailboxes or if same uid is used for multiple accounts). +#verbose_proctitle = no + +# Should all processes be killed when Dovecot master process shuts down. +# Setting this to "no" means that Dovecot can be upgraded without +# forcing existing client connections to close (although that could also be +# a problem if the upgrade is e.g. because of a security fix). +#shutdown_clients = yes + +# If non-zero, run mail commands via this many connections to doveadm server, +# instead of running them directly in the same process. +#doveadm_worker_count = 0 +# UNIX socket or host:port used for connecting to doveadm server +#doveadm_socket_path = doveadm-server + +# Space separated list of environment variables that are preserved on Dovecot +# startup and passed down to all of its child processes. You can also give +# key=value pairs to always set specific settings. +#import_environment = TZ + +## +## Dictionary server settings +## + +# Dictionary can be used to store key=value lists. This is used by several +# plugins. The dictionary can be accessed either directly or though a +# dictionary server. The following dict block maps dictionary names to URIs +# when the server is used. These can then be referenced using URIs in format +# "proxy::<name>". + +dict { + #quota = mysql:/etc/dovecot/dovecot-dict-sql.conf.ext + #expire = sqlite:/etc/dovecot/dovecot-dict-sql.conf.ext +} + +# Most of the actual configuration gets included below. The filenames are +# first sorted by their ASCII value and parsed in that order. The 00-prefixes +# in filenames are intended to make it easier to understand the ordering. +!include conf.d/*.conf + +# A config file can also tried to be included without giving an error if +# it's not found: +!include_try local.conf diff --git a/config/dovecot/etc/entrypoint.sh b/config/dovecot/etc/entrypoint.sh new file mode 100644 index 0000000000000000000000000000000000000000..32d87a848aee3542dcc0f20febc3b44acdf83f57 --- /dev/null +++ b/config/dovecot/etc/entrypoint.sh @@ -0,0 +1,25 @@ +#!/bin/bash -e +echo "all arguments: "$@ +echo "0: "$0 +echo "1: "$1 + +if [[ -z "${MAIL_DOMAIN}" ]]; then + echo "ERROR: MAIL_DOMAIN parameter not set ... exit ..." + exit 1 +fi + +# $1 as hostname for this dovecot instance +/etc/initial-config.sh "${MAIL_DOMAIN}" + +if [[ "$1" == "bash" ]]; then + echo "Starting interactive shell ..." + bash + echo "Interactive shell stopped." + exit 0; +fi + + +/usr/bin/supervisord -c /etc/supervisor/supervisord.conf + +# Tailing dovecot Logs as container output (auth) +tail -F /var/log/dovecot/*.log diff --git a/config/dovecot/etc/initial-config.sh b/config/dovecot/etc/initial-config.sh new file mode 100644 index 0000000000000000000000000000000000000000..6937c43f28d421deb2ca35206f61940408bcd195 --- /dev/null +++ b/config/dovecot/etc/initial-config.sh @@ -0,0 +1,90 @@ +#!/bin/bash +set -e + +# TODO: .... everything ... + +# todo check for $1 and to overwrite the config ... +if [[ -z "${MAIL_DOMAIN}" ]]; then + echo "ERROR: MAIL_DOMAIN parameter not set ... exit ..." + exit 1 +fi + +if [ ! -f "/etc/dovecot/dovecot.conf" ]; then + # Copy default config + echo "Copying default config from /etc/dovecot.dist" + cp -R /etc/dovecot.dist/* /etc/dovecot/ +fi + +INIT_STATE_FILE="/etc/dovecot/dovecot-init-done" + +if [ ! -f ${INIT_STATE_FILE} ]; then + + echo "Executing init-config script (dovecot-backend) " + echo "$0 $@" + + echo "Creating user and group: vmail" + groupadd -g 5000 vmail + useradd -u 5000 -g 5000 -m -d /home/vmail -s /bin/false vmail + adduser dovecot vmail + + # Create log dir and adjust permissions + mkdir -p /var/log/dovecot + touch /var/log/dovecot/debug.log + touch /var/log/dovecot/info.log + touch /var/log/dovecot/error.log + + chown -R vmail:dovecot /var/log/dovecot* + + echo "Creating directory for dovecot acl informations" + mkdir -p /var/lib/dovecot/db + chmod 0770 /var/lib/dovecot + + echo "Creating dictionary for shared namespace" + touch /var/lib/dovecot/db/shared-mailboxes.db + + echo "Creating virtual directories" + mkdir -p /var/lib/dovecot/virtual/all + chmod -R 700 /var/lib/dovecot/virtual + + echo "* + -INBOX/Trash + -INBOX/Trash/* + -INBOX/Spam + -INBOX/Spam/* + all" > /var/lib/dovecot/virtual/all/dovecot-virtual + + chown -R vmail:vmail /var/lib/dovecot + + LDA_PATH="/usr/lib/dovecot/dovecot-lda" + echo "dovecot unix - n n - - pipe" >> /etc/postfix/master.cf + echo " flags=DRhu user=vmail:vmail argv=${LDA_PATH} -f \${sender} -d \${user}" >> /etc/postfix/master.cf + + echo "$(date)" > ${INIT_STATE_FILE} +fi + +if [[ "${MAIL_DEBUG_LOG}" == "1" ]]; then + echo "Enabling debug logging for dovecot ..." + echo "debug_log_path = /var/log/dovecot/debug.log" >> /etc/dovecot/conf.d/10-logging.conf + echo "auth_verbose = yes" >> /etc/dovecot/conf.d/10-logging.conf + echo "mail_debug = yes" >> /etc/dovecot/conf.d/10-logging.conf + +fi + + + +echo "Configure postfix main.cf" +postconf -e "myhostname = dovecot" +postconf -e "smtpd_use_tls = no" +postconf -e "myorigin = \$mydomain" +postconf -e "mydestination = " +postconf -e "relayhost = "\$mydomain +#postconf -e "smtpd_tls_cert_file=${SSL_DIR}/certs/${FQDN}.crt" +#postconf -e "smtpd_tls_key_file=${SSL_DIR}/private/${FQDN}.key" +postconf -e "dovecot_destination_recipient_limit = 1" +postconf -e "virtual_mailbox_domains = ${MAIL_DOMAIN}" +postconf -e "virtual_transport = dovecot" +postconf -e "myorigin = \$mydomain" +postconf -e "mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 ${ENV_SUBNET}" +# set home permissions every time ... +chown -R vmail:vmail /home/vmail +chmod 2770 /home/vmail diff --git a/config/dovecot/etc/supervisor/conf.d/dovecot.conf b/config/dovecot/etc/supervisor/conf.d/dovecot.conf new file mode 100644 index 0000000000000000000000000000000000000000..3cfa655719f2342204210ed52662f5558d2d8a86 --- /dev/null +++ b/config/dovecot/etc/supervisor/conf.d/dovecot.conf @@ -0,0 +1,4 @@ +[program:dovecot] +command=/usr/sbin/dovecot -c /etc/dovecot/dovecot.conf -F +autorestart=true +user=root ; TODO: switch to dovecot user \ No newline at end of file diff --git a/config/dovecot/etc/supervisor/conf.d/postfix.conf b/config/dovecot/etc/supervisor/conf.d/postfix.conf new file mode 100644 index 0000000000000000000000000000000000000000..ec480b686a073ef1b34649ce5640c3b8286b59ce --- /dev/null +++ b/config/dovecot/etc/supervisor/conf.d/postfix.conf @@ -0,0 +1,11 @@ +[program:rsyslog] +command=/usr/sbin/rsyslogd -n + +[program:postfix] +process_name=postfix +directory=/etc/postfix +command=/usr/sbin/postfix -c /etc/postfix start +autorestart=false ; it will be marked as failed, postfix is running anyway ... +startretries=1 +user=root ; TODO: switch to postfix user + diff --git a/config/dovecot/etc/supervisor/supervisord.conf b/config/dovecot/etc/supervisor/supervisord.conf new file mode 100644 index 0000000000000000000000000000000000000000..186df065175c4d7e695e96b61edb300dc253c5c3 --- /dev/null +++ b/config/dovecot/etc/supervisor/supervisord.conf @@ -0,0 +1,30 @@ +[supervisord] +nodaemon=false ; start in background +#nodaemon=true ; start in foreground + +[unix_http_server] +file=/var/run/supervisor.sock ; (the path to the socket file) +chmod=0700 ; sockef file mode (default 0700) + +[supervisord] +logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log) +pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid) +childlogdir=/var/log/supervisor ; ('AUTO' child log dir, default $TEMP) + +; the below section must remain in the config file for RPC +; (supervisorctl/web interface) to work, additional interfaces may be +; added by defining them in separate rpcinterface: sections +[rpcinterface:supervisor] +supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface + +[supervisorctl] +serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL for a unix socket + +; The [include] section can just contain the "files" setting. This +; setting can list multiple files (separated by whitespace or +; newlines). It can also contain wildcards. The filenames are +; interpreted as relative to this file. Included files *cannot* +; include files themselves. + +[include] +files = /etc/supervisor/conf.d/*.conf \ No newline at end of file diff --git a/features/codecept.sh b/features/codecept.sh index 6b92b4feb7f1e8dbc6e4e37b6833f5657c6ee00c..efaedae3e86c86e147ac77d0dcf0ec4be31cc3b9 100755 --- a/features/codecept.sh +++ b/features/codecept.sh @@ -114,14 +114,16 @@ git clone --depth 1 -b master https://gitlab.open-xchange.com/frontend/core /op cd /opt/open-xchange/tests/frontend/ui npm install -g allure-commandline --save-dev -setOXProperty PROVISIONING_URL "http://localhost/" /opt/open-xchange/tests/frontend/ui/.env +setOXProperty PROVISIONING_URL "http://192.168.33.211/" /opt/open-xchange/tests/frontend/ui/.env setOXProperty CONTEXT_ID "1337" /opt/open-xchange/tests/frontend/ui/.env setOXProperty SELENIUM_HOST "localhost" /opt/open-xchange/tests/frontend/ui/.env -setOXProperty LAUNCH_URL "http://localhost/appsuite/" /opt/open-xchange/tests/frontend/ui/.env -setOXProperty PROVISIONING_URL "http://localhost/" /opt/open-xchange/tests/frontend/ui/.env +setOXProperty LAUNCH_URL "http://192.168.33.211/appsuite/" /opt/open-xchange/tests/frontend/ui/.env +setOXProperty SMTP_SERVER "192.168.33.211" /opt/open-xchange/tests/frontend/ui/.env +setOXProperty IMAP_SERVER "192.168.33.211" /opt/open-xchange/tests/frontend/ui/.env + yarn [ ! "$(docker ps -a | grep "hA4uYS")" ] && docker run --name "hA4uYS" -d -p 4444:4444 -p 5900:5900 -v /dev/shm:/dev/shm selenium/standalone-chrome-debug:latest -yarn e2e --verbose --debug +yarn e2e elif [[ "${FEATURE_ENABLE}" = false ]]; then diff --git a/features/dovecot.sh b/features/dovecot.sh new file mode 100755 index 0000000000000000000000000000000000000000..55267236a309aaa664c1715b9350c35a337ccba3 --- /dev/null +++ b/features/dovecot.sh @@ -0,0 +1,195 @@ + +#!/bin/bash +# +# Copyright (C) 2019 OX Software GmbH +# +# This file is part of OX Automation. +# +# OX Automation is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# OX Automation is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with OX Automation. If not, see <http://www.gnu.org/licenses/>. +# +# +# Authors: +# Daniel Pondruff <daniel.pondruffopen-xchange.com> +# + +set -e +SCRIPT_DIR="$( cd "$(dirname "$0")" ; pwd -P)" +# sourcing some commonly used functions and executing basic checks +source ${SCRIPT_DIR}/../lib/common.bash +source ${SCRIPT_DIR}/../lib/setup.bash +source ${SCRIPT_DIR}/../lib/dovecot.bash +checkRootPrivileges +detectDistribution + +## Help text +show_usage() { +echo -n " + $0 [OPTIONS] + + --install + --enable + --disable + --restart + -k | --key <value> + +" +} + + +### reading config from command line; overriding defaults +POSITIONAL=() +while [[ $# -gt 0 ]] +do +key="$1" + +case $key in + -h|--help) + show_usage + exit 0 + shift + ;; + --debug) + echo "WARNING: Debug flag set (--debug)" + set -x + shift + ;; + --enable) + FEATURE_ENABLE=true + shift + ;; + --disable) + FEATURE_ENABLE=false + shift + ;; + --install) + FEATURE_INSTALL=true + shift + ;; + -k|--key) + value="$2" + shift + shift + ;; + --restart) + RESTART_OX=true + shift + ;; + *) # unknown option + POSITIONAL+=("$1") # save it in an array for later + shift + ;; +esac +done +set -- "${POSITIONAL[@]}" # restore positional parameters + +if [[ "${FEATURE_INSTALL}" = true ]]; then +installDovecot +INIT_STATE_FILE="/etc/dovecot/dovecot-init-done" + +if [ ! -f "/etc/dovecot/dovecot.conf" ]; then + # Copy default config + echo "Copying default config from /etc/dovecot.dist" + cp -R /etc/dovecot.dist/* /etc/dovecot/ +fi + + +if [ ! -f ${INIT_STATE_FILE} ]; then + echo "Executing init-config script (dovecot-backend) " + echo "$0 $@" + echo "Creating user and group: vmail" + groupadd -g 5000 vmail + useradd -u 5000 -g 5000 -m -d /home/vmail -s /bin/false vmail + adduser dovecot vmail + # Create log dir and adjust permissions + mkdir -p /var/log/dovecot + touch /var/log/dovecot/debug.log + touch /var/log/dovecot/info.log + touch /var/log/dovecot/error.log + chown -R vmail:dovecot /var/log/dovecot* + echo "Creating directory for dovecot acl informations" + mkdir -p /var/lib/dovecot/db + chmod 0770 /var/lib/dovecot + echo "Creating dictionary for shared namespace" + touch /var/lib/dovecot/db/shared-mailboxes.db + echo "Creating virtual directories" + mkdir -p /var/lib/dovecot/virtual/all + chmod -R 700 /var/lib/dovecot/virtual + echo "* + -INBOX/Trash + -INBOX/Trash/* + -INBOX/Spam + -INBOX/Spam/* + all" > /var/lib/dovecot/virtual/all/dovecot-virtual + chown -R vmail:vmail /var/lib/dovecot + LDA_PATH="/usr/lib/dovecot/dovecot-lda" + echo "dovecot unix - n n - - pipe" >> /etc/postfix/master.cf + echo " flags=DRhu user=vmail:vmail argv=${LDA_PATH} -f \${sender} -d \${user}" >> /etc/postfix/master.cf + echo "$(date)" > ${INIT_STATE_FILE} + + + echo "Configure postfix main.cf" + postconf -e "myhostname = dovecot" + postconf -e "smtpd_use_tls = no" + postconf -e "myorigin = \$mydomain" + postconf -e "mydestination = " + postconf -e "relayhost = "\$mydomain + #postconf -e "smtpd_tls_cert_file=${SSL_DIR}/certs/${FQDN}.crt" + #postconf -e "smtpd_tls_key_file=${SSL_DIR}/private/${FQDN}.key" + postconf -e "dovecot_destination_recipient_limit = 1" + postconf -e "virtual_mailbox_domains = ${MAIL_DOMAIN}" + postconf -e "virtual_transport = dovecot" + postconf -e "myorigin = \$mydomain" + postconf -e "mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128 ${ENV_SUBNET}" + # set home permissions every time ... + chown -R vmail:vmail /home/vmail + chmod 2770 /home/vmail +fi +elif [[ "${FEATURE_ENABLE}" = true ]]; then + INPUT=${SCRIPT_DIR}/../config/environment/qa/users.csv + OLDIFS=$IFS + IFS=',' + [ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; } + while read username password + do + if [[ "$username" == "#"* ]]; then + # skipping commented out line + continue + fi + #echo "username : $username" + /opt/open-xchange/sbin/changeuser -u $username -c 10 -A oxadmin -P secret --imapserver "dovecot.qa.open-xchange.com" --smtpserver "dovecot.qa.open-xchange.com" + # echo "password : $password" + done < $INPUT + IFS=$OLDIFS +elif [[ "${FEATURE_ENABLE}" = false ]]; then + INPUT=${SCRIPT_DIR}/../config/environment/qa/users.csv + OLDIFS=$IFS + IFS=',' + [ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; } + while read username password + do + if [[ "$username" == "#"* ]]; then + # skipping commented out line + continue + fi + #echo "username : $username" + /opt/open-xchange/sbin/changeuser -u $username -c 10 -A oxadmin -P secret --imapserver "localhost" --smtpserver "localhost" + # echo "password : $password" + done < $INPUT + IFS=$OLDIFS +fi +if [[ "${RESTART_OX}" = true ]]; then + restartService dovecot +fi + diff --git a/lib/dovecot.bash b/lib/dovecot.bash new file mode 100644 index 0000000000000000000000000000000000000000..822eaf24d36612fe3d29f64994a8014f263b29fa --- /dev/null +++ b/lib/dovecot.bash @@ -0,0 +1,46 @@ + +# +# Copyright (C) 2019 OX Software GmbH +# +# This file is part of OX Automation. +# +# OX Automation is free software: you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# OX Automation is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +# +# See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with OX Automation. If not, see <http://www.gnu.org/licenses/>. +# +# +# Authors: +# Daniel Pondruff <daniel.pondruff@open-xchange.com> +# + +# This restarts the provided service name with the configured service managers + +function installDovecot { + echo "Add Dovecot Build key & Repo" + wget https://repo.dovecot.org/DOVECOT-REPO-GPG && apt-key add DOVECOT-REPO-GPG && \ + echo "deb https://repo.dovecot.org/ce-2.3-latest/debian/stretch stretch main" > /etc/apt/sources.list.d/dovecot.list + + echo "Install Dovecot CE packages" + apt-get update && apt-get install -y dovecot-core \ + dovecot-imapd \ + dovecot-lmtpd \ + dovecot-managesieved \ + dovecot-sieve \ + dovecot-pop3d \ + dovecot-ldap \ + postfix \ + rsyslog + echo "Copy Dovecot Configs" + rm -rf /etc/dovecot/* + cp -R config/dovecot/etc/dovecot/* /etc/dovecot/ +} \ No newline at end of file diff --git a/setup/install-dovecot.sh b/setup/install-dovecot.sh index 41ad98582aa5b38aeaf2694343d5f413123b55f6..bb20f1a2dae59f756cf1dad3830cc9cb4cdc9753 100755 --- a/setup/install-dovecot.sh +++ b/setup/install-dovecot.sh @@ -48,706 +48,9 @@ DC_BUILDKEY="https://apt.dovecot.fi/dovecot-gpg.key" # FUNCTION_DEFINITIONS #================================================================================ -function sanity_checks() { - # Checking if we are running as root - echo -n "Checking user... " - if [[ $EUID -ne 0 ]]; then - die "This script must be run as root." - else - ok "OK." - fi - - # Checking OS architecture - echo -n "Checking architecture... " - ARCH=$(uname -m) - if [[ "${ARCH}" != "x86_64" ]]; then - die "Failed.\nA 64bit operating system is mandatory to install." - else - ok "OK." - fi - - # FQDN check - # ping -c 1 -q "${FQDN}" > /dev/null 2>&1 - # if [[ $? -ne 0 ]]; then - # die "Cannot resolve FQDN (${FQDN}), please check the network configuration." - # fi - - # Release detection - echo -n "Checking operating system... " - OS=$(uname -s) - if [[ ${OS} != "Linux" ]] ; then - die "non-Linux.\n\nError: This installer is designed for Linux based operating systems." - fi - if [[ -f /etc/os-release ]]; then - OS=$(awk -F= '/^ID=/{print $2}' /etc/os-release | tr -d \") - REV=$(awk -F= '/^VERSION_ID/{print $2}' /etc/os-release | tr -d \") - if [[ ${OS} = "debian" ]]; then - export DEBIAN_FRONTEND=noninteractive - if [[ ${REV} = "10" ]]; then - DIST="DebianBuster" - COMPATIBLE=true - DC_REPO_PREFIX="apt" - DC_REPO_SUFFIX="debian/buster/ buster main" - elif [[ ${REV} = "9" ]]; then - DIST="DebianStretch" - COMPATIBLE=true - DC_REPO_PREFIX="apt" - DC_REPO_SUFFIX="debian/stretch/ stretch main" - elif [[ ${REV} = "8" ]]; then - DIST="DebianJessie" - COMPATIBLE=true - DC_REPO_PREFIX="apt" - DC_REPO_SUFFIX="debian/jessie/ jessie main" - elif [[ ${REV} = "7" ]]; then - DIST="DebianWheezy" - COMPATIBLE=true - DC_REPO_PREFIX="apt" - # no wheezy packages, may fail - DC_REPO_SUFFIX="debian/jessie/ jessie main" - fi - elif [[ ${OS} = "ubuntu" ]]; then - export DEBIAN_FRONTEND=noninteractive - if [[ ${REV} = "16.04" ]]; then - DIST="Ubuntu_16.04" - COMPATIBLE=true - DC_REPO_PREFIX="apt" - DC_REPO_SUFFIX="ubuntu/xenial xenial main" - fi - elif [[ ${OS} = "rhel" ]]; then - if [[ ${REV} = "7"* ]]; then - DIST="RHEL7" - COMPATIBLE=true - DC_REPO_PREFIX="yum" - DC_REPO_SUFFIX="rhel/7/RPMS/x86_64/" - fi - elif [[ ${OS} = "centos" ]]; then - if [[ ${REV} = "7"* ]]; then - DIST="CentOS7" - COMPATIBLE=true - DC_REPO_PREFIX="yum" - DC_REPO_SUFFIX="centos/7/RPMS/x86_64/" - fi - fi - elif [[ -f /etc/redhat-release ]]; then - REV=$(sed s/.*Red\ Hat\ Enterprise\ Linux\ Server\ release\ // < /etc/redhat-release | sed s/\ .*//) - if [[ ${REV} = "6."* ]]; then - DIST="RHEL6" - COMPATIBLE=true - DC_REPO_PREFIX="yum" - DC_REPO_SUFFIX="rhel/6/RPMS/x86_64/" - fi - REV=$(sed s/.*CentOS\ release\ // < /etc/redhat-release | sed s/\ .*//) - if [[ ${REV} = "6."* ]]; then - DIST="CentOS6" - COMPATIBLE=true - DC_REPO_PREFIX="yum" - DC_REPO_SUFFIX="centos/6/RPMS/x86_64/" - fi - fi - - if [[ -z ${COMPATIBLE} ]]; then - echo "unknown." - echo "" - echo "This installer supports:" - echo "* Debian GNU/Linux 7.0 (Wheezy)" - echo "* Debian GNU/Linux 8.0 (Jessie)" - echo "* Debian GNU/Linux 9.0 (Wheezy)" - echo "* Debian GNU/Linux 10.0 (Buster)" - echo "* Ubuntu 16.04 (Xenial Xerus)" - echo "* RedHat Enterprise Linux 6.0 (RHEL6)" - echo "* RedHat Enterprise Linux 7.0 (RHEL7)" - echo "* CentOS 6.0" - echo "* CentOS 7.0" - exit 1 - fi - - if [[ ${DIST} == "DebianStretch" ]] || [[ ${DIST} == "DebianJessie" ]] || [[ ${DIST} == "DebianWheezy" ]] || [[ ${DIST} == "DebianBuster" ]] || [[ ${DIST} == "Ubuntu_16.04" ]]; then - if [[ ${DC_PRO} == true ]]; then - #IMAP_PACKAGES="dovecot-ee-*" - IMAP_PACKAGES="dovecot-ee-core dovecot-ee-imapd dovecot-ee-lmtpd dovecot-ee-sieve dovecot-ee-managesieved dovecot-ee-pop3d dovecot-ee-cassandra-plugin dovecot-ee-dovemon dovecot-ee-fts dovecot-ee-license dovecot-ee-lucene dovecot-ee-mail-crypt-plugin dovecot-ee-solr dovecot-ee-virtual-attachments-plugin" - else - IMAP_PACKAGES="dovecot-core dovecot-imapd dovecot-lmtpd dovecot-managesieved dovecot-sieve dovecot-pop3d" - fi - TESTER_PACKAGES="python-pip psmisc" - else - if [[ ${DC_PRO} == true ]]; then - IMAP_PACKAGES="dovecot-ee-core dovecot-ee-imapd dovecot-ee-lmtpd dovecot-ee-pigeonhole dovecot-ee-managesieve dovecot-ee-pop3d dovecot-ee-cassandra-plugin dovecot-ee-dovemon dovecot-ee-fts dovecot-ee-license dovecot-ee-lucene dovecot-ee-mail-crypt-plugin dovecot-ee-solr dovecot-ee-virtual-attachments-plugin" - else - IMAP_PACKAGES="dovecot dovecot-pigeonhole" - fi - fi - -} - -function generate_cert() { - echo "Generating certificate for $FQDN" - if [[ "${DIST}" == "DebianStretch" ]] || [[ "${DIST}" == "DebianJessie" ]] || [[ "${DIST}" == "DebianWheezy" ]] || [[ "${DIST}" == "DebianBuster" ]] || [[ ${DIST} == "Ubuntu_16.04" ]]; then - SSL_DIR="/etc/ssl" - elif [[ "${DIST}" == "RHEL6" ]] || [[ "${DIST}" == "RHEL7" ]] || [[ "${DIST}" == "CentOS6" ]] || [[ "${DIST}" == "CentOS7" ]]; then - SSL_DIR="/etc/pki/tls" - fi - - openssl req -new -x509 -newkey rsa:2048 -days 3650 -nodes -subj "/CN=$FQDN" -keyout "${SSL_DIR}/private/${FQDN}.key" -out "${SSL_DIR}/certs/${FQDN}.crt" - chmod 444 "${SSL_DIR}/certs/${FQDN}.crt" - chmod 400 "${SSL_DIR}/private/${FQDN}.key" - -} - -function add_repo_info { - - echo "Adding repository information..." - - if [[ "${DC_REPO_SOURCE}" == "EXT" && ${DC_PRO} == false ]]; then - # Using EXTernal repository - # Not installing PRO, using Community Edition (ce) - # Using repo.dovecot.org build key - DC_REPO_SRV="https://repo.dovecot.org/" - DC_VERSION_PREFIX="ce-" - DC_BUILDKEY="https://repo.dovecot.org/DOVECOT-REPO-GPG" - - echo "Using official dovecot community packages ... " - URL=${DC_REPO_SRV}${DC_VERSION_PREFIX}${DC_VERSION}/${DC_REPO_SUFFIX} - elif [[ "${DC_REPO_SOURCE}" == "EXT" && ${DC_PRO} == true ]]; then - if [[ ${DIST} = *"Debian"* ]]; then - DC_REPO_SRV="https://${DC_USER}:${DC_PASS}@apt.dovecot.fi/" - elif [[ ${DIST} == *"RHEL"* ]] || [[ ${DIST} == *"CentOS"* ]]; then - DC_REPO_SRV="https://${DC_USER}:${DC_PASS}@yum.dovecot.fi/" - fi - - # Using EXTernal repository - # Installing PRO, using Enterprise Edition (ee, pro) - # Using apt.dovecot.fi build key - DC_VERSION_PREFIX="stable-" - DC_BUILDKEY="https://apt.dovecot.fi/dovecot-gpg.key" - - echo "Using official dovecot pro packages ... " - URL=${DC_REPO_SRV}${DC_VERSION_PREFIX}${DC_VERSION}/${DC_REPO_SUFFIX} - - # We will need 3rdparty drivers for pro: - DC_3RD_PARTY="${DC_REPO_SRV}3rdparty/${DC_REPO_SUFFIX}" - - elif [[ "${DC_REPO_SOURCE}" == "INT" && ${DC_PRO} == true ]]; then - if [[ ${DIST} = *"Debian"* ]]; then - DC_REPO_SRV="https://apt.dovecot.net/" - elif [[ ${DIST} == *"RHEL"* ]] || [[ ${DIST} == *"CentOS"* ]]; then - DC_REPO_SRV="https://yum.dovecot.net/" - fi - - # Using INTernal repository - # Installing PRO, using ee packages - # Using ?? build key - DC_VERSION_PREFIX="" - DC_BUILDKEY="https://repo.dovecot.org/DOVECOT-REPO-GPG" # ?? - - echo "Using internal dovecot enterprise packages ... " - URL="${DC_REPO_SRV}${DC_VERSION}/${DC_REPO_SUFFIX}" - - # We will need 3rdparty drivers for pro: - DC_3RD_PARTY="${DC_REPO_SRV}3rdparty/${DC_REPO_SUFFIX}" - - # Right now there seems to be no access to the build key to the public - # We have to override the key check - OVERRIDE_BUILDKEY_CHECK=true - elif [[ "${DC_REPO_SOURCE}" == "SNAPSHOT" && ${DC_PRO} == false ]]; then - if [[ -z ${DC_USER} ]] || [[ -z ${DC_PASS} ]]; then - die "ERROR: Missing credentials for dovecot pro repository (specify in set-install.sh)" - fi - - if [[ ${DIST} = *"Debian"* ]]; then - # Using external snapshot repository - # SEE: https://wiki2.dovecot.org/PrebuiltBinaries - # Not installing PRO, using Community Edition (ce) - # Using xi.dovecot.fi build key - - DC_BUILDKEY="http://xi.dovecot.fi/debian/archive.key" - DC_REPO_SRV="https://xi.dovecot.fi/" - - # Building debian snapshot url - URL="${DC_REPO_SRV}debian/ " - if [[ ${DIST} == "DebianStretch" ]]; then - URL=${URL}"stretch" - elif [[ ${DIST} == "DebianJessie" ]]; then - URL=${URL}"jessie" - elif [[ ${DIST} == "DebianWheezy" ]]; then - URL=${URL}"wheezy" - elif [[ ${DIST} == "DebianBuster" ]]; then - URL=${URL}"buster" - fi - URL="${URL}-auto/dovecot-${DC_VERSION} main" - - echo "Using official dovecot snapshot packages (debian only, ce only)... " - - else - die "ERROR: Snapshot packages are only available for Debian based distributions ..." - fi - fi - - - echo "Repository url: "$URL - if [[ -z ${URL} ]]; then - die "ERROR: could not determine repository url ..." - fi - # At this time a valid repository url for the current distro is required. - # Otherwise it may install outdated dovecot packages that are delievered with the distro - - # write repo data - if [[ ${DIST} == "DebianStretch" ]] || [[ ${DIST} == "DebianJessie" ]] || [[ ${DIST} == "DebianWheezy" ]] || [[ ${DIST} == "DebianBuster" ]] || [[ ${DIST} == "Ubuntu_16.04" ]]; then - echo "deb ${URL}" > /etc/apt/sources.list.d/dovecot.list - - if [[ -n ${DC_3RD_PARTY} ]]; then - echo "Adding 3rd party dovecot repo ..." - echo "deb ${DC_3RD_PARTY}" > /etc/apt/sources.list.d/dovecot-3rd.list - fi - elif [[ ${DIST} == "RHEL6" ]] || [[ ${DIST} == "RHEL7" ]] || [[ ${DIST} == "CentOS6" ]] || [[ ${DIST} == "CentOS7" ]]; then - - { - echo "[dovecot]" - echo "name=Dovecot Repo" - echo "baseurl=${URL}/" - echo "enabled=1" - } > /etc/yum.repos.d/dovecot.repo - - - { - echo "[dovecot-3rdparty]" - echo "name=Dovecot 3rdparty" - echo "baseurl=${DC_3RD_PARTY}/" - echo "enabled=1" - } > /etc/yum.repos.d/dovecot-3rd.repo - fi -} - -function install_packages() { - # Adding OX App Suite and Dovecot repository build key - echo -n "Adding OX App Suite and Dovecot repository build key..." - if [[ "${DIST}" == "DebianStretch" ]] || [[ "${DIST}" == "DebianJessie" ]] || [[ "${DIST}" == "DebianWheezy" ]] || [[ ${DIST} == "DebianBuster" ]] || [[ ${DIST} == "Ubuntu_16.04" ]]; then - wget -q ${AS_BUILDKEY} -O - | apt-key add - - wget -q ${DC_BUILDKEY} -O - | apt-key add - - elif [[ "${DIST}" == "RHEL6" ]] || [[ "${DIST}" == "RHEL7" ]]; then - rpm --import ${AS_BUILDKEY} - rpm --import ${DC_BUILDKEY} - elif [[ "${DIST}" == "CentOS6" ]] || [[ "${DIST}" == "CentOS7" ]]; then - rpm --import ${AS_BUILDKEY} - rpm --import ${DC_BUILDKEY} - fi - - if [[ true == "${POSTFIX}" ]]; then - SMTP_PACKAGES="postfix" - fi - - PACKAGES="${IMAP_PACKAGES} ${SMTP_PACKAGES}" - - echo "Installing mail backend packages..." - - INSTALL_OPTIONS="-y " - - if [[ ${DIST} == "DebianStretch" ]] || [[ ${DIST} == "DebianWheezy" ]] || [[ ${DIST} == "DebianJessie" ]] || [[ ${DIST} == "DebianBuster" ]] || [[ ${DIST} == "Ubuntu_16.04" ]]; then - if [[ true == "${POSTFIX}" ]]; then - echo "postfix postfix/main_mailer_type select Internet Site" | debconf-set-selections - echo "postfix postfix/mailname string $FQDN" | debconf-set-selections - echo "postfix postfix/relayhost string \$mydomain" | debconf-set-selections - echo "postfix postfix/protocols select all" | debconf-set-selections - echo "postfix postfix/procmail boolean false" | debconf-set-selections - fi - - if [[ "${OVERRIDE_BUILDKEY_CHECK}" == true ]]; then - INSTALL_OPTIONS="${INSTALL_OPTIONS}--allow-unauthenticated " - fi - - apt-get clean - apt-get -qq update - apt-get ${INSTALL_OPTIONS} install ${PACKAGES} ${TESTER_PACKAGES} - elif [[ ${DIST} == "RHEL6" ]] || [[ ${DIST} == "RHEL7" ]]; then - if [[ "${OVERRIDE_BUILDKEY_CHECK}" == true ]]; then - INSTALL_OPTIONS="${INSTALL_OPTIONS}--nogpgcheck " - fi - - subscription-manager refresh - yum clean all - yum ${INSTALL_OPTIONS} install ${PACKAGES} ${TESTER_PACKAGES} - elif [[ ${DIST} == "CentOS6" ]] || [[ ${DIST} == "CentOS7" ]]; then - if [[ "${OVERRIDE_BUILDKEY_CHECK}" == true ]]; then - INSTALL_OPTIONS="${INSTALL_OPTIONS}--nogpgcheck " - fi - yum clean all - yum ${INSTALL_OPTIONS} install ${PACKAGES} ${TESTER_PACKAGES} - fi -} - -function configure_postfix() { - echo "Configure postfix main.cf" - postconf -e "myorigin = \$mydomain" - postconf -e "mydestination = " - postconf -e "relayhost = "\$mydomain - postconf -e "smtpd_tls_cert_file=${SSL_DIR}/certs/${FQDN}.crt" - postconf -e "smtpd_tls_key_file=${SSL_DIR}/private/${FQDN}.key" - postconf -e "dovecot_destination_recipient_limit = 1" - postconf -e "virtual_mailbox_domains = $FQDN, $DN, $DN.localdomain" - postconf -e "virtual_transport = dovecot" - - echo "Configure postfix master.cf" - # uncomment the next line if you want debug output - #postconf -M smtp/inet="smtp inet n - - - - smtpd -v" - - if [[ ${DIST} == "DebianStretch" ]] || [[ ${DIST} == "DebianWheezy" ]] || [[ ${DIST} == "DebianJessie" ]] || [[ ${DIST} == "DebianBuster" ]] || [[ ${DIST} == "Ubuntu_16.04" ]]; then - LDA_PATH="/usr/lib/dovecot/dovecot-lda" - else - LDA_PATH="/usr/libexec/dovecot/dovecot-lda" - fi - - - echo "dovecot unix - n n - - pipe" >> /etc/postfix/master.cf - echo " flags=DRhu user=vmail:vmail argv=${LDA_PATH} -f \${sender} -d \${user}" >> /etc/postfix/master.cf -} - -function configure_dovecot() { - echo "Configure dovecot" - DC_CONF_DIR="/etc/dovecot/conf.d/" - - if [[ "${DIST}" == "CentOS6" ]] || [[ "${DIST}" == "CentOS7" ]]; then - selinuxenabled - if [ $? -ne 0 ] - then - echo "Selinux not enabled" - else - echo "Enabling selinux dovecot policies" - semanage permissive -a dovecot_t - fi - fi - - if [[ true == "${DC_PRO}" ]]; then - if [[ "${DIST}" == "CentOS6" ]] || [[ "${DIST}" == "CentOS7" ]] || [[ "${DIST}" == "RHEL6" ]] || [[ "${DIST}" == "RHEL7" ]]; then - DC_DEFAULT_CONF_DIR="/usr/share/doc/dovecot-ee-*/example-config/conf.d/" - declare -a CONF_FILE_LIST=("10-mail.conf" "10-master.conf" "10-auth.conf" "10-ssl.conf" "10-logging.conf" "15-lda.conf" "20-imap.conf" "20-managesieve.conf" "90-quota.conf" "90-plugin.conf" "90-sieve.conf" "90-acl.conf" "auth-static.conf.ext" "../dovecot.conf") - elif [[ "${DIST}" == "DebianStretch" ]] || [[ "${DIST}" == "DebianWheezy" ]] || [[ "${DIST}" == "DebianJessie" ]] || [[ "${DIST}" == "DebianBuster" ]] || [[ ${DIST} == "Ubuntu_16.04" ]]; then - DC_DEFAULT_CONF_DIR="/usr/share/doc/dovecot-ee-core/example-config/conf.d/" - declare -a CONF_FILE_LIST=("10-master.conf" "10-logging.conf" "15-lda.conf" "10-ssl.conf" "20-imap.conf" "20-managesieve.conf" "90-quota.conf" "90-plugin.conf" "90-acl.conf" "auth-static.conf.ext") - cp /usr/share/doc/dovecot-ee-core/example-config/conf.d/10-mail.conf "${DC_CONF_DIR}"10-mail.conf - cp /usr/share/doc/dovecot-ee-core/example-config/conf.d/10-auth.conf "${DC_CONF_DIR}"10-auth.conf - cp /usr/share/doc/dovecot-ee-core/example-config/dovecot.conf "${DC_CONF_DIR}"../dovecot.conf - gunzip /usr/share/doc/dovecot/example-config/conf.d/90-sieve.conf.gz -c > "${DC_CONF_DIR}"90-sieve.conf - cp /usr/share/doc/dovecot/example-config/conf.d/20-managesieve.conf "${DC_CONF_DIR}"20-managesieve.conf - fi - else - DC_DEFAULT_CONF_DIR="/usr/share/dovecot/conf.d/" - declare -a CONF_FILE_LIST=("20-imap.conf" "20-managesieve.conf" "90-sieve.conf" "../dovecot.conf") - fi - - for file in "${CONF_FILE_LIST[@]}" - do - if [ ! -f "${DC_CONF_DIR}/${file}" ] - then - echo -n "Copying $file to ${DC_CONF_DIR}... " - cp ${DC_DEFAULT_CONF_DIR}${file} ${DC_CONF_DIR}${file} - ok "OK" - fi - done - echo "Backing up config files" - for file in "10-mail.conf" "10-master.conf" "10-auth.conf" "10-ssl.conf" "auth-static.conf.ext" "10-logging.conf" "15-lda.conf" "20-imap.conf" "20-managesieve.conf" "90-quota.conf" "90-acl.conf" "90-plugin.conf" - do - echo -n "Renaming file ${file} to ${file}.orig... " - mv -- "${DC_CONF_DIR}${file}" "${DC_CONF_DIR}${file}.orig" - echo "OK" - done - - # dovecot.conf - sed -i '/\!include\_try.*protocol/a protocols = imap lmtp' /etc/dovecot/dovecot.conf - - # 10-mail.conf - if [[ "${DC_VERSION}" == "2.3" ]] || [[ "${DC_VERSION}" > "2.3."* ]]; then - DC_MAIL_PLUGINS="acl mail_log notify quota old_stats virtual zlib" - else - DC_MAIL_PLUGINS="acl mail_log notify quota stats virtual zlib" - fi - - if [[ "${DC_VERSION}" > "2.2.27"* ]] || [[ "${DC_REPO}" == "nightly" ]]; then - cat > "${DC_CONF_DIR}"/10-mail.conf <<EOF -mail_vsize_bg_after_count = 100 -EOF - fi - - cat >> "${DC_CONF_DIR}"/10-mail.conf <<EOF -mailbox_list_index = yes -mail_always_cache_fields = body.snippet -mail_location = maildir:~/Maildir -mail_uid = vmail -mail_gid = vmail -EOF - - if [[ true == "${DC_PRO}" ]]; then - cat >> "${DC_CONF_DIR}"/10-mail.conf <<EOF -mail_plugins = \$mail_plugins ${DC_MAIL_PLUGINS} virtual_attachments -EOF - else - cat >> "${DC_CONF_DIR}"/10-mail.conf <<EOF -mail_plugins = \$mail_plugins ${DC_MAIL_PLUGINS} -EOF - fi - - cat >> "${DC_CONF_DIR}"/10-mail.conf <<EOF - -namespace inbox { - inbox = yes - prefix = INBOX/ - separator = / -} - -namespace { - type = shared - separator = / - prefix = shared/%%u/ - location = maildir:%%h/Maildir:INDEX=%h/shared/%%u:CONTROL=%h/shared/%%u - subscriptions = yes - list = children -} -EOF - - if [[ "${DIST}" != "CentOS6" ]] && [[ "${DIST}" != "RHEL6" ]]; then - cat >> "${DC_CONF_DIR}"/10-mail.conf <<EOF -namespace virtual { - prefix = virtual/ - separator = / - hidden = yes - list = no - subscriptions = no - location = virtual:/var/lib/dovecot/virtual:INDEX=~/Maildir/virtual - mailbox all { - special_use = \All - } -} -EOF - fi - - if [[ ${DC_PRO} == true ]]; then - cat >> "${DC_CONF_DIR}"/10-mail.conf <<EOF -namespace virtualattachments { - prefix = VirtualAttachments/ - separator = / - hidden = yes - list = no - subscriptions = no - location = attachments:~/Maildir/virtual-attachments - mailbox INBOX { - auto = create - } - mailbox "INBOX/Sent Items" { - auto = create - } - mailbox virtual/all { - auto = create - special_use = \All - } -} -EOF - fi - - # TLS cert - if [[ "${DIST}" == "CentOS6" ]] || [[ "${DIST}" == "CentOS7" ]] || [[ "${DIST}" == "RHEL6" ]] || [[ "${DIST}" == "RHEL7" ]]; then - DC_CERT_FILE="/etc/pki/dovecot/certs/dovecot.pem" - DC_KEY_FILE="/etc/pki/dovecot/private/dovecot.pem" - elif [[ "${DIST}" == "DebianStretch" ]] || [[ "${DIST}" == "DebianWheezy" ]] || [[ "${DIST}" == "DebianJessie" ]] || [[ "${DIST}" == "DebianBuster" ]] || [[ ${DIST} == "Ubuntu_16.04" ]]; then - if [[ true == "${DC_PRO}" ]]; then - DC_CERT_FILE="/etc/ssl/certs/dovecot.pem" - DC_KEY_FILE="/etc/ssl/private/dovecot.pem" - else - DC_CERT_FILE="/etc/dovecot/dovecot.pem" - DC_KEY_FILE="/etc/dovecot/private/dovecot.pem" - fi - fi - - if [[ "${DIST}" == "CentOS7" ]] || [[ "${DIST}" == "RHEL7" ]]; then - if [[ true == "${DC_PRO}" ]]; then - cd /usr/share/doc/dovecot-ee-+([0-9])* - else - cd /usr/share/doc/dovecot-+([0-9])* - fi - elif [[ "${DIST}" == "CentOS6" ]] || [[ "${DIST}" == "RHEL6" ]]; then - if [[ true == "${DC_PRO}" ]]; then - cd /usr/share/doc/dovecot-ee-+([0-9])* - else - cd /usr/libexec/dovecot/ - fi - elif [[ "${DIST}" == "DebianStretch" ]] || [[ "${DIST}" == "DebianWheezy" ]] || [[ "${DIST}" == "DebianJessie" ]] || [[ "${DIST}" == "DebianBuster" ]] || [[ ${DIST} == "Ubuntu_16.04" ]]; then - if [[ true == "${DC_PRO}" ]]; then - cd /usr/share/doc/dovecot-ee-core/ - else - cd /usr/share/dovecot/ - fi - fi - - # 10-ssl.conf - cat > "${DC_CONF_DIR}"/10-ssl.conf <<EOF -ssl = yes -ssl_cert = <${DC_CERT_FILE} -ssl_key = <${DC_KEY_FILE} -EOF - - if [[ "${DC_VERSION}" == "2.3" ]] || [[ "${DC_VERSION}" > "2.3."* ]]; then - DC_SSL_DH_FILE="/etc/dovecot/dh.pem" - echo "Generating ssl dh file with openssl dhparam 2048 at ${DC_SSL_DH_FILE}" - openssl dhparam -out ${DC_SSL_DH_FILE} 2048 - cat >> "${DC_CONF_DIR}"/10-ssl.conf <<EOF -ssl_dh = <${DC_SSL_DH_FILE} -EOF - fi - bash mkcert.sh - - # 10-master.conf - cat > "${DC_CONF_DIR}"/10-master.conf <<EOF -service auth { - unix_listener auth-userdb { - mode = 0666 - user = vmail - group = vmail - } -} -EOF - # 10-auth.conf - cat > "${DC_CONF_DIR}"/10-auth.conf <<EOF -disable_plaintext_auth = no -auth_mechanisms = plain -!include auth-static.conf.ext -EOF - - # auth-static.conf.ext - cat > "${DC_CONF_DIR}"/auth-static.conf.ext <<EOF -passdb { - driver = static - args = password=secret -} - -userdb { - driver = static - args = uid=vmail gid=vmail home=/home/vmail/%u -} -EOF - - # 10-logging.conf - cat > "${DC_CONF_DIR}"/10-logging.conf <<EOF -#log_path = /var/log/dovecot.log -auth_verbose = yes -plugin { - mail_log_events = delete undelete expunge copy flag_change append mailbox_delete mailbox_rename - mail_log_fields = uid box msgid size -} -EOF - - # 15-lda.conf - cat > "${DC_CONF_DIR}"/15-lda.conf <<EOF -protocol lda { - mail_plugins = \$mail_plugins sieve -} -postmaster_address = invalid@invalid.invalid -EOF - - if [[ "${DC_VERSION}" == "2.3" ]] || [[ "${DC_VERSION}" > "2.3."* ]]; then - DC_IMAP_PLUGINS="imap_acl imap_quota imap_old_stats imap_filter_sieve" - else - DC_IMAP_PLUGINS="imap_acl imap_quota imap_stats" - fi - - # 20-imap.conf - cat > "${DC_CONF_DIR}"/20-imap.conf <<EOF -imap_capability = +SEARCH=X-MIMEPART XDOVECOT -protocol imap { - mail_plugins = \$mail_plugins ${DC_IMAP_PLUGINS} -} -EOF - - # 20-managesieve.conf - cat > "${DC_CONF_DIR}"/20-managesieve.conf <<EOF -protocols = \$protocols sieve -service managesieve-login { - inet_listener sieve { - port = 4190 - } -} -EOF - - # 90-quota.conf - cat > "${DC_CONF_DIR}"/90-quota.conf <<EOF -plugin { - quota = count:User quota - quota_rule = *:storage=1G - quota_rule2 = INBOX/Trash:storage=+100M - quota_grace = 10%% -} -plugin { - quota = maildir:User quota -} -EOF - - # 90-acl.conf - cat > "${DC_CONF_DIR}"/90-acl.conf <<EOF -plugin { - acl = vfile - acl_shared_dict = file:/var/lib/dovecot/db/shared-mailboxes.db -} -EOF - - # 91-stats.conf - if [[ "${DC_VERSION}" == "2.3" ]] || [[ "${DC_VERSION}" > "2.3."* ]]; then - cat >> "${DC_CONF_DIR}"/91-stats.conf <<EOF -service old-stats { - fifo_listener old-stats-mail { - user = vmail - mode = 0600 - } - ## permission denied issues @RHEL - #inet_listener { - # address = 127.0.0.1 - # port = 24242 - #} -} -EOF - else - cat >> "${DC_CONF_DIR}"/91-stats.conf <<EOF -service stats { - fifo_listener stats-mail { - user = vmail - mode = 0600 - } - ## permission denied issues @RHEL - #inet_listener { - # address = 127.0.0.1 - # port = 24242 - #} -} -EOF - fi - -} - -function prerequisites() { - echo "Creating user and group: vmail" - groupadd -g 5000 vmail - useradd -u 5000 -g 5000 -m -d /home/vmail -s /bin/false vmail - chown -R vmail:vmail /home/vmail - chmod 2770 /home/vmail - - echo "Creating directory for dovecot acl informations" - mkdir -p /var/lib/dovecot/db - chmod 0770 /var/lib/dovecot - - echo "Creating dictionary for shared namespace" - touch /var/lib/dovecot/db/shared-mailboxes.db - - echo "Creating virtual directories" - mkdir -p /var/lib/dovecot/virtual/all - chmod -R 700 /var/lib/dovecot/virtual - - echo "* --INBOX/Trash --INBOX/Trash/* --INBOX/Spam --INBOX/Spam/* - all" > /var/lib/dovecot/virtual/all/dovecot-virtual - - chown -R vmail:vmail /var/lib/dovecot -} function restart_services() { if [[ "${DIST}" == "DebianWheezy" ]] || [[ "${DIST}" == "DebianBuster" ]] || [[ "${DIST}" == "CentOS6" ]] || [[ "${DIST}" == "RHEL6" ]]; then @@ -860,31 +163,3 @@ fi # fi # fi -sanity_checks -prerequisites -generate_cert -add_repo_info -INSTALLCOUNT=0 -while [[ ${INSTALLCOUNT} -lt 6 ]]; do - install_packages - if [[ $? -ne 0 ]]; then - INSTALLCOUNT=$((INSTALLCOUNT+1)) - echo "Error while installing packages, retrying in 30s ($INSTALLCOUNT/5)." - sleep 30 - else - break - fi -done -if [[ ${INSTALLCOUNT} -ge 5 ]]; then - echo "Error while installing packages, aborting." - exit 1 -fi -if [[ true == "${POSTFIX}" ]]; then - configure_postfix -fi -configure_dovecot -restart_services - -echo " -Installation complete, thanks for using Dovecot. Have a lot of fun! -"