diff --git a/install_update_dovecot-2.4.sh b/install_update_dovecot-2.4.sh index 12f3f85..7f8b6c9 100755 --- a/install_update_dovecot-2.4.sh +++ b/install_update_dovecot-2.4.sh @@ -31,9 +31,12 @@ _backup_crontab_file="/tmp/crontab_root.${backup_date}" rc_done="\033[71G[ \033[32mdone\033[m ]" rc_failed="\033[71G[ \033[31m\033[1mfailed\033[m ]" -rc_skipped="\033[71G[ \033[33m\033[1mskipped\033[m ]" +#rc_skipped="\033[71G[ \033[33m\033[1mskipped\033[m ]" +rc_skipped="\033[71G[ \033[1;37mskipped\033[m ]" rc_wait="\033[71G[ \033[5m\033[1m..\033[m ]" +rc_not_yet_implemented="\033[71G[ \033[1;33mNot Yet Implemented\033[m ]" + # ------------- # - Functions an Variable @@ -172,7 +175,7 @@ detect_os_1 echo -echononl "\tInclude Configuration file.." +echononl " Include Configuration file.." if [[ ! -f $conf_file ]]; then echo -e "$rc_failed" fatal "Missing configuration file '$conf_file'" @@ -505,6 +508,7 @@ rc_done="${rc_done}" rc_failed="${rc_failed}" rc_skipped="${rc_skipped}" rc_wait="${rc_wait}" +rc_not_yet_implemented="${rc_not_yet_implemented}" clean_up() { @@ -763,7 +767,7 @@ export PGPASSWORD=$dbpassword echo -e "\033[1mDoing some backups\033[m.." -echononl "\tBackup existing installation log directory.." +echononl " Backup existing installation log directory.." if [[ -d "${_log_dir}" ]]; then mv "${_log_dir}" "${_log_dir}.${backup_date}" if [ "$?" = 0 ]; then @@ -776,7 +780,7 @@ else echo -e "$rc_skipped" fi -echononl "\tBackup existing installation directory.." +echononl " Backup existing installation directory.." if [[ -d "/usr/local/dovecot-${_version}" ]]; then mv "/usr/local/dovecot-${_version}" "/usr/local/dovecot-${_version}.${backup_date}" if [ "$?" = 0 ]; then @@ -799,7 +803,7 @@ else echo -e "$rc_skipped" fi -echononl "\tBackup existing source directory.." +echononl " Backup existing source directory.." if [[ -d "${_src_base_dir}/dovecot-${_version}" ]]; then mv "${_src_base_dir}/dovecot-${_version}" "${_src_base_dir}/dovecot-${_version}.${backup_date}" if [ "$?" = 0 ]; then @@ -835,7 +839,7 @@ echo -e "\033[1mDownload sources\033[m.." ## - Downloud Dovecot 2.2.x ## - -echononl "\tDownload dovecot-${_version}.tar.gz" +echononl " Download dovecot-${_version}.tar.gz" if [ ! -f "${_src_base_dir}/dovecot-${_version}.tar.gz" ]; then wget --no-check-certificate https://dovecot.org/releases/${dovecot_main_version}/dovecot-${_version}.tar.gz > /dev/null 2>&1 if [ "$?" = 0 ]; then @@ -864,7 +868,7 @@ fi ## - if [[ ${dovecot_major_version} -eq 2 ]] && [[ ${dovecot_minor_version} -lt 4 ]] ; then - echononl "\tDownload dovecot-${dovecot_main_version}-pigeonhole-${_pigeonhole}.tar.gz.." + echononl " Download dovecot-${dovecot_main_version}-pigeonhole-${_pigeonhole}.tar.gz.." 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 if [ "$?" = 0 ]; then @@ -876,7 +880,7 @@ if [[ ${dovecot_major_version} -eq 2 ]] && [[ ${dovecot_minor_version} -lt 4 ]] Download \033[1mdovecot-${dovecot_main_version}-pigeonhole-${_pigeonhole}.tar.gz\033[m manually and proceed instllation." - echononl "\tProceed instllation [yes/no]: " + echononl " Proceed instllation [yes/no]: " read OK OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do @@ -894,7 +898,7 @@ if [[ ${dovecot_major_version} -eq 2 ]] && [[ ${dovecot_minor_version} -lt 4 ]] else - echononl "\tDownload dovecot-pigeonhole-${_pigeonhole}.tar.gz.." + echononl " Download 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 @@ -910,7 +914,7 @@ else \033[1mdovecot-pigeonhole-${_pigeonhole}.tar.gz\033[m\n" - echononl "\tProceed instllation [yes/no]: " + echononl " Proceed instllation [yes/no]: " read OK OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do @@ -935,7 +939,7 @@ if $_new ; then ## - echo "" echo -e "\033[1mInstalling required debian packages\033[m.." - echononl "\tInstalling libpq5 libpq-dev .." + echononl " Installing libpq5 libpq-dev .." if ! dpkg -l libpq-dev | grep -e "^ii" | grep libpq-dev > /dev/null ; then apt-get install libpq5 libpq-dev > ${_log_dir}/debian-install.log 2&>1 if [ "$?" = 0 ]; then @@ -947,7 +951,7 @@ if $_new ; then else echo -e "$rc_skipped" fi - echononl "\tInstalling libkrb5-dev .." + echononl " Installing libkrb5-dev .." if ! dpkg -l libkrb5-dev | grep -e "^ii" | grep libkrb5-dev > /dev/null ; then apt-get install libkrb5-dev >> ${_log_dir}/debian-install.log 2&>1 if [ "$?" = 0 ]; then @@ -967,7 +971,7 @@ fi echo "" echo -e "\033[1mCreate required users/groups\033[m.." -echononl "\tCreate group dovecot.." +echononl " Create group dovecot.." if ! grep dovecot /etc/group > /dev/null ; then addgroup --system --gid 91 dovecot > ${_log_dir}/system.log 2>&1 if [ "$?" = 0 ]; then @@ -980,7 +984,7 @@ else echo -e "$rc_skipped" fi -echononl "\tCreate user dovecot.." +echononl " Create user dovecot.." if ! grep dovecot /etc/passwd > /dev/null ; then adduser --system --home /var/empty --no-create-home --shell /usr/sbin/nologin \ --ingroup dovecot --uid 91 dovecot > ${_log_dir}/system.log 2>&1 @@ -994,7 +998,7 @@ else echo -e "$rc_skipped" fi -echononl "\tAdd Apache User (${http_user}) to group 'dovecot'.." +echononl " Add Apache User (${http_user}) to group 'dovecot'.." if getent group dovecot 2> /dev/null | grep -q "\b${http_user}\b" > /dev/null 2>&1 ; then echo -e "$rc_skipped" else @@ -1008,7 +1012,7 @@ else fi -echononl "\tCreate group dovenull.." +echononl " Create group dovenull.." if ! grep dovenull /etc/group > /dev/null ; then addgroup --system --gid 65533 dovenull > ${_log_dir}/system.log 2>&1 if [ "$?" = 0 ]; then @@ -1020,7 +1024,7 @@ if ! grep dovenull /etc/group > /dev/null ; then else echo -e "$rc_skipped" fi -echononl "\tCreate user dovenull.." +echononl " Create user dovenull.." if ! grep dovenull /etc/passwd > /dev/null ; then adduser --system --home /var/empty --no-create-home --shell /usr/sbin/nologin \ --ingroup dovenull --uid 65533 dovenull > ${_log_dir}/system.log 2>&1 @@ -1039,7 +1043,7 @@ if $update ; then # - Deaktiviere Cronjobs # - echo "" - echononl "\tBackup Crontab (user toot) to '$_backup_crontab_file'" + echononl " Backup Crontab (user toot) to '$_backup_crontab_file'" crontab -l > $_backup_crontab_file 2> $log_file if [[ $? -eq 0 ]]; then echo -e "$rc_done" @@ -1054,7 +1058,7 @@ if $update ; then rm -f $_backup_crontab_file fi - echononl "\tRemove crontab for user root.." + echononl " Remove crontab for user root.." crontab -r > $log_file 2>&1 if [[ $? -eq 0 ]]; then echo -e "$rc_done" @@ -1076,7 +1080,7 @@ echo -e "\033[1mInstalling Base System\033[m.." ## - Unpack dovecot sources ## - cd ${_src_base_dir} -echononl "\tUnpack dovecot-${_version}.tar.gz.." +echononl " Unpack dovecot-${_version}.tar.gz.." tar -xzf dovecot-${_version}.tar.gz > /dev/null if [ "$?" = 0 ]; then echo -e "$rc_done" @@ -1101,7 +1105,7 @@ if $systemd_support ; then fi #--with-systemdsystemunitdir=/etc/systemd/system/" -echononl "\tConfigure Dovecot.." +echononl " Configure Dovecot.." #./configure \ # --prefix=/usr/local/dovecot-${_version} \ # --with-${db_driver} \ @@ -1121,7 +1125,7 @@ fi ## - Compile dovecot ## - -echononl "\tCompile Dovecot Sources.." +echononl " Compile Dovecot Sources.." make > ${_log_dir}/dovecot-${_version}-make.log 2>&1 || clean_up 1 if [ "$?" = 0 ]; then echo -e "$rc_done" @@ -1134,7 +1138,7 @@ fi ## ----------------- ## --- Stop dovecot if running -echononl "\tStop dovecot service.." +echononl " Stop dovecot service.." if ps ax 2> /dev/null | grep -q -E "/usr/local/dovecot[0-9.-]*/sbin/dovecot" > /dev/null 2>&1 ; then if $systemd_support ; then systemctl stop dovecot > /dev/null 2>&1 @@ -1153,7 +1157,7 @@ fi blank_line -echononl "\tRemove dovecot service file if exists.." +echononl " Remove dovecot service file if exists.." if [[ -f "/etc/systemd/system/dovecot.service" ]] ; then rm -f "/etc/systemd/system/dovecot.service" > /dev/null 2>&1 if [[ "$?" -gt 0 ]]; then @@ -1166,7 +1170,7 @@ else echo -e "$rc_skipped" fi -echononl "\tRemove dovecot systemd's socket file if exists.." +echononl " Remove dovecot systemd's socket file if exists.." if [[ -f "/etc/systemd/system/dovecot.socket" ]] ; then rm -f "/etc/systemd/system/dovecot.socket" > /dev/null 2>&1 if [[ "$?" -gt 0 ]]; then @@ -1179,7 +1183,7 @@ else echo -e "$rc_skipped" fi -echononl "\tRemove directory '/etc/systemd/system/dovecot.service.d' if exists.." +echononl " Remove directory '/etc/systemd/system/dovecot.service.d' if exists.." if [[ -d "/etc/systemd/system/dovecot.service.d" ]] ; then rm -rf "/etc/systemd/system/dovecot.service.d" > /dev/null 2>&1 if [[ "$?" -gt 0 ]]; then @@ -1196,7 +1200,7 @@ blank_line ## - Install dovecot ## - -echononl "\tInstall Dovecot into Folder /usr/local/dovecot-${_version}" +echononl " Install Dovecot into Folder /usr/local/dovecot-${_version}" make install > ${_log_dir}/dovecot-${_version}-install.log 2>&1 || clean_up 1 if [ "$?" = 0 ]; then echo -e "$rc_done" @@ -1205,6 +1209,31 @@ else fatal Installing dovecot failed fi +blank_line + +echononl " Create Configuration Directory 'etc/dovecot/conf.d'.." +if [[ ! -d "/usr/local/dovecot-${_version}/etc/dovecot/conf.d" ]] ; then + mkdir -p "/usr/local/dovecot-${_version}/etc/dovecot/conf.d" > $log_file 2>&1 + if [ "$?" = 0 ]; then + echo -e "$rc_done" + else + echo -e "$rc_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 +else + echo -e "$rc_skipped" +fi + ## - Add /usr/local/dovecot/bin to PATH variable ## - @@ -1215,7 +1244,7 @@ fi ## - PATH=$PATH:$checkdir ## - fi ## - -echononl "\tAdd /usr/local/dovecot/bin to PATH variable.." +echononl " Add /usr/local/dovecot/bin to PATH variable.." if ! grep "checkdir=\"/usr/local/dovecot/bin\"" /etc/profile > /dev/null ; then perl -i -n -p -e "s#^(\s*)(export\ +PATH)#checkdir=\"/usr/local/dovecot/bin\"\nif [ -d \\\$checkdir ]; then\n PATH=\\\$PATH:\\\$checkdir\nfi\n\n\1\2#" /etc/profile if [ "$?" = 0 ]; then @@ -1228,7 +1257,7 @@ else echo -e "$rc_skipped" fi -echononl "\tCopy Manpages if not exists.." +echononl " Copy Manpages if not exists.." ## - Manpages ## - if ! grep /usr/local/dovecot/share/man /etc/manpath.config > /dev/null 2<&1 ; then @@ -1247,7 +1276,7 @@ fi cd ${_src_base_dir} echo "" -echononl "\tExtracting ${dovecot_pigeonhole_archiv}.." +echononl " Extracting ${dovecot_pigeonhole_archiv}.." gunzip < ${_src_base_dir}/${dovecot_pigeonhole_archiv} | tar -C ${_src_base_dir} -xf - if [ "$?" = 0 ]; then echo -e "$rc_done" @@ -1258,7 +1287,7 @@ fi cd ${dovecot_pigeonhole_archiv_dir} -echononl "\tConfigure Pigeonhole ManageSieve.." +echononl " Configure Pigeonhole ManageSieve.." ./configure \ --prefix=/usr/local/dovecot-${_version} \ --with-dovecot=/usr/local/dovecot-${_version}/lib/dovecot > ${_log_dir}/${dovecot_pigeonhole_archiv_prefix}-configure.log 2<&1 @@ -1269,7 +1298,7 @@ else fatal Configuring Pigeonhole ManageSieve failed fi -echononl "\tCompile Pigeonhole ManageSieve.." +echononl " Compile Pigeonhole ManageSieve.." make > ${_log_dir}/${dovecot_pigeonhole_archiv_prefix}-make.log 2<&1 if [ "$?" = 0 ]; then echo -e "$rc_done" @@ -1278,7 +1307,7 @@ else fatal Compiling Pigeonhole ManageSieve failed fi -echononl "\tInstall Pigeonhole ManageSieve.." +echononl " Install Pigeonhole ManageSieve.." make install > ${_log_dir}/${dovecot_pigeonhole_archiv_prefix}-install.log 2<&1 if [ "$?" = 0 ]; then echo -e "$rc_done" @@ -1312,7 +1341,7 @@ if [[ ${dovecot_major_version} -eq 2 ]] && [[ ${dovecot_minor_version} -lt 4 ]] else echo -e "$rc_skipped" fi - + echononl "Backup main configuration file 'dovecot.conf'.." if [[ -f "/usr/local/dovecot-${_version}/etc/dovecot/dovecot.conf" ]] ; then @@ -1330,18 +1359,18 @@ fi blank_line -echo -e "\033[1mBase install of Dovecot and Pigeonhole ManageSieve finished\033[m.." - -blank_line - -echononl "Proceed 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" +#echo -e "\033[1mBase install of Dovecot and Pigeonhole ManageSieve finished\033[m.." +# +#blank_line +# +#echononl "Proceed 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" _failed=false @@ -1361,12 +1390,18 @@ if [[ $dovecot_major_version -gt 2 ]] \ # - state_dir = /run/dovecot # - # - listen = $ipv4 $ipv6 - # - + # - # - mail_home = /var/vmail/%{user | domain}/%{user | username} # - mail_path = ~/Maildir # - mail_driver = Maildir # - - # - shutdown_clients = no + # - shutdown_clients = no + # - + # - ssl_server { + # - ssl = yes + # - cert_file = /etc/dovecot/ssl/mailserver.crt + # - key_file = /etc/dovecot/ssl/mailserver.key + # - } # - _conf_file="/usr/local/dovecot-${_version}/etc/dovecot/dovecot.conf" @@ -1385,9 +1420,13 @@ if [[ $dovecot_major_version -gt 2 ]] \ _shutdown_clients="no" - echononl "\tAdjust file dovecot.conf.." + _cert_file="/etc/dovecot/ssl/mailserver.crt" + _key_file="/etc/dovecot/ssl/mailserver.key" + _ssl_server_block="ssl_server {\n ssl = yes\n cert_file = ${_cert_file}\n key_file = ${_key_file}\n}" -# # Delete all lines that begin with !include and also delete the following line + echononl " Adjust file dovecot.conf.." + +# # Delete all lines that begin with !include and also delete the following line # # if it is empty or contains only whitespace. # # # sed -i '/^!include/ { @@ -1396,8 +1435,8 @@ if [[ $dovecot_major_version -gt 2 ]] \ # /^!include.*/d # }' "${_conf_file}" || _failed=true - # Delete all lines beginning with !include, together with all comment lines - # directly preceding it (#...) - even several in a row, and also the line + # Delete all lines beginning with !include, together with all comment lines + # directly preceding it (#...) - even several in a row, and also the line # following it if it is empty or only contains whitespace. # awk ' @@ -1437,21 +1476,36 @@ if [[ $dovecot_major_version -gt 2 ]] \ sed -i "/^\s*protocols\s*{/,/^}/c\ ${_protocols_block}" ${_conf_file} || _failed=true else - echo -e "\n${_protocols_block}" >> "${_conf_file}" || _failed=true + cat <> "${_conf_file}" || _failed=true + +# Enable wanted protocols: +$(echo -e "${_protocols_block}") +EOF + #echo -e "\n${_protocols_block}" >> "${_conf_file}" || _failed=true fi if grep -qE '^\s*listen\s*=' "${_conf_file}"; then perl -i -n -p -e "s#^(\s*)\#?\ ?(listen\ ?=.*)#listen = ${_listen}#g" \ "${_conf_file}" || _failed=true else - echo -e "\nlisten = ${_listen}" >> "${_conf_file}" || _failed=true + cat <> "${_conf_file}" || _failed=true + +# Enable wanted protocols: +listen = ${_listen} +EOF + #echo -e "\nlisten = ${_listen}" >> "${_conf_file}" || _failed=true fi if grep -qE '^\s*base_dir\s*=' "${_conf_file}"; then perl -i -n -p -e "s#^(\s*)\#?\ ?(base_dir\ ?=.*)#base_dir = ${_base_dir}#g" \ "${_conf_file}" || _failed=true else - echo -e "\nbase_dir = ${_base_dir}" >> "${_conf_file}" || _failed=true + cat <> "${_conf_file}" || _failed=true + +# Base directory where to store runtime data. +base_dir = ${_base_dir} +EOF + #echo -e "\nbase_dir = ${_base_dir}" >> "${_conf_file}" || _failed=true fi if grep -qE '^\s*state_dir\s*=' "${_conf_file}"; then @@ -1486,10 +1540,30 @@ if [[ $dovecot_major_version -gt 2 ]] \ perl -i -n -p -e "s#^(\s*)\#?\ ?(shutdown_clients\ ?=.*)#shutdown_clients = ${_shutdown_clients}#g" \ "${_conf_file}" || _failed=true else - echo -e "\nshutdown_clients = ${_shutdown_clients}" >> "${_conf_file}" || _failed=true + cat <> "${_conf_file}" || _failed=true + +# 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 = ${_shutdown_clients} +EOF + #echo -e "\nshutdown_clients = ${_shutdown_clients}" >> "${_conf_file}" || _failed=true fi - cat <> "${_conf_file}" + if grep -qE '^\s*ssl_server\s*{' "${_conf_file}"; then + sed -i "/^\s*ssl_server\s*{/,/^}/c\ + ${_ssl_server_block}" ${_conf_file} || _failed=true + else + cat <> "${_conf_file}" || _failed=true + +# SSL/TLS Configuration +$(echo -e "${_ssl_server_block}") +EOF + fi + + + cat <> "${_conf_file}" || _failed=true # 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 @@ -1534,7 +1608,7 @@ else ## - expire = $db_driver:/usr/local/dovecot/etc/dovecot/sql-dict.conf.ext ## - } ## - - echononl "\tAdjust file dovecot.conf.." + echononl " Adjust file dovecot.conf.." if [[ -n "$ipv6" ]]; then perl -i.ORIG -n -p -e "s#^([ ]*)\#?\ ?(listen\ ?=.*)#\1\#\# \2\n\1listen = $ipv4 $ipv6#g" \ /usr/local/dovecot-${_version}/etc/dovecot/dovecot.conf || _failed=true @@ -1567,21 +1641,21 @@ fi blank_line -echononl "Proceed 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" +#echononl "Proceed 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" if $_new ; then if [ "$db_driver" = "pgsql" ]; then - echononl "\tCheck if database '$dbname' already exists.." + echononl " Check if database '$dbname' already exists.." count=`su - postgres -c "psql -q -A -t -l" 2> ${_log_dir}/error.log | grep -c -e "^$dbname"` if [ "$?" = 0 ]; then echo -e "$rc_done" @@ -1589,7 +1663,7 @@ if $_new ; then echo -e "$rc_failed" error "Checking existence of database '$dbname' failed!" - echononl "\tcontinue anyway [yes/no]: " + echononl " continue anyway [yes/no]: " read OK OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do @@ -1601,7 +1675,7 @@ if $_new ; then fi if [ $count -eq 0 ];then - echononl "\tCreate database user ${dbuser}.." + echononl " Create database user ${dbuser}.." echo "CREATE ROLE $dbuser WITH LOGIN NOCREATEDB NOCREATEROLE NOSUPERUSER ENCRYPTED PASSWORD '$dbpassword'" \ | su - postgres -c "psql" > /dev/null 2>&1 @@ -1612,7 +1686,7 @@ if $_new ; then fatal Creating database user $dbuser failed fi - echononl "\tCreate database ${dbname}.." + echononl " Create database ${dbname}.." su - postgres -c "createdb -E utf8 -O ${dbuser} $dbname" if [ "$?" = 0 ]; then @@ -1625,7 +1699,7 @@ if $_new ; then ## - Create table expires in database ${dbname} ## - - echononl "\tCreate table expires in database ${dbname}.." + echononl " Create table expires in database ${dbname}.." if $plugin_expire ; then cat << EOF | psql -U$dbuser $dbname > ${_log_dir}/error.log 2>&1 @@ -1643,7 +1717,7 @@ EOF echo -e "$rc_failed" error "$(cat ${_log_dir}/error.log)" - echononl "\tcontinue anyway [yes/no]: " + echononl " continue anyway [yes/no]: " read OK OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do @@ -1657,7 +1731,7 @@ EOF echo -e "$rc_skipped" fi - echononl "\tCreate function merge_expires() / trigger mergeexpires.." + echononl " Create function merge_expires() / trigger mergeexpires.." if $plugin_expire ; then cat << EOF | psql -U$dbuser $dbname > /dev/null 2>&1 CREATE LANGUAGE plpgsql; @@ -1684,7 +1758,7 @@ EOF echo -e "$rc_failed" error "$(cat ${_log_dir}/error.log)" - echononl "\tcontinue anyway [yes/no]: " + echononl " continue anyway [yes/no]: " read OK OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do @@ -1703,7 +1777,7 @@ EOF "SELECT SCHEMA_NAME FROM INFORMATION_SCHEMA.SCHEMATA WHERE SCHEMA_NAME = '$dbname'" 2>/dev/null \ | grep $_db_name > /dev/null 2>&1 ; then - echononl "\tCreate database ${dbname}.." + echononl " Create database ${dbname}.." mysql ${MYSQL_CREDENTIALS} -N -s -e \ "CREATE DATABASE IF NOT EXISTS $dbname CHARACTER SET utf8 COLLATE utf8_general_ci" > ${_log_dir}/error.log 2>&1 @@ -1713,7 +1787,7 @@ EOF echo -e "$rc_failed" error "$(cat ${_log_dir}/error.log)" - echononl "\tcontinue anyway [yes/no]: " + echononl " continue anyway [yes/no]: " read OK OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do @@ -1723,7 +1797,7 @@ EOF [[ $OK = "yes" ]] || fatal "Abbruch durch User" fi - echononl "\tCreate database user ${dbuser}.." + echononl " Create database user ${dbuser}.." mysql ${MYSQL_CREDENTIALS} -N -s -e \ "GRANT ALL ON ${dbname}.* TO '${dbuser}'@'localhost' IDENTIFIED BY '$dbpassword'" > ${_log_dir}/error.log 2>&1 @@ -1733,7 +1807,7 @@ EOF echo -e "$rc_failed" error "$(cat ${_log_dir}/error.log)" - echononl "\tcontinue anyway [yes/no]: " + echononl " continue anyway [yes/no]: " read OK OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do @@ -1743,7 +1817,7 @@ EOF [[ $OK = "yes" ]] || fatal "Abbruch durch User" fi - echononl "\tFlushing database privileges.." + echononl " Flushing database privileges.." mysql ${MYSQL_CREDENTIALS} -N -s -e "FLUSH PRIVILEGES" > ${_log_dir}/error.log 2>&1 if [ "$?" = 0 ]; then @@ -1752,7 +1826,7 @@ EOF echo -e "$rc_failed" error "$(cat ${_log_dir}/error.log)" - echononl "\tcontinue anyway [yes/no]: " + echononl " continue anyway [yes/no]: " read OK OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do @@ -1767,7 +1841,7 @@ EOF ## - Create table expires in database ${dbname} ## - - echononl "\tCreate table expires in database ${dbname}.." + echononl " Create table expires in database ${dbname}.." if $plugin_expire ; then cat << EOF | mysql -u$dbuser -p$dbpassword $dbname > /dev/null 2>&1 @@ -1793,7 +1867,7 @@ fi ## - create sql-dict.conf.ext file ## - -echononl "\tCreate file sql-dict.conf.ext with plugin 'expire'.." +echononl " Create file sql-dict.conf.ext with plugin 'expire'.." if $plugin_expire ; then if [ "$db_driver" = "pgsql" ]; then @@ -1853,7 +1927,7 @@ EOF ## - create sql-dict.conf.ext file ## - - echononl "\tCreate file sql-dict.conf.ext" + echononl " Create file sql-dict.conf.ext" cat </usr/local/dovecot-${_version}/etc/dovecot/sql-dict.conf.ext # CREATE TABLE expires ( # username varchar(100) not null, @@ -1886,153 +1960,177 @@ else fi -## - edit /usr/local/dovecot/etc/dovecot/conf.d/10-master.conf -## - -## - default_process_limit = 1024 -## - default_client_limit = 10240 -## - -## - default_vsz_limit = 512M -## - -## - !! Bemerkung !! -## - -## - Das Hochsetzen des default_client_limit Parameters auf einen Wert größer -## - als 1024 geht nur dann wenn auch die Anzahl der zulässigen "open files" -## - (default = 1024) geändert wird. -## - -## - -## - Systemd System: -## - =============== -## - -## - In der service datei (z.Bsp. /etc/systemd/system/multi-user.target.wants/dovecot.service) -## - den Wert 'LimitNOFILE' hochsetzen: -## - -## - LimitNOFILE=32768 (must be greater or equal of 'default_client_limit') -## - -## - systemctl daemon-reload -## - systemctl restart dovecot.service -## - -## - Im Falle von LX containern muss zusätzlich auf dem hostsystem -## - in der datei '/etc/systemd/system.conf' der Wert für 'DefaultLimitNOFILE' -## - hochgesetzt werden. -## - -## - System V systems: -## - ================= -## - Das Hochsetzen des default_client_limit Parameters auf einen Wert größer -## - als 1024 geht nur dann wenn auch die Anzahl der zulässigen "open files" -## - (default = 1024) geändert wird. Z.Bsp. in der Datei /etc/init.d/dovecot -## - durch Einfügen der zeile: -## - ulimit -n 32768 -## - -## - Linux VServer: -## - put the following lines into /etc/security/limits.conf -## - -## - @staff hard nofile 32768 -## - root hard nofile 32768 -## - -## - !! Mybe you have also create file /etc/vservers/*/ulimits/nofiles.hard -## - with the same contents: -## - -## - @staff hard nofile 32768 -## - @adm hard nofile 32768 -## - root hard nofile 32768 -## - -## - see also http://linux-vserver.org/Ulimit_Nofiles -## - -## - -## - -## - service auth { -## - -## - # Auth Listener (XMPP - Jabber) -## - inet_listener { -## - address = $xmpp_listener_addresses -## - port = $xmpp_listener_port -## - } -## - .. -## - unix_listener auth-userdb { -## - mode = 0666 -## - user = dovecot -## - group = dovecot -## - } -## - .. -## - unix_listener /var/spool/postfix/private/dovecot-auth { -## - mode = 0666 -## - user = postfix -## - group = postfix -## - } -## - .. -## - } -## - -## - service imap-login { -## - inet_listener imap { -## - address = $imap_listener_adresses -## - .. -## - } -## - inet_listener imaps { -## - address = $imaps_listener_adresses -## - .. -## - } -## - -## - process_min_avail = 16 -## - } -## - -## - service pop3-login { -## - inet_listener pop3 { -## - address = $pop_listener_adresses -## - .. -## - } -## - inet_listener pop3s { -## - address = $pops_listener_adresses -## - .. -## - } -## - } -## - -_failed=false -echononl "\tAdjusting file 10-master.conf.." -perl -i.ORIG -n -p -e "s#^([ ]*)(unix_listener\ +auth-userdb.*)#\1\2\n\1 mode = 0666\n\1 user = dovecot\n\1 group = dovecot#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-master.conf || _failed=true -perl -i -n -p -e "s#^([ ]*)(\#.*Postfix.*smtp-auth.*)#\1\2\n\1unix_listener /var/spool/postfix/private/dovecot-auth {\n\1 mode = 0666\n\1 user = postfix\n\1 group = postfix\n\1}#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-master.conf || _failed=true -perl -i -n -p -e "s#^([ ]*)(inet_listener\ +imap\ .*)#\1\2\n\1 address = $imap_listener_adresses#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-master.conf || _failed=true -perl -i -n -p -e "s#^([ ]*)(inet_listener\ +imaps.*)#\1\2\n\1 address = $imaps_listener_adresses#g#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-master.conf || _failed=true -perl -i -n -p -e "s#^([ ]*)(\#?process_min_avail\ ?=.*)#\1\#\# \2\n\1process_min_avail = 16#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-master.conf || _failed=true -perl -i -n -p -e "s#^([ ]*)(inet_listener\ +pop3\ .*)#\1\2\n\1 address = $pop_listener_adresses#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-master.conf || _failed=true -perl -i -n -p -e "s#^([ ]*)(inet_listener\ +pop3s.*)#\1\2\n\1 address = $pops_listener_adresses#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-master.conf || _failed=true +# edit /usr/local/dovecot/etc/dovecot/conf.d/10-master.conf +# +if [[ $dovecot_major_version -gt 2 ]] \ + || ( [[ $dovecot_major_version -eq 2 ]] && [[ $dovecot_minor_version -gt 3 ]] ); then -if $xmpp_listener ; then - perl -i -n -p -e "s#^([ ]*)(service auth\s+\{.*)#\1\2\n\n \# Auth Listener (XMPP - Jabber)\n inet_listener {\n address = $xmpp_listener_addresses\n port = $xmpp_listener_port\n }\n#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-master.conf || _failed=true -fi + if [[ ! -f "/usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-master.conf" ]] ; then + _failed=false + echononl " Create empty file '10-master.conf'.." + touch /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-master.conf > ${log_file} + if [ "$?" = 0 ]; then + echo -e "$rc_done" + else + echo -e "$rc_failed" + error "Creating empty file '/usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-master.conf' failed!" + fi + fi -## - setting default prozcess/client limit -## - -perl -i -n -p -e "s#^([ ]*\#?[ ]*)(default_process_limit.*)#\1\2\ndefault_process_limit = 1024#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-master.conf || _failed=true -perl -i -n -p -e "s#^([ ]*\#?[ ]*)(default_client_limit.*)#\1\2\ndefault_client_limit = 10240#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-master.conf || _failed=true + echononl " Adjusting file 10-master.conf.." + echo -e "$rc_not_yet_implemented" -perl -i -n -p -e "s#^([ ]*\#?[ ]*)(default_vsz_limit.*)#\1\2\ndefault_vsz_limit = 512M#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-master.conf || _failed=true - -if ! $_failed ; then - echo -e "$rc_done" else - echo -e "$rc_failed" - fatal "Adjusting file /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-master.conf failed" -fi + + ## - edit /usr/local/dovecot/etc/dovecot/conf.d/10-master.conf + ## - + ## - default_process_limit = 1024 + ## - default_client_limit = 10240 + ## - + ## - default_vsz_limit = 512M + ## - + ## - !! Bemerkung !! + ## - + ## - Das Hochsetzen des default_client_limit Parameters auf einen Wert größer + ## - als 1024 geht nur dann wenn auch die Anzahl der zulässigen "open files" + ## - (default = 1024) geändert wird. + ## - + ## - + ## - Systemd System: + ## - =============== + ## - + ## - In der service datei (z.Bsp. /etc/systemd/system/multi-user.target.wants/dovecot.service) + ## - den Wert 'LimitNOFILE' hochsetzen: + ## - + ## - LimitNOFILE=32768 (must be greater or equal of 'default_client_limit') + ## - + ## - systemctl daemon-reload + ## - systemctl restart dovecot.service + ## - + ## - Im Falle von LX containern muss zusätzlich auf dem hostsystem + ## - in der datei '/etc/systemd/system.conf' der Wert für 'DefaultLimitNOFILE' + ## - hochgesetzt werden. + ## - + ## - System V systems: + ## - ================= + ## - Das Hochsetzen des default_client_limit Parameters auf einen Wert größer + ## - als 1024 geht nur dann wenn auch die Anzahl der zulässigen "open files" + ## - (default = 1024) geändert wird. Z.Bsp. in der Datei /etc/init.d/dovecot + ## - durch Einfügen der zeile: + ## - ulimit -n 32768 + ## - + ## - Linux VServer: + ## - put the following lines into /etc/security/limits.conf + ## - + ## - @staff hard nofile 32768 + ## - root hard nofile 32768 + ## - + ## - !! Mybe you have also create file /etc/vservers/*/ulimits/nofiles.hard + ## - with the same contents: + ## - + ## - @staff hard nofile 32768 + ## - @adm hard nofile 32768 + ## - root hard nofile 32768 + ## - + ## - see also http://linux-vserver.org/Ulimit_Nofiles + ## - + ## - + ## - + ## - service auth { + ## - + ## - # Auth Listener (XMPP - Jabber) + ## - inet_listener { + ## - address = $xmpp_listener_addresses + ## - port = $xmpp_listener_port + ## - } + ## - .. + ## - unix_listener auth-userdb { + ## - mode = 0666 + ## - user = dovecot + ## - group = dovecot + ## - } + ## - .. + ## - unix_listener /var/spool/postfix/private/dovecot-auth { + ## - mode = 0666 + ## - user = postfix + ## - group = postfix + ## - } + ## - .. + ## - } + ## - + ## - service imap-login { + ## - inet_listener imap { + ## - address = $imap_listener_adresses + ## - .. + ## - } + ## - inet_listener imaps { + ## - address = $imaps_listener_adresses + ## - .. + ## - } + ## - + ## - process_min_avail = 16 + ## - } + ## - + ## - service pop3-login { + ## - inet_listener pop3 { + ## - address = $pop_listener_adresses + ## - .. + ## - } + ## - inet_listener pop3s { + ## - address = $pops_listener_adresses + ## - .. + ## - } + ## - } + ## - + _failed=false + echononl " Adjusting file 10-master.conf.." + perl -i.ORIG -n -p -e "s#^([ ]*)(unix_listener\ +auth-userdb.*)#\1\2\n\1 mode = 0666\n\1 user = dovecot\n\1 group = dovecot#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-master.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)(\#.*Postfix.*smtp-auth.*)#\1\2\n\1unix_listener /var/spool/postfix/private/dovecot-auth {\n\1 mode = 0666\n\1 user = postfix\n\1 group = postfix\n\1}#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-master.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)(inet_listener\ +imap\ .*)#\1\2\n\1 address = $imap_listener_adresses#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-master.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)(inet_listener\ +imaps.*)#\1\2\n\1 address = $imaps_listener_adresses#g#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-master.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)(\#?process_min_avail\ ?=.*)#\1\#\# \2\n\1process_min_avail = 16#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-master.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)(inet_listener\ +pop3\ .*)#\1\2\n\1 address = $pop_listener_adresses#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-master.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)(inet_listener\ +pop3s.*)#\1\2\n\1 address = $pops_listener_adresses#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-master.conf || _failed=true + + if $xmpp_listener ; then + perl -i -n -p -e "s#^([ ]*)(service auth\s+\{.*)#\1\2\n\n \# Auth Listener (XMPP - Jabber)\n inet_listener {\n address = $xmpp_listener_addresses\n port = $xmpp_listener_port\n }\n#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-master.conf || _failed=true + fi + + ## - setting default prozcess/client limit + ## - + perl -i -n -p -e "s#^([ ]*\#?[ ]*)(default_process_limit.*)#\1\2\ndefault_process_limit = 1024#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-master.conf || _failed=true + perl -i -n -p -e "s#^([ ]*\#?[ ]*)(default_client_limit.*)#\1\2\ndefault_client_limit = 10240#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-master.conf || _failed=true + + perl -i -n -p -e "s#^([ ]*\#?[ ]*)(default_vsz_limit.*)#\1\2\ndefault_vsz_limit = 512M#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-master.conf || _failed=true + + if ! $_failed ; then + echo -e "$rc_done" + else + echo -e "$rc_failed" + fatal "Adjusting file /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-master.conf failed" + fi + +fi # edit /usr/local/dovecot/etc/dovecot/conf.d/10-master.conf blank_line -echononl "\tCreate Cert/Key Directory '$cert_base_dir'.." +echononl " Create Cert/Key Directory '$cert_base_dir'.." if [[ ! -d "$cert_base_dir" ]] ; then mkdir -p "$cert_base_dir" > $log_file 2>&1 if [[ $? -eq 0 ]] ; then echo -e "$rc_done" - echononl "\tChange Permissions for Cert/Key Directory '$cert_base_dir'.." + echononl " Change Permissions for Cert/Key Directory '$cert_base_dir'.." chmod 755 "$cert_base_dir" > $log_file 2>&1 if [[ $? -eq 0 ]] ; then echo -e "$rc_done" @@ -2058,7 +2156,7 @@ if [[ $dovecot_major_version -ge 3 ]] \ || ( [[ $dovecot_major_version -eq 2 ]] && [[ $dovecot_minor_version -ge 3 ]] ); then if [[ ! -f "$dh_pem_file" ]] ; then - echononl "\tCreate SSL DH parameters '$dh_pem_file'.." + echononl " Create SSL DH parameters '$dh_pem_file'.." echo -en "$rc_wait" if [[ "$os_dist" = "debian" ]] && [[ $os_version -gt 11 ]] ; then openssl dhparam -out "$dh_pem_file" 4096 > /dev/null 2>&1 @@ -2075,152 +2173,174 @@ if [[ $dovecot_major_version -ge 3 ]] \ fi +# edit /usr/local/dovecot/etc/dovecot/conf.d/10-ssl.conf +# +if [[ $dovecot_major_version -gt 2 ]] \ + || ( [[ $dovecot_major_version -eq 2 ]] && [[ $dovecot_minor_version -gt 3 ]] ); then -## - edit /usr/local/dovecot/etc/dovecot/conf.d/10-ssl.conf -## - -## - ssl = required -## - -## - ssl_cert = <$server_cert -## - ssl_key = <$server_key -## - -## - # - 'ssl_dh_parameters_length' is obsolete and no longer needed -## - #ssl_dh_parameters_length = 2048 -## - -## - # - 'ssl_protocols has been' replaced by ssl_min_protocol -## - #ssl_protocols = !SSLv3 -## - ssl_min_protocol = TLSv1.2 -## - -## - ssl_cipher_list = ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA -## - -## - ssl_prefer_server_ciphers = yes -## - -## - -## - there are another possibilities to handle certs, but this did'nt work -## - as i expected.. -## - #local_name imap.warenform.de { -## - # ssl_cert = <$imap_cert -## - # ssl_key = <$imap_key -## - #} -## - #local_name pop.warenform.de { -## - # ssl_cert = <$pop_cert -## - # ssl_key = <$pop_key -## - #} -## - -_failed=false -echononl "\tAdjusting file 10-ssl.conf.." -perl -i.ORIG -n -p -e "s#^(\s*\#*\s*)(ssl\ ?=.*)#\#\1\2\nssl = required#" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-ssl.conf || _failed=true -perl -i -n -p -e "s#^([ ]*)(ssl_cert\ ?=.*)#\1\#\# \2\n\1ssl_cert = <$server_cert#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-ssl.conf || _failed=true -perl -i -n -p -e "s#^([ ]*)(ssl_key\ ?=.*)#\1\#\# \2\n\1ssl_key = <$server_key#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-ssl.conf || _failed=true + echononl " Adjusting file 10-ssl.conf.." + echo -e "$rc_not_yet_implemented" -if [[ $dovecot_major_version -ge 3 ]] \ - || ( [[ $dovecot_major_version -eq 2 ]] && [[ $dovecot_minor_version -ge 3 ]] ); then - if [[ ! -f "$dh_pem_file" ]]; then - if [[ -f "/etc/postfix/ssl/dh_2048.pem" ]]; then - dh_pem_file="/etc/postfix/ssl/dh_2048.pem" - fi - fi - if [[ -f "$dh_pem_file" ]]; then - perl -i -n -p -e "s#^(\s*\#*)(ssl_dh\s*=.*)#\#\1\2\nssl_dh = <$dh_pem_file#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-ssl.conf || _failed=true - else - _failed=true - fi else - perl -i -n -p -e "s#^([ ]*)\#?(ssl_dh_parameters_length\ ?=.*)#\1\#\# \2\nssl_dh_parameters_length = 2048#g" \ + ## - edit /usr/local/dovecot/etc/dovecot/conf.d/10-ssl.conf + ## - + ## - ssl = required + ## - + ## - ssl_cert = <$server_cert + ## - ssl_key = <$server_key + ## - + ## - # - 'ssl_dh_parameters_length' is obsolete and no longer needed + ## - #ssl_dh_parameters_length = 2048 + ## - + ## - # - 'ssl_protocols has been' replaced by ssl_min_protocol + ## - #ssl_protocols = !SSLv3 + ## - ssl_min_protocol = TLSv1.2 + ## - + ## - ssl_cipher_list = ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA + ## - + ## - ssl_prefer_server_ciphers = yes + ## - + ## - + ## - there are another possibilities to handle certs, but this did'nt work + ## - as i expected.. + ## - #local_name imap.warenform.de { + ## - # ssl_cert = <$imap_cert + ## - # ssl_key = <$imap_key + ## - #} + ## - #local_name pop.warenform.de { + ## - # ssl_cert = <$pop_cert + ## - # ssl_key = <$pop_key + ## - #} + ## - + _failed=false + echononl " Adjusting file 10-ssl.conf.." + perl -i.ORIG -n -p -e "s#^(\s*\#*\s*)(ssl\ ?=.*)#\#\1\2\nssl = required#" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-ssl.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)(ssl_cert\ ?=.*)#\1\#\# \2\n\1ssl_cert = <$server_cert#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-ssl.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)(ssl_key\ ?=.*)#\1\#\# \2\n\1ssl_key = <$server_key#g" \ /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-ssl.conf || _failed=true -fi -perl -i -n -p -e "s#^([ ]*)\#?(ssl_min_protocol\ ?=.*)#\1\#\# \2\nssl_min_protocol = TLSv1.2#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-ssl.conf || _failed=true + if [[ $dovecot_major_version -ge 3 ]] \ + || ( [[ $dovecot_major_version -eq 2 ]] && [[ $dovecot_minor_version -ge 3 ]] ); then + if [[ ! -f "$dh_pem_file" ]]; then + if [[ -f "/etc/postfix/ssl/dh_2048.pem" ]]; then + dh_pem_file="/etc/postfix/ssl/dh_2048.pem" + fi + fi + if [[ -f "$dh_pem_file" ]]; then + perl -i -n -p -e "s#^(\s*\#*)(ssl_dh\s*=.*)#\#\1\2\nssl_dh = <$dh_pem_file#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-ssl.conf || _failed=true + else + _failed=true + fi + else + perl -i -n -p -e "s#^([ ]*)\#?(ssl_dh_parameters_length\ ?=.*)#\1\#\# \2\nssl_dh_parameters_length = 2048#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-ssl.conf || _failed=true + fi -# - Replace only the first occurence of the match -# - -# - Example: -# - # Replace first occurence of 'width: .*' in file 'filename.css' -# - -# - perl -pi -e '$a=1 if(!$a && s/(width:).*;/$1 100%;/);' filename.css -# - -perl -i -n -p -e '$a=1 if(!$a && s#^([ ]*)\#?(ssl_cipher_list\ ?=.*)#\1\#\# \2\nssl_cipher_list = ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA#);' \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-ssl.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)\#?(ssl_min_protocol\ ?=.*)#\1\#\# \2\nssl_min_protocol = TLSv1.2#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-ssl.conf || _failed=true + + # - Replace only the first occurence of the match + # - + # - Example: + # - # Replace first occurence of 'width: .*' in file 'filename.css' + # - + # - perl -pi -e '$a=1 if(!$a && s/(width:).*;/$1 100%;/);' filename.css + # - + perl -i -n -p -e '$a=1 if(!$a && s#^([ ]*)\#?(ssl_cipher_list\ ?=.*)#\1\#\# \2\nssl_cipher_list = ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-AES256-GCM-SHA384:DHE-RSA-AES128-GCM-SHA256:DHE-DSS-AES128-GCM-SHA256:kEDH+AESGCM:ECDHE-RSA-AES128-SHA256:ECDHE-ECDSA-AES128-SHA256:ECDHE-RSA-AES128-SHA:ECDHE-ECDSA-AES128-SHA:ECDHE-RSA-AES256-SHA384:ECDHE-ECDSA-AES256-SHA384:ECDHE-RSA-AES256-SHA:ECDHE-ECDSA-AES256-SHA:DHE-RSA-AES128-SHA256:DHE-RSA-AES128-SHA:DHE-DSS-AES128-SHA256:DHE-RSA-AES256-SHA256:DHE-DSS-AES256-SHA:DHE-RSA-AES256-SHA:AES128-GCM-SHA256:AES256-GCM-SHA384:AES128-SHA256:AES256-SHA256:AES128-SHA:AES256-SHA:AES:CAMELLIA:DES-CBC3-SHA:!aNULL:!eNULL:!EXPORT:!DES:!RC4:!MD5:!PSK:!aECDH:!EDH-DSS-DES-CBC3-SHA:!EDH-RSA-DES-CBC3-SHA:!KRB5-DES-CBC3-SHA#);' \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-ssl.conf || _failed=true -perl -i -n -p -e "s#^([ ]*)\#?(ssl_prefer_server_ciphers\ ?=.*)#\1\#\# \2\nssl_prefer_server_ciphers = yes#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-ssl.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)\#?(ssl_prefer_server_ciphers\ ?=.*)#\1\#\# \2\nssl_prefer_server_ciphers = yes#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-ssl.conf || _failed=true + + if ! $_failed ; then + echo -e "$rc_done" + else + echo -e "$rc_failed" + fatal "Adjusting file 10-ssl.conf failed" + fi + +fi # edit /usr/local/dovecot/etc/dovecot/conf.d/10-ssl.conf + + +# edit /usr/local/dovecot/etc/dovecot/conf.d/10-mail.conf +# +if [[ $dovecot_major_version -gt 2 ]] \ + || ( [[ $dovecot_major_version -eq 2 ]] && [[ $dovecot_minor_version -gt 3 ]] ); then + + echononl " Adjusting file 10-mail.conf.." + echo -e "$rc_not_yet_implemented" -if ! $_failed ; then - echo -e "$rc_done" else - echo -e "$rc_failed" - fatal "Adjusting file 10-ssl.conf failed" -fi - -## - edit /usr/local/dovecot/etc/dovecot/conf.d/10-mail.conf -## - -## - mail_location = maildir:/var/vmail/%d/%n/Maildir -## - -## - mail_uid = vmail -## - mail_gid = vmail -## - -## - first_valid_uid = 5000 -## - last_valid_uid = 5000 -## - -## - mail_temp_dir = /var/vmail/tmp -## - -## - first_valid_gid = 5000 -## - last_valid_gid = 5000 -## - -## - auth_socket_path = /run/dovecot/auth-userdb -## - mail_plugins = quota | mail_plugins = quota expire -## - -## - mailbox_list_index = yes -## - -_failed=false -echononl "\tAdjusting file 10-mail.conf" -perl -i.ORIG -n -p -e "s#^([ ]*)\#?\ ?(mail_location\ +=.*)#\1\#\# \2\n\1mail_location = maildir:/var/vmail/%d/%n/Maildir#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf || _failed=true -perl -i -n -p -e "s#^([ ]*)\#?\ ?(mail_uid.*)#\1\#\# \2\n\1mail_uid = vmail#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf || _failed=true -perl -i -n -p -e "s#^([ ]*)\#?\ ?(mail_gid.*)#\1\#\# \2\n\1mail_gid = vmail#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf || _failed=true -perl -i -n -p -e "s#^([ ]*)\#?\ ?(mail_temp_dir.*)#\1\#\# \2\n\1mail_temp_dir = /var/vmail/tmp#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf || _failed=true -perl -i -n -p -e "s#^([ ]*)\#?\ ?(first_valid_uid.*)#\1\#\# \2\n\1first_valid_uid = 5000#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf || _failed=true -perl -i -n -p -e "s#^([ ]*)\#?\ ?(last_valid_uid.*)#\1\#\# \2\n\1last_valid_uid = 5000#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf || _failed=true -perl -i -n -p -e "s#^([ ]*)\#?\ ?(first_valid_gid.*)#\1\#\# \2\n\1first_valid_gid = 5000#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf || _failed=true -perl -i -n -p -e "s#^([ ]*)\#?\ ?(last_valid_gid.*)#\1\#\# \2\n\1last_valid_gid = 5000#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf || _failed=true -perl -i -n -p -e "s#^([ ]*)\#?\ ?(auth_socket_path\ +=.*)#\1\#\# \2\n\1auth_socket_path = /run/dovecot/auth-userdb#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf || _failed=true - -if $plugin_expire ; then - perl -i -n -p -e "s#^([ ]*)\#?\ ?(mail_plugins\ +=.*)#\1\#\# \2\n\1mail_plugins = quota expire#g" \ + ## - edit /usr/local/dovecot/etc/dovecot/conf.d/10-mail.conf + ## - + ## - mail_location = maildir:/var/vmail/%d/%n/Maildir + ## - + ## - mail_uid = vmail + ## - mail_gid = vmail + ## - + ## - first_valid_uid = 5000 + ## - last_valid_uid = 5000 + ## - + ## - mail_temp_dir = /var/vmail/tmp + ## - + ## - first_valid_gid = 5000 + ## - last_valid_gid = 5000 + ## - + ## - auth_socket_path = /run/dovecot/auth-userdb + ## - mail_plugins = quota | mail_plugins = quota expire + ## - + ## - mailbox_list_index = yes + ## - + _failed=false + echononl " Adjusting file 10-mail.conf" + perl -i.ORIG -n -p -e "s#^([ ]*)\#?\ ?(mail_location\ +=.*)#\1\#\# \2\n\1mail_location = maildir:/var/vmail/%d/%n/Maildir#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)\#?\ ?(mail_uid.*)#\1\#\# \2\n\1mail_uid = vmail#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)\#?\ ?(mail_gid.*)#\1\#\# \2\n\1mail_gid = vmail#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)\#?\ ?(mail_temp_dir.*)#\1\#\# \2\n\1mail_temp_dir = /var/vmail/tmp#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)\#?\ ?(first_valid_uid.*)#\1\#\# \2\n\1first_valid_uid = 5000#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)\#?\ ?(last_valid_uid.*)#\1\#\# \2\n\1last_valid_uid = 5000#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)\#?\ ?(first_valid_gid.*)#\1\#\# \2\n\1first_valid_gid = 5000#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)\#?\ ?(last_valid_gid.*)#\1\#\# \2\n\1last_valid_gid = 5000#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)\#?\ ?(auth_socket_path\ +=.*)#\1\#\# \2\n\1auth_socket_path = /run/dovecot/auth-userdb#g" \ /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf || _failed=true -else - perl -i -n -p -e "s#^([ ]*)\#?\ ?(mail_plugins\ +=.*)#\1\#\# \2\n\1mail_plugins = quota#g" \ + if $plugin_expire ; then + perl -i -n -p -e "s#^([ ]*)\#?\ ?(mail_plugins\ +=.*)#\1\#\# \2\n\1mail_plugins = quota expire#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf || _failed=true + + else + perl -i -n -p -e "s#^([ ]*)\#?\ ?(mail_plugins\ +=.*)#\1\#\# \2\n\1mail_plugins = quota#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf || _failed=true + fi + + perl -i -n -p -e "s#^([ ]*)\#?\ ?(mailbox_list_index\s*=.*)#\1\#\# \2\n\1mailbox_list_index = yes#g" \ /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf || _failed=true -fi -perl -i -n -p -e "s#^([ ]*)\#?\ ?(mailbox_list_index\s*=.*)#\1\#\# \2\n\1mailbox_list_index = yes#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf || _failed=true + if ! $_failed ; then + echo -e "$rc_done" + else + echo -e "$rc_failed" + fatal "Adjusting file '10-mail.conf' failed" + fi -if ! $_failed ; then - echo -e "$rc_done" -else - echo -e "$rc_failed" - fatal "Adjusting file '10-mail.conf' failed" -fi +fi # edit /usr/local/dovecot/etc/dovecot/conf.d/10-mail.conf -echononl "\tCreate TEMP directory '/var/vmail/tmp' .." +echononl " Create TEMP directory '/var/vmail/tmp' .." if [[ ! -d /var/vmail/tmp ]] ; then mkdir /var/vmail/tmp > /dev/null 2>&1 if [[ $? -eq 0 ]]; then @@ -2233,7 +2353,7 @@ else echo -e "$rc_skipped" fi -echononl "\tChange ownerchip of directory '/var/vmail/tmp' .." +echononl " Change ownerchip of directory '/var/vmail/tmp' .." chown vmail:vmail /var/vmail/tmp > /dev/null 2>&1 if [[ $? -eq 0 ]]; then echo -e "$rc_done" @@ -2242,270 +2362,335 @@ else error "Changing ownerchip of directory '/var/vmail/tmp' failed." fi -## - edit /usr/local/dovecot/etc/dovecot/conf.d/10-mail.conf -## - -## - comment out namespace section "namespace inbox". we will create namespaces later. -## - in detail, tha means comment out 3 lines: -## - namespace inbox { -## - .. -## - inbox = yes -## - .. -## - } -## - -_failed=false -_found=false -_tmp_file="$(mktemp)" -> $_tmp_file -while IFS='' read -r _line || [[ -n $_line ]] ; do +blank_line - if echo "$_line" | grep -i -E "^\s*namespace\s+inbox\s+" > /dev/null 2>&1 ; then - echo "## $_line" >> $_tmp_file - _found=true - continue - fi +# modify /usr/local/dovecot/etc/dovecot/conf.d/10-mail.conf +# +# +if [[ $dovecot_major_version -gt 2 ]] \ + || ( [[ $dovecot_major_version -eq 2 ]] && [[ $dovecot_minor_version -gt 3 ]] ); then - if $_found && echo "$_line" | grep -i -E "^\s*}" > /dev/null 2>&1 ; then - echo "## $_line" >> $_tmp_file - _found=false - continue - fi + echononl " Modify file '10-mail.conf'.." + echo -e "$rc_not_yet_implemented" - if $_found ; then - echo "## $_line" >> $_tmp_file - else - echo "$_line" >> $_tmp_file - fi -done < "/usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf" -if [[ "$?" != "0" ]] ; then - _failed=true -fi -mv /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf.TMP -if [[ "$?" != "0" ]] ; then - _failed=true -fi -mv $_tmp_file /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf -if [[ "$?" != "0" ]] ; then - _failed=true -fi -chmod 644 /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf -if [[ "$?" != "0" ]] ; then - _failed=true -fi - - -#perl -i -n -p -e "s#^([ ]*)(namespace\ +inbox\ +{\ *)#\1\#\#\ \2#g" \ -# /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf || _failed=true -#perl -i -n -p -e "s#^([ ]*)(inbox\ +=\ +yes\ *)#\1\#\#\ \2#g" \ -# /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf || _failed=true -#perl -i -n -p -e "s#^([ ]*)(}\ *)#\1\#\#\ \2#g" \ -# /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf || _failed=true - -if ! $_failed ; then - echo -e "$rc_done" else - echo -e "$rc_failed" - fatal "Adjusting file /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf failed" -fi -## - edit /usr/local/dovecot/etc/dovecot/conf.d/10-mail.conf -## - -## - Add namespaces type private -## - -## - Add: -## - namespace inbox { -## - type = private -## - separator = / -## - prefix = -## - inbox = yes -## - } -## - -echononl "\tAdd namespaces type private to file 10-mail.conf" -cat <> /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf + echononl " Modify file '10-mail.conf'.." + + ## - edit /usr/local/dovecot/etc/dovecot/conf.d/10-mail.conf + ## - + ## - comment out namespace section "namespace inbox". we will create namespaces later. + ## - in detail, tha means comment out 3 lines: + ## - namespace inbox { + ## - .. + ## - inbox = yes + ## - .. + ## - } + ## - + _failed=false + _found=false + _tmp_file="$(mktemp)" + > $_tmp_file + while IFS='' read -r _line || [[ -n $_line ]] ; do + + if echo "$_line" | grep -i -E "^\s*namespace\s+inbox\s+" > /dev/null 2>&1 ; then + echo "## $_line" >> $_tmp_file + _found=true + continue + fi + + if $_found && echo "$_line" | grep -i -E "^\s*}" > /dev/null 2>&1 ; then + echo "## $_line" >> $_tmp_file + _found=false + continue + fi + + if $_found ; then + echo "## $_line" >> $_tmp_file + else + echo "$_line" >> $_tmp_file + fi + done < "/usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf" + if [[ "$?" != "0" ]] ; then + _failed=true + fi + mv /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf.TMP + if [[ "$?" != "0" ]] ; then + _failed=true + fi + mv $_tmp_file /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf + if [[ "$?" != "0" ]] ; then + _failed=true + fi + chmod 644 /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf + if [[ "$?" != "0" ]] ; then + _failed=true + fi + + + #perl -i -n -p -e "s#^([ ]*)(namespace\ +inbox\ +{\ *)#\1\#\#\ \2#g" \ + # /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf || _failed=true + #perl -i -n -p -e "s#^([ ]*)(inbox\ +=\ +yes\ *)#\1\#\#\ \2#g" \ + # /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf || _failed=true + #perl -i -n -p -e "s#^([ ]*)(}\ *)#\1\#\#\ \2#g" \ + # /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf || _failed=true + + if ! $_failed ; then + echo -e "$rc_done" + else + echo -e "$rc_failed" + fatal "Adjusting file /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf failed" + fi + + + ## - edit /usr/local/dovecot/etc/dovecot/conf.d/10-mail.conf + ## - + ## - Add namespaces type private + ## - + ## - Add: + ## - namespace inbox { + ## - type = private + ## - separator = / + ## - prefix = + ## - inbox = yes + ## - } + ## - + echononl " Add namespaces type private to file 10-mail.conf" + cat <> /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf ## - Namespaces ## - namespace inbox { - # Namespace type: private, shared or public - type = private +# Namespace type: private, shared or public +type = private - # Hierarchy separator to use. You should use the same separator for all - # namespaces or some clients get confused. '/' is usually a good one. - # The default however depends on the underlying mail storage format. - #separator = - separator = / +# Hierarchy separator to use. You should use the same separator for all +# namespaces or some clients get confused. '/' is usually a good one. +# The default however depends on the underlying mail storage format. +#separator = +separator = / - # Prefix required to access this namespace. This needs to be different for - # all namespaces. For example "Public/". - #prefix = - prefix = +# Prefix required to access this namespace. This needs to be different for +# all namespaces. For example "Public/". +#prefix = +prefix = - # Physical location of the mailbox. This is in same format as - # mail_location, which is also the default for it. - #location = +# Physical location of the mailbox. This is in same format as +# mail_location, which is also the default for it. +#location = - # There can be only one INBOX, and this setting defines which namespace - # has it. - #inbox = no - inbox = yes +# There can be only one INBOX, and this setting defines which namespace +# has it. +#inbox = no +inbox = yes - # If namespace is hidden, it's not advertised to clients via NAMESPACE - # extension. You'll most likely also want to set list=no. This is mostly - # useful when converting from another server with different namespaces which - # you want to deprecate but still keep working. For example you can create - # hidden namespaces with prefixes "~/mail/", "~%u/mail/" and "mail/". - #hidden = no +# If namespace is hidden, it's not advertised to clients via NAMESPACE +# extension. You'll most likely also want to set list=no. This is mostly +# useful when converting from another server with different namespaces which +# you want to deprecate but still keep working. For example you can create +# hidden namespaces with prefixes "~/mail/", "~%u/mail/" and "mail/". +#hidden = no - # Show the mailboxes under this namespace with LIST command. This makes the - # namespace visible for clients that don't support NAMESPACE extension. - # "children" value lists child mailboxes, but hides the namespace prefix. - #list = yes +# Show the mailboxes under this namespace with LIST command. This makes the +# namespace visible for clients that don't support NAMESPACE extension. +# "children" value lists child mailboxes, but hides the namespace prefix. +#list = yes - # Namespace handles its own subscriptions. If set to "no", the parent - # namespace handles them (empty prefix should always have this as "yes") - #subscriptions = yes +# Namespace handles its own subscriptions. If set to "no", the parent +# namespace handles them (empty prefix should always have this as "yes") +#subscriptions = yes } EOF -if [ "$?" = 0 ]; then - echo -e "$rc_done" -else - echo -e "$rc_failed" - fatal "Adjusting file /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf failed" -fi + if [ "$?" = 0 ]; then + echo -e "$rc_done" + else + echo -e "$rc_failed" + fatal "Adjusting file /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf failed" + fi + +fi # modify /usr/local/dovecot/etc/dovecot/conf.d/10-mail.conf -## - edit /usr/local/dovecot/etc/dovecot/conf.d/15-mailboxes.conf -## - -## - Add definitions for mailbox Spam: -## - -## - mailbox Drafts { -## - auto = subscribe -## - special_use = \Drafts -## - } -## - -## - mailbox Trash { -## - auto = subscribe -## - special_use = \Trash -## - } -## - -## - mailbox Sent { -## - auto = subscribe -## - special_use = \Sent -## - } -## - -## - mailbox $spam_folder { -## - auto = subscribe -## - special_use = \Junk -## - } -## - +# edit /usr/local/dovecot/etc/dovecot/conf.d/15-mailboxes.conf +# _failed=false -echononl "\tAdjusting file 15-mailboxes.conf" -perl -i.ORIG -n -p -e "s#^([ ]*)(mailbox\ +Drafts\ +{.*)#\1\2\n\1 auto = subscribe#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/15-mailboxes.conf || _failed=true -if [ "$spam_folder" != "Junk" ]; then +if [[ $dovecot_major_version -gt 2 ]] \ + || ( [[ $dovecot_major_version -eq 2 ]] && [[ $dovecot_minor_version -gt 3 ]] ); then + + echononl " Adjusting file 15-mailboxes.conf.." + echo -e "$rc_not_yet_implemented" + +else + + ## - edit /usr/local/dovecot/etc/dovecot/conf.d/15-mailboxes.conf + ## - + ## - Add definitions for mailbox Spam: + ## - + ## - mailbox Drafts { + ## - auto = subscribe + ## - special_use = \Drafts + ## - } + ## - + ## - mailbox Trash { + ## - auto = subscribe + ## - special_use = \Trash + ## - } + ## - + ## - mailbox Sent { + ## - auto = subscribe + ## - special_use = \Sent + ## - } + ## - + ## - mailbox $spam_folder { + ## - auto = subscribe + ## - special_use = \Junk + ## - } + ## - + + echononl " Adjusting file 15-mailboxes.conf" + perl -i.ORIG -n -p -e "s#^([ ]*)(mailbox\ +Drafts\ +{.*)#\1\2\n\1 auto = subscribe#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/15-mailboxes.conf || _failed=true + if [ "$spam_folder" != "Junk" ]; then + if $plugin_expire ; then + perl -i -n -p -e "s#^([ ]*)(mailbox\ +Junk\ +{.*)#\1mailbox $spam_folder {\n\1 auto = subscribe\n\1 special_use = \\\Junk\n\1}\n\1\2#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/15-mailboxes.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)(mailbox\ +Junk\ +{.*)#\1\2\n\1 auto = no#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/15-mailboxes.conf || _failed=true + else + perl -i -n -p -e "s#^([ ]*)(mailbox\ +Junk\ +{.*)#\1mailbox $spam_folder {\n\1 auto = subscribe\n\1 autoexpunge = 30d\n\1 special_use = \\\Junk\n\1}\n\1\2#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/15-mailboxes.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)(mailbox\ +Junk\ +{.*)#\1\2\n\1 auto = no\n\1 autoexpunge = 30d#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/15-mailboxes.conf || _failed=true + fi + else + if $plugin_expire ; then + perl -i -n -p -e "s#^([ ]*)(mailbox\ +$spam_folder\ +{.*)#\1\2\n\1 auto = subscribe#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/15-mailboxes.conf || _failed=true + else + perl -i -n -p -e "s#^([ ]*)(mailbox\ +$spam_folder\ +{.*)#\1\2\n\1 auto = subscribe\n\1 autoexpunge = 30d#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/15-mailboxes.conf || _failed=true + fi + fi if $plugin_expire ; then - perl -i -n -p -e "s#^([ ]*)(mailbox\ +Junk\ +{.*)#\1mailbox $spam_folder {\n\1 auto = subscribe\n\1 special_use = \\\Junk\n\1}\n\1\2#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/15-mailboxes.conf || _failed=true - perl -i -n -p -e "s#^([ ]*)(mailbox\ +Junk\ +{.*)#\1\2\n\1 auto = no#g" \ + perl -i -n -p -e "s#^([ ]*)(mailbox\ +Trash\ +{.*)#\1\2\n\1 auto = subscribe#g" \ /usr/local/dovecot-${_version}/etc/dovecot/conf.d/15-mailboxes.conf || _failed=true else - perl -i -n -p -e "s#^([ ]*)(mailbox\ +Junk\ +{.*)#\1mailbox $spam_folder {\n\1 auto = subscribe\n\1 autoexpunge = 30d\n\1 special_use = \\\Junk\n\1}\n\1\2#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/15-mailboxes.conf || _failed=true - perl -i -n -p -e "s#^([ ]*)(mailbox\ +Junk\ +{.*)#\1\2\n\1 auto = no\n\1 autoexpunge = 30d#g" \ + perl -i -n -p -e "s#^([ ]*)(mailbox\ +Trash\ +{.*)#\1\2\n\1 auto = subscribe\n\1 autoexpunge = 3d#g" \ /usr/local/dovecot-${_version}/etc/dovecot/conf.d/15-mailboxes.conf || _failed=true fi -else - if $plugin_expire ; then - perl -i -n -p -e "s#^([ ]*)(mailbox\ +$spam_folder\ +{.*)#\1\2\n\1 auto = subscribe#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/15-mailboxes.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)(mailbox\ +Sent\ +{.*)#\1\2\n\1 auto = subscribe#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/15-mailboxes.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)(mailbox\ +\"Sent Messages\"\ +{.*)#\1\2\n\1 auto = no#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/15-mailboxes.conf || _failed=true + + if ! $_failed ; then + echo -e "$rc_done" else - perl -i -n -p -e "s#^([ ]*)(mailbox\ +$spam_folder\ +{.*)#\1\2\n\1 auto = subscribe\n\1 autoexpunge = 30d#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/15-mailboxes.conf || _failed=true + echo -e "$rc_failed" + fatal "Adjusting /usr/local/dovecot-${_version}/etc/dovecot/conf.d/15-mailboxes.conf failed" fi -fi -if $plugin_expire ; then - perl -i -n -p -e "s#^([ ]*)(mailbox\ +Trash\ +{.*)#\1\2\n\1 auto = subscribe#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/15-mailboxes.conf || _failed=true -else - perl -i -n -p -e "s#^([ ]*)(mailbox\ +Trash\ +{.*)#\1\2\n\1 auto = subscribe\n\1 autoexpunge = 3d#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/15-mailboxes.conf || _failed=true -fi -perl -i -n -p -e "s#^([ ]*)(mailbox\ +Sent\ +{.*)#\1\2\n\1 auto = subscribe#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/15-mailboxes.conf || _failed=true -perl -i -n -p -e "s#^([ ]*)(mailbox\ +\"Sent Messages\"\ +{.*)#\1\2\n\1 auto = no#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/15-mailboxes.conf || _failed=true -if ! $_failed ; then - echo -e "$rc_done" -else - echo -e "$rc_failed" - fatal "Adjusting /usr/local/dovecot-${_version}/etc/dovecot/conf.d/15-mailboxes.conf failed" -fi +fi # edit /usr/local/dovecot/etc/dovecot/conf.d/15-mailboxes.conf -## - edit /usr/local/dovecot/etc/dovecot/conf.d/10-auth.conf -## - -## - disable_plaintext_auth = no -## - auth_mechanisms = $auth_mechanisms -## - !include auth-sql.conf.ext # comment all other includes -## - auth_username_translation = "%@" -## - +# edit /usr/local/dovecot/etc/dovecot/conf.d/10-auth.conf +# _failed=false -echononl "\tAdjusting file 10-auth.conf" -perl -i.ORIG -n -p -e "s#^([ ]*)\#?\ ?(disable_plaintext_auth\ +=.*)#\1\#\# \2\n\1disable_plaintext_auth = yes#" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-auth.conf || _failed=true -perl -i -n -p -e "s#^([ ]*)\#?\ ?(auth_mechanisms\ +=.*)#\1\#\# \2\n\1auth_mechanisms = $auth_mechanisms#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-auth.conf || _failed=true -perl -i -n -p -e "s#^(\!include\ auth-.*)#\#\1#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-auth.conf || _failed=true -perl -i -n -p -e "s#^\#(\!include\ auth-sql.*)#\1#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-auth.conf || _failed=true -perl -i -n -p -e "s#^([ ]*)\#?\ ?(auth_username_translation\ +=.*)#\1\#\# \2\n\1auth_username_translation = \"%@\"#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-auth.conf || _failed=true +if [[ $dovecot_major_version -gt 2 ]] \ + || ( [[ $dovecot_major_version -eq 2 ]] && [[ $dovecot_minor_version -gt 3 ]] ); then + + echononl " Adjusting file '10-auth.conf'.." + echo -e "$rc_not_yet_implemented" -if ! $_failed ; then - echo -e "$rc_done" else - echo -e "$rc_failed" - fatal "Adjusting /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-auth.conf failed" -fi + + ## - edit /usr/local/dovecot/etc/dovecot/conf.d/10-auth.conf + ## - + ## - disable_plaintext_auth = no + ## - auth_mechanisms = $auth_mechanisms + ## - !include auth-sql.conf.ext # comment all other includes + ## - auth_username_translation = "%@" + ## - + echononl " Adjusting file 10-auth.conf" + perl -i.ORIG -n -p -e "s#^([ ]*)\#?\ ?(disable_plaintext_auth\ +=.*)#\1\#\# \2\n\1disable_plaintext_auth = yes#" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-auth.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)\#?\ ?(auth_mechanisms\ +=.*)#\1\#\# \2\n\1auth_mechanisms = $auth_mechanisms#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-auth.conf || _failed=true + perl -i -n -p -e "s#^(\!include\ auth-.*)#\#\1#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-auth.conf || _failed=true + perl -i -n -p -e "s#^\#(\!include\ auth-sql.*)#\1#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-auth.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)\#?\ ?(auth_username_translation\ +=.*)#\1\#\# \2\n\1auth_username_translation = \"%@\"#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-auth.conf || _failed=true + + if ! $_failed ; then + echo -e "$rc_done" + else + echo -e "$rc_failed" + fatal "Adjusting /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-auth.conf failed" + fi + +fi # edit /usr/local/dovecot/etc/dovecot/conf.d/10-auth.conf +# edit /usr/local/dovecot/etc/dovecot/conf.d/auth-sql.conf.ext +# +if [[ $dovecot_major_version -gt 2 ]] \ + || ( [[ $dovecot_major_version -eq 2 ]] && [[ $dovecot_minor_version -gt 3 ]] ); then -## - edit /usr/local/dovecot/etc/dovecot/conf.d/auth-sql.conf.ext -## - -## - passdb { -## - driver = sql -## - -## - -## - # path for sql configuration file, see example-config/dovecot-sql.conf.ext -## - args = /usr/local/dovecot/etc/dovecot/sql-connect.conf.ext -## - } -## - -## - .. -## - -## - userdb { -## - driver = sql -## - args = /usr/local/dovecot/etc/dovecot/sql-connect.conf.ext -## - } -## - -echononl "\tAdjusting file auth-sql.conf.ext" -perl -i.ORIG -n -p -e "s#^([ ]*)(args\ ?=.*)#\1\#\# \2\n\1args = /usr/local/dovecot/etc/dovecot/sql-connect.conf.ext#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/auth-sql.conf.ext + echononl " Adjusting file '/auth-sql.conf.ext'.." + echo -e "$rc_not_yet_implemented" -if ! $_failed ; then - echo -e "$rc_done" else - echo -e "$rc_failed" - fatal "Adjusting /usr/local/dovecot-${_version}/etc/dovecot/conf.d/auth-sql.conf.ext failed" -fi -## - create sql configuration file -## - -echononl "\tCreate sql configuration file sql-connect.conf.ext" -if [ "$db_driver" = "pgsql" ]; then + ## - edit /usr/local/dovecot/etc/dovecot/conf.d/auth-sql.conf.ext + ## - + ## - passdb { + ## - driver = sql + ## - + ## - + ## - # path for sql configuration file, see example-config/dovecot-sql.conf.ext + ## - args = /usr/local/dovecot/etc/dovecot/sql-connect.conf.ext + ## - } + ## - + ## - .. + ## - + ## - userdb { + ## - driver = sql + ## - args = /usr/local/dovecot/etc/dovecot/sql-connect.conf.ext + ## - } + ## - + echononl " Adjusting file auth-sql.conf.ext" + perl -i.ORIG -n -p -e "s#^([ ]*)(args\ ?=.*)#\1\#\# \2\n\1args = /usr/local/dovecot/etc/dovecot/sql-connect.conf.ext#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/auth-sql.conf.ext - cat < /usr/local/dovecot-${_version}/etc/dovecot/sql-connect.conf.ext + if ! $_failed ; then + echo -e "$rc_done" + else + echo -e "$rc_failed" + fatal "Adjusting /usr/local/dovecot-${_version}/etc/dovecot/conf.d/auth-sql.conf.ext failed" + fi + +fi # edit /usr/local/dovecot/etc/dovecot/conf.d/auth-sql.conf.ext + + +# create file /usr/local/dovecot-${_version}/etc/dovecot/sql-connect.conf.ext +# +if [[ $dovecot_major_version -gt 2 ]] \ + || ( [[ $dovecot_major_version -eq 2 ]] && [[ $dovecot_minor_version -gt 3 ]] ); then + + echononl " Create sql configuration file 'sql-connect.conf.ext'.." + echo -e "$rc_not_yet_implemented" + +else + + ## - create sql configuration file + ## - + echononl " Create sql configuration file 'sql-connect.conf.ext'.." + if [ "$db_driver" = "pgsql" ]; then + + cat < /usr/local/dovecot-${_version}/etc/dovecot/sql-connect.conf.ext driver = $db_driver ## - if using unix-socket (host=/run/postgresql) ensure that ## - coresponding entries in pg_hba.cof fits @@ -2528,16 +2713,16 @@ user_query = SELECT '/var/vmail/' || maildir AS home, \\ ## - iterate_query = SELECT username AS user FROM mailbox EOF - if [ "$?" = 0 ]; then - echo -e "$rc_done" - else - echo -e "$rc_failed" - fatal "Adjusting file /usr/local/dovecot-${_version}/etc/dovecot/sql-connect.conf.ext failed" - fi + if [ "$?" = 0 ]; then + echo -e "$rc_done" + else + echo -e "$rc_failed" + fatal "Adjusting file /usr/local/dovecot-${_version}/etc/dovecot/sql-connect.conf.ext failed" + fi -elif [ "$db_driver" = "mysql" ]; then + elif [ "$db_driver" = "mysql" ]; then - cat < /usr/local/dovecot-${_version}/etc/dovecot/sql-connect.conf.ext + cat < /usr/local/dovecot-${_version}/etc/dovecot/sql-connect.conf.ext driver = $db_driver connect = host=$dbhost user=$dbuser password=$dbpassword dbname=$dbname @@ -2554,55 +2739,69 @@ user_query = SELECT CONCAT('/var/vmail/',maildir) AS home, \\ ## - iterate_query = SELECT username AS user FROM mailbox EOF - if [ "$?" = 0 ]; then + if [ "$?" = 0 ]; then + echo -e "$rc_done" + else + echo -e "$rc_failed" + fatal "Adjusting file /usr/local/dovecot-${_version}/etc/dovecot/sql-connect.conf.ext failed" + fi + fi + +fi # create file /usr/local/dovecot-${_version}/etc/dovecot/sql-connect.conf.ext + + +# edit /usr/local/dovecot/etc/dovecot/conf.d/10-logging.conf +# +_failed=false +if [[ $dovecot_major_version -gt 2 ]] \ + || ( [[ $dovecot_major_version -eq 2 ]] && [[ $dovecot_minor_version -gt 3 ]] ); then + + echononl " Adjusting file '10-logging.conf'.." + echo -e "$rc_not_yet_implemented" + +else + + ## - edit /usr/local/dovecot/etc/dovecot/conf.d/10-logging.conf + ## - + ## - + ## - if running inetd-script: + ## - + ## - log_path = /var/log/dovecot/dovecot.log + ## - + ## - or for example + ## - + ## - log_path = syslog + ## - syslog_facility = local1 + ## - auth_verbose = yes + ## - auth_verbose_passwords = plain + ## - + ## - in conjunction with the the following entries in /etc/rsyslog.conf + ## - + ## - local1.* -/var/log/dovecot.log + ## - local1.info -/var/log/dovecot.info + ## - local1.warn -/var/log/dovecot.warn + ## - local1.err -/var/log/dovecot.err + ## - :msg,contains,"stored mail into mailbox"\ + ## - -/var/log/dovecot.lmtp + ## - + echononl " Adjusting file '10-logging.conf'.." + perl -i.ORIG -n -p -e "s#^([ ]*)\#?\ ?(log_path\ ?=.*)#\1\#\# \2\n\1log_path = syslog#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-logging.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)\#?\ ?(syslog_facility\ ?=.*)#\1\#\# \2\n\1syslog_facility = local1#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-logging.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)\#?\ ?(auth_verbose\ ?=.*)#\1\#\# \2\n\1auth_verbose = yes#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-logging.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)\#?\ ?(auth_verbose_passwords\ ?=.*)#\1\#\# \2\n\1auth_verbose_passwords = plain#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-logging.conf || _failed=true + + if ! $_failed ; then echo -e "$rc_done" else echo -e "$rc_failed" - fatal "Adjusting file /usr/local/dovecot-${_version}/etc/dovecot/sql-connect.conf.ext failed" + fatal "Adjusting /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-logging.conf failed" fi -fi - -## - edit /usr/local/dovecot/etc/dovecot/conf.d/10-logging.conf -## - -## - -## - if running inetd-script: -## - -## - log_path = /var/log/dovecot/dovecot.log -## - -## - or for example -## - -## - log_path = syslog -## - syslog_facility = local1 -## - auth_verbose = yes -## - auth_verbose_passwords = plain -## - -## - in conjunction with the the following entries in /etc/rsyslog.conf -## - -## - local1.* -/var/log/dovecot.log -## - local1.info -/var/log/dovecot.info -## - local1.warn -/var/log/dovecot.warn -## - local1.err -/var/log/dovecot.err -## - :msg,contains,"stored mail into mailbox"\ -## - -/var/log/dovecot.lmtp -## - -_failed=false -echononl "\tAdjusting file 10-logging.conf" -perl -i.ORIG -n -p -e "s#^([ ]*)\#?\ ?(log_path\ ?=.*)#\1\#\# \2\n\1log_path = syslog#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-logging.conf || _failed=true -perl -i -n -p -e "s#^([ ]*)\#?\ ?(syslog_facility\ ?=.*)#\1\#\# \2\n\1syslog_facility = local1#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-logging.conf || _failed=true -perl -i -n -p -e "s#^([ ]*)\#?\ ?(auth_verbose\ ?=.*)#\1\#\# \2\n\1auth_verbose = yes#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-logging.conf || _failed=true -perl -i -n -p -e "s#^([ ]*)\#?\ ?(auth_verbose_passwords\ ?=.*)#\1\#\# \2\n\1auth_verbose_passwords = plain#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-logging.conf || _failed=true - -if ! $_failed ; then - echo -e "$rc_done" -else - echo -e "$rc_failed" - fatal "Adjusting /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-logging.conf failed" -fi +fi # edit /usr/local/dovecot/etc/dovecot/conf.d/10-logging.conf if $_new ; then @@ -2610,7 +2809,7 @@ if $_new ; then mkdir -p /var/log/dovecot echo - echononl "\tCreate file /etc/rsyslog.d/dovecot.conf" + echononl " Create file /etc/rsyslog.d/dovecot.conf" cat < /etc/rsyslog.d/dovecot.conf ## - dovecot @@ -2631,7 +2830,7 @@ EOF fatal "Creating file /etc/rsyslog.d/dovecot.conf failed" fi - echononl "\tRestart rsyslog Servive" + echononl " Restart rsyslog Servive" if $systemd_support ; then systemctl restart rsyslog.service > /dev/null 2>&1 else @@ -2647,7 +2846,7 @@ EOF ## - logrotate for dovecot log-files ## - - echononl "\tCreate file /etc/logrotate.d/dovecot" + echononl " Create file /etc/logrotate.d/dovecot" cat < /etc/logrotate.d/dovecot /var/log/dovecot/dovecot.log /var/log/dovecot/dovecot.info @@ -2679,184 +2878,271 @@ EOF echo fi -## - edit /usr/local/dovecot/etc/dovecot/conf.d/15-lda.conf -## - -## - postmaster_address = $postmaster_address -## - hostname = $hostname -## - sendmail_path = /usr/sbin/sendmail -## - lda_mailbox_autocreate = no -## - mail_plugins = $mail_plugins sieve -## - -_failed=false -echononl "\tAdjusting file 15-lda.conf" -perl -i.ORIG -n -p -e "s#^([ ]*)\#?\ ?(postmaster_address\ +=.*)#\1\#\# \2\n\1postmaster_address = $postmaster_address#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/15-lda.conf || _failed=true -perl -i -n -p -e "s#^([ ]*)\#?\ ?(hostname\ +=.*)#\1\#\# \2\n\1hostname = $hostname#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/15-lda.conf || _failed=true -perl -i -n -p -e "s#^([ ]*)\#?\ ?(sendmail_path\ +=.*)#\1\#\# \2\n\1sendmail_path = /usr/sbin/sendmail#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/15-lda.conf || _failed=true -perl -i -n -p -e "s#^([ ]*)\#?\ ?(lda_mailbox_autocreate\ +=.*)#\1\#\# \2\n\1lda_mailbox_autocreate = no#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/15-lda.conf || _failed=true -perl -i -n -p -e "s#^([ ]*)\#?\ ?(mail_plugins\ +=.*)#\1\#\# \2\n\1mail_plugins = \\\$mail_plugins sieve#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/15-lda.conf || _failed=true -if ! $_failed ; then - echo -e "$rc_done" +# edit /usr/local/dovecot/etc/dovecot/conf.d/15-lda.conf +# +_failed=false +if [[ $dovecot_major_version -gt 2 ]] \ + || ( [[ $dovecot_major_version -eq 2 ]] && [[ $dovecot_minor_version -gt 3 ]] ); then + + echononl " Adjusting file '15-lda.conf'.." + echo -e "$rc_not_yet_implemented" + else - echo -e "$rc_failed" - fatal "Adjusting /usr/local/dovecot-${_version}/etc/dovecot/conf.d/15-lda.conf failed" -fi - -## - edit /usr/local/dovecot/etc/dovecot/conf.d/20-lmtp -## - -## - lmtp_save_to_detail_mailbox = no -## - mail_plugins = $mail_plugins sieve -## - -_failed=false -echononl "\tAdjusting file 20-lmtp.conf" -perl -i.ORIG -n -p -e "s#^([ ]*)\#?\ ?(lmtp_save_to_detail_mailbox\ +=.*)#\1\#\# \2\n\1lmtp_save_to_detail_mailbox = no#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-lmtp.conf || _failed=true -perl -i -n -p -e "s#^([ ]*)\#?\ ?(mail_plugins\ +=.*)#\1\#\# \2\n\1mail_plugins = \\\$mail_plugins sieve#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-lmtp.conf || _failed=true - -if ! $_failed ; then - echo -e "$rc_done" -else - echo -e "$rc_failed" - fatal "Adjusting /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-lmtp.conf failed" -fi - - -## - edit /usr/local/dovecot/etc/dovecot/conf.d/20-imap.conf -## - -## - ssl_cert = <$imap_cert -## - ssl_key = <$imap_key -## - mail_max_userip_connections = $max_userip_connections -## - mail_plugins = $mail_plugins imap_quota -## - imap_client_workarounds = delay-newmail -## - -_failed=false -echononl "\tAdjusting file 20-imap.conf" -perl -i.ORIG -n -p -e "s#^([ ]*)\#?\ ?(protocol imap \{)#\1\2\n\n\1 ssl_cert = <$imap_cert\n\1 ssl_key = <$imap_key\n#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-imap.conf || _failed=true -perl -i -n -p -e "s#^([ ]*)\#?\ ?(mail_max_userip_connections\ +=.*)#\1\#\# \2\n\1mail_max_userip_connections = $max_userip_connections#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-imap.conf || _failed=true -perl -i -n -p -e "s#^([ ]*)\#?\ ?(mail_plugins\ +=.*)#\1\#\# \2\n\1mail_plugins = \\\$mail_plugins imap_quota#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-imap.conf || _failed=true -perl -i -n -p -e "s#^([ ]*)\#?\ ?(imap_client_workarounds\ +=.*)#\1\#\# \2\n\1imap_client_workarounds = delay-newmail#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-imap.conf || _failed=true - -if ! $_failed ; then - echo -e "$rc_done" -else - echo -e "$rc_failed" - fatal "Adjusting /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-imap.conf failed" -fi - - -## - edit /usr/local/dovecot/etc/dovecot/conf.d/20-pop3.conf -## - -## - ssl_cert = <$pop_cert -## - ssl_key = <$pop_key -## - mail_max_userip_connections = 24 -## - pop3_client_workarounds = outlook-no-nuls oe-ns-eoh -## - -_failed=false -echononl "\tAdjusting file 20-pop3.conf" -perl -i.ORIG -n -p -e "s#^([ ]*)\#?\ ?(protocol pop3 \{)#\1\2\n\n\1 ssl_cert = <$pop_cert\n\1 ssl_key = <$pop_key\n#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-pop3.conf || _failed=true -perl -i -n -p -e "s#^([ ]*)\#?\ ?(mail_max_userip_connections\ +=.*)#\1\#\# \2\n\1mail_max_userip_connections = 24#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-pop3.conf || _failed=true -perl -i -n -p -e "s#^([ ]*)\#?\ ?(pop3_client_workarounds\ +=.*)#\1\#\# \2\n\1pop3_client_workarounds = outlook-no-nuls oe-ns-eoh#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-pop3.conf || _failed=true - -if ! $_failed ; then - echo -e "$rc_done" -else - echo -e "$rc_failed" - fatal "Adjusting /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-pop3.conf failed" -fi - - -## - edit /usr/local/dovecot/etc/dovecot/conf.d/90-plugin.conf -## - -## - Note: -## - Setting "autocreate", "autosubscribe" here is depricated. Use mailbox { auto } setting instead. -## - -## - expire = Trash -## - expire2 = Trash/* -## - expire3 = Spam -## - -## - expire_dict = proxy::expire -## - -## - # Enable caching of dict value in dovecot.index file. This significantly reduces -## - # the number of dict lookups. It makes initial testing more confusing though, so -## - # it's better to enable it only after you've verified that the expire plugin is -## - # working as wanted. (v2.2.16+) -## - expire_cache = yes -## - -_failed=false -echononl "\tAdjusting file 90-plugin.conf" -if $plugin_expire ; then - perl -i.ORIG -n -p -e "s#^([ ]*)(\#?\ ?setting_name\ +=.*)#\1\2\n\n\1expire = Trash\n\1expire2 = Trash/*\n\1expire3 = $spam_folder\n\n\1expire_dict = proxy::expire\n\n\1\# Enable caching of dict value in dovecot.index file. This significantly reduces\n\1\# the number of dict lookups. It makes initial testing more confusing though, so\n\1\# it's better to enable it only after you've verified that the expire plugin is\n\1\# working as wanted. (v2.2.16+)\n\1expire_cache = yes#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/90-plugin.conf || _failed=true + ## - edit /usr/local/dovecot/etc/dovecot/conf.d/15-lda.conf + ## - + ## - postmaster_address = $postmaster_address + ## - hostname = $hostname + ## - sendmail_path = /usr/sbin/sendmail + ## - lda_mailbox_autocreate = no + ## - mail_plugins = $mail_plugins sieve + ## - + echononl " Adjusting file '15-lda.conf'.." + perl -i.ORIG -n -p -e "s#^([ ]*)\#?\ ?(postmaster_address\ +=.*)#\1\#\# \2\n\1postmaster_address = $postmaster_address#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/15-lda.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)\#?\ ?(hostname\ +=.*)#\1\#\# \2\n\1hostname = $hostname#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/15-lda.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)\#?\ ?(sendmail_path\ +=.*)#\1\#\# \2\n\1sendmail_path = /usr/sbin/sendmail#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/15-lda.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)\#?\ ?(lda_mailbox_autocreate\ +=.*)#\1\#\# \2\n\1lda_mailbox_autocreate = no#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/15-lda.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)\#?\ ?(mail_plugins\ +=.*)#\1\#\# \2\n\1mail_plugins = \\\$mail_plugins sieve#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/15-lda.conf || _failed=true if ! $_failed ; then echo -e "$rc_done" else echo -e "$rc_failed" - fatal "Adjusting /usr/local/dovecot-${_version}/etc/dovecot/conf.d/90-plugin.conf failed" + fatal "Adjusting /usr/local/dovecot-${_version}/etc/dovecot/conf.d/15-lda.conf failed" fi -else - echo -e "$rc_skipped" -fi + +fi # edit /usr/local/dovecot/etc/dovecot/conf.d/15-lda.conf -## - edit /usr/local/dovecot/etc/dovecot/conf.d/90-sieve.conf -## - -## - sieve = ~/.dovecot.sieve -## - #sieve_global_path = /usr/local/dovecot/etc/dovecot/sieve/default.sieve -## - sieve_before = /usr/local/dovecot/etc/dovecot/sieve/move-spam.sieve -## - sieve_dir = ~/sieve -## - sieve_global = /usr/local/dovecot/etc/dovecot/sieve/global/ -## - recipient_delimiter = -## - +# edit /usr/local/dovecot/etc/dovecot/conf.d/20-lmtp +# _failed=false -echononl "\tAdjusting file 90-sieve.conf" -perl -i.ORIG -n -p -e "s#^([ ]*)\#?\ ?(sieve\ ?=.*)#\1\#\# \2\n\1sieve = ~/.dovecot.sieve#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/90-sieve.conf || _failed=true -perl -i -n -p -e "s#^([ ]*)\#?\ ?(sieve_before\ ?=.*)#\1\#\# \2\n\1sieve_before =/usr/local/dovecot/etc/dovecot/sieve/move-spam.sieve#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/90-sieve.conf || _failed=true -perl -i -n -p -e "s#^([ ]*)\#?\ ?(sieve_dir\ ?=.*)#\1\#\# \2\n\1sieve_dir = ~/sieve#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/90-sieve.conf || _failed=true -perl -i -n -p -e "s#^([ ]*)\#?\ ?(sieve_global\ ?=.*)#\1\#\# \2\n\1sieve_global = /usr/local/dovecot/etc/dovecot/sieve/global/#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/90-sieve.conf || _failed=true -perl -i -n -p -e "s#^([ ]*)\#?\ ?(recipient_delimiter\ ?=.*)#\1\#\# \2\n\1recipient_delimiter =#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/90-sieve.conf || _failed=true +if [[ $dovecot_major_version -gt 2 ]] \ + || ( [[ $dovecot_major_version -eq 2 ]] && [[ $dovecot_minor_version -gt 3 ]] ); then + + echononl " Adjusting file '20-lmtp.conf'.." + echo -e "$rc_not_yet_implemented" -if ! $_failed ; then - echo -e "$rc_done" else - echo -e "$rc_failed" - fatal "Adjusting /usr/local/dovecot-${_version}/etc/dovecot/conf.d/90-sieve.conf" -fi -# - Add Setting from Pigeonhole Sieve: Vacation Extension -# - -echononl "\tAdd Setting for included Pigeonhole Sieve: Vacation Extension" -_found=false -_tmp_file="/tmp/dovecot_conf_90-sieve.conf" -cp -a "/usr/local/dovecot-${_version}/etc/dovecot/conf.d/90-sieve.conf" "$_tmp_file" > /dev/null 2>&1 -:> $_tmp_file -while IFS='' read -r _line || [[ -n $_line ]] ; do + ## - edit /usr/local/dovecot/etc/dovecot/conf.d/20-lmtp + ## - + ## - lmtp_save_to_detail_mailbox = no + ## - mail_plugins = $mail_plugins sieve + ## - + echononl " Adjusting file '20-lmtp.conf'.." + perl -i.ORIG -n -p -e "s#^([ ]*)\#?\ ?(lmtp_save_to_detail_mailbox\ +=.*)#\1\#\# \2\n\1lmtp_save_to_detail_mailbox = no#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-lmtp.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)\#?\ ?(mail_plugins\ +=.*)#\1\#\# \2\n\1mail_plugins = \\\$mail_plugins sieve#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-lmtp.conf || _failed=true - echo "$_line" >> "$_tmp_file" + if ! $_failed ; then + echo -e "$rc_done" + else + echo -e "$rc_failed" + fatal "Adjusting /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-lmtp.conf failed" + fi - if ! $_found && $(echo "$_line" | grep -i -E "^\s*plugin {" > /dev/null 2>&1) ; then - _found=true +fi # edit /usr/local/dovecot/etc/dovecot/conf.d/20-lmtp - cat <> "$_tmp_file" + +# edit /usr/local/dovecot/etc/dovecot/conf.d/20-imap.conf +# +_failed=false +if [[ $dovecot_major_version -gt 2 ]] \ + || ( [[ $dovecot_major_version -eq 2 ]] && [[ $dovecot_minor_version -gt 3 ]] ); then + + echononl " Adjusting file '20-lmtp.conf'.." + echo -e "$rc_not_yet_implemented" + +else + + ## - edit /usr/local/dovecot/etc/dovecot/conf.d/20-imap.conf + ## - + ## - ssl_cert = <$imap_cert + ## - ssl_key = <$imap_key + ## - mail_max_userip_connections = $max_userip_connections + ## - mail_plugins = $mail_plugins imap_quota + ## - imap_client_workarounds = delay-newmail + ## - + echononl " Adjusting file 20-imap.conf" + perl -i.ORIG -n -p -e "s#^([ ]*)\#?\ ?(protocol imap \{)#\1\2\n\n\1 ssl_cert = <$imap_cert\n\1 ssl_key = <$imap_key\n#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-imap.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)\#?\ ?(mail_max_userip_connections\ +=.*)#\1\#\# \2\n\1mail_max_userip_connections = $max_userip_connections#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-imap.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)\#?\ ?(mail_plugins\ +=.*)#\1\#\# \2\n\1mail_plugins = \\\$mail_plugins imap_quota#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-imap.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)\#?\ ?(imap_client_workarounds\ +=.*)#\1\#\# \2\n\1imap_client_workarounds = delay-newmail#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-imap.conf || _failed=true + + if ! $_failed ; then + echo -e "$rc_done" + else + echo -e "$rc_failed" + fatal "Adjusting /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-imap.conf failed" + fi + +fi # edit /usr/local/dovecot/etc/dovecot/conf.d/20-imap.conf + + +# edit /usr/local/dovecot/etc/dovecot/conf.d/20-pop3.conf +# +_failed=false +if [[ $dovecot_major_version -gt 2 ]] \ + || ( [[ $dovecot_major_version -eq 2 ]] && [[ $dovecot_minor_version -gt 3 ]] ); then + + echononl " Adjusting file '20-pop3.conf'.." + echo -e "$rc_not_yet_implemented" + +else + + ## - edit /usr/local/dovecot/etc/dovecot/conf.d/20-pop3.conf + ## - + ## - ssl_cert = <$pop_cert + ## - ssl_key = <$pop_key + ## - mail_max_userip_connections = 24 + ## - pop3_client_workarounds = outlook-no-nuls oe-ns-eoh + ## - + echononl " Adjusting file 20-pop3.conf" + perl -i.ORIG -n -p -e "s#^([ ]*)\#?\ ?(protocol pop3 \{)#\1\2\n\n\1 ssl_cert = <$pop_cert\n\1 ssl_key = <$pop_key\n#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-pop3.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)\#?\ ?(mail_max_userip_connections\ +=.*)#\1\#\# \2\n\1mail_max_userip_connections = 24#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-pop3.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)\#?\ ?(pop3_client_workarounds\ +=.*)#\1\#\# \2\n\1pop3_client_workarounds = outlook-no-nuls oe-ns-eoh#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-pop3.conf || _failed=true + + if ! $_failed ; then + echo -e "$rc_done" + else + echo -e "$rc_failed" + fatal "Adjusting /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-pop3.conf failed" + fi + +fi # edit /usr/local/dovecot/etc/dovecot/conf.d/20-pop3.conf + + +# edit /usr/local/dovecot/etc/dovecot/conf.d/90-plugin.conf +# +_failed=false +if [[ $dovecot_major_version -gt 2 ]] \ + || ( [[ $dovecot_major_version -eq 2 ]] && [[ $dovecot_minor_version -gt 3 ]] ); then + + echononl " Adjusting file '90-plugin.conf'.." + echo -e "$rc_skipped" + +else + + ## - edit /usr/local/dovecot/etc/dovecot/conf.d/90-plugin.conf + ## - + ## - Note: + ## - Setting "autocreate", "autosubscribe" here is depricated. Use mailbox { auto } setting instead. + ## - + ## - expire = Trash + ## - expire2 = Trash/* + ## - expire3 = Spam + ## - + ## - expire_dict = proxy::expire + ## - + ## - # Enable caching of dict value in dovecot.index file. This significantly reduces + ## - # the number of dict lookups. It makes initial testing more confusing though, so + ## - # it's better to enable it only after you've verified that the expire plugin is + ## - # working as wanted. (v2.2.16+) + ## - expire_cache = yes + ## - + echononl " Adjusting file 90-plugin.conf" + if $plugin_expire ; then + perl -i.ORIG -n -p -e "s#^([ ]*)(\#?\ ?setting_name\ +=.*)#\1\2\n\n\1expire = Trash\n\1expire2 = Trash/*\n\1expire3 = $spam_folder\n\n\1expire_dict = proxy::expire\n\n\1\# Enable caching of dict value in dovecot.index file. This significantly reduces\n\1\# the number of dict lookups. It makes initial testing more confusing though, so\n\1\# it's better to enable it only after you've verified that the expire plugin is\n\1\# working as wanted. (v2.2.16+)\n\1expire_cache = yes#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/90-plugin.conf || _failed=true + + + if ! $_failed ; then + echo -e "$rc_done" + else + echo -e "$rc_failed" + fatal "Adjusting /usr/local/dovecot-${_version}/etc/dovecot/conf.d/90-plugin.conf failed" + fi + else + echo -e "$rc_skipped" + fi + +fi # edit /usr/local/dovecot/etc/dovecot/conf.d/90-plugin.conf + + +# edit /usr/local/dovecot/etc/dovecot/conf.d/90-sieve.conf +# +_failed=false +if [[ $dovecot_major_version -gt 2 ]] \ + || ( [[ $dovecot_major_version -eq 2 ]] && [[ $dovecot_minor_version -gt 3 ]] ); then + + echononl " Adjusting file '20-lmtp.conf'.." + echo -e "$rc_not_yet_implemented" + +else + + ## - edit /usr/local/dovecot/etc/dovecot/conf.d/90-sieve.conf + ## - + ## - sieve = ~/.dovecot.sieve + ## - #sieve_global_path = /usr/local/dovecot/etc/dovecot/sieve/default.sieve + ## - sieve_before = /usr/local/dovecot/etc/dovecot/sieve/move-spam.sieve + ## - sieve_dir = ~/sieve + ## - sieve_global = /usr/local/dovecot/etc/dovecot/sieve/global/ + ## - recipient_delimiter = + ## - + echononl " Adjusting file 90-sieve.conf" + perl -i.ORIG -n -p -e "s#^([ ]*)\#?\ ?(sieve\ ?=.*)#\1\#\# \2\n\1sieve = ~/.dovecot.sieve#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/90-sieve.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)\#?\ ?(sieve_before\ ?=.*)#\1\#\# \2\n\1sieve_before =/usr/local/dovecot/etc/dovecot/sieve/move-spam.sieve#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/90-sieve.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)\#?\ ?(sieve_dir\ ?=.*)#\1\#\# \2\n\1sieve_dir = ~/sieve#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/90-sieve.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)\#?\ ?(sieve_global\ ?=.*)#\1\#\# \2\n\1sieve_global = /usr/local/dovecot/etc/dovecot/sieve/global/#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/90-sieve.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)\#?\ ?(recipient_delimiter\ ?=.*)#\1\#\# \2\n\1recipient_delimiter =#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/90-sieve.conf || _failed=true + + if ! $_failed ; then + echo -e "$rc_done" + else + echo -e "$rc_failed" + fatal "Adjusting /usr/local/dovecot-${_version}/etc/dovecot/conf.d/90-sieve.conf" + fi + +fi # edit /usr/local/dovecot/etc/dovecot/conf.d/90-sieve.conf + + +# adjust /usr/local/dovecot/etc/dovecot/conf.d/90-sieve.conf +# +# Add Setting for included Pigeonhole Sieve: Vacation Extension +# +_failed=false +if [[ $dovecot_major_version -gt 2 ]] \ + || ( [[ $dovecot_major_version -eq 2 ]] && [[ $dovecot_minor_version -gt 3 ]] ); then + + echononl " Add Setting for included Pigeonhole Sieve: Vacation Extension'.." + echo -e "$rc_not_yet_implemented" + +else + + # - Add Setting from Pigeonhole Sieve: Vacation Extension + # - + echononl " Add Setting for included Pigeonhole Sieve: Vacation Extension" + _tmp_file="/tmp/dovecot_conf_90-sieve.conf" + cp -a "/usr/local/dovecot-${_version}/etc/dovecot/conf.d/90-sieve.conf" "$_tmp_file" > /dev/null 2>&1 + :> $_tmp_file + while IFS='' read -r _line || [[ -n $_line ]] ; do + + echo "$_line" >> "$_tmp_file" + + if ! $_found && $(echo "$_line" | grep -i -E "^\s*plugin {" > /dev/null 2>&1) ; then + _found=true + + cat <> "$_tmp_file" # Add Setting 'sieve_vacation_send_from_recipient' from (included) # @@ -2881,13 +3167,15 @@ while IFS='' read -r _line || [[ -n $_line ]] ; do sieve_vacation_send_from_recipient = yes EOF - fi -done < "/usr/local/dovecot-${_version}/etc/dovecot/conf.d/90-sieve.conf" -cp -a "$_tmp_file" "/usr/local/dovecot-${_version}/etc/dovecot/conf.d/90-sieve.conf" > /dev/null 2>&1 -echo -e "$rc_done" + fi + done < "/usr/local/dovecot-${_version}/etc/dovecot/conf.d/90-sieve.conf" + cp -a "$_tmp_file" "/usr/local/dovecot-${_version}/etc/dovecot/conf.d/90-sieve.conf" > /dev/null 2>&1 + echo -e "$rc_done" + +fi # adjust /usr/local/dovecot/etc/dovecot/conf.d/90-sieve.conf -echononl "\tCreate Directory for global sieve scripts" +echononl " Create Directory for global sieve scripts" mkdir -p "/usr/local/dovecot-${_version}/etc/dovecot/sieve/global/" > $log_file 2>&1 if [ "$?" = 0 ]; then echo -e "$rc_done" @@ -2895,7 +3183,7 @@ else echo -e "$rc_failed" error "$(cat $log_file)" - echononl "\tcontinue anyway [yes/no]: " + echononl " continue anyway [yes/no]: " read OK OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do @@ -2909,7 +3197,7 @@ fi ## - ceate global sieve script ## - -echononl "\tCeate global sieve script" +echononl " Ceate global sieve script" cat < /usr/local/dovecot-${_version}/etc/dovecot/sieve/move-spam.sieve require ["fileinto"]; # rule:[Move Spam] @@ -2927,7 +3215,7 @@ else echo -e "$rc_failed" error "Creating global sieve script failed" - echononl "\tcontinue anyway [yes/no]: " + echononl " continue anyway [yes/no]: " read OK OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do @@ -2941,7 +3229,7 @@ fi ## - NOTICE: if you pre-compile your (global) scripts, you will increase ## - performance ## - -echononl "\tPrecompile global sieve script" +echononl " Precompile global sieve script" cd /usr/local/dovecot-${_version}/etc/dovecot/sieve/ /usr/local/dovecot-${_version}/bin/sievec \ /usr/local/dovecot-${_version}/etc/dovecot/sieve/move-spam.sieve > $log_file 2>&1 @@ -2952,7 +3240,7 @@ else echo -e "$rc_failed" error "$(cat $log_file)" - echononl "\tcontinue anyway [yes/no]: " + echononl " continue anyway [yes/no]: " read OK OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do @@ -2974,7 +3262,7 @@ if $systemd_support; then ## - # - At time, we don't use private tmp directory for divecot. ## - # - - ## - echononl "\tAdjust Systemd service file, set PrivateTmp=false.." + ## - echononl " Adjust Systemd service file, set PrivateTmp=false.." ## - if [[ -f "/etc/systemd/system/dovecot.service" ]] ; then ## - ## - if $(grep -o -E "PrivateTmp\s*=\s*[^[:blank:]]+" /etc/systemd/system/dovecot.service | grep -q true 2> /dev/null ) ; then @@ -3006,7 +3294,7 @@ if $systemd_support; then if [[ $service_limit_nofile -gt _LimitNOFILE ]] ; then adjust_limit_nofile=true - echononl "\tCreate Directory '/etc/systemd/system/dovecot.service.d'.." + echononl " Create Directory '/etc/systemd/system/dovecot.service.d'.." if [[ -d "/etc/systemd/system/dovecot.service.d" ]] ; then echo -e "$rc_skipped" else @@ -3021,7 +3309,7 @@ if $systemd_support; then fi - echononl "\tAdjust 'LimitNOFILE' for 'dovecot.service'.." + echononl " Adjust 'LimitNOFILE' for 'dovecot.service'.." if ! $adjust_limit_nofile ; then echo -e "$rc_skipped" else @@ -3034,7 +3322,7 @@ EOF fi - echononl "\tReload systemd .." + echononl " Reload systemd .." systemctl daemon-reload > /dev/null 2>&1 if [ "$?" = 0 ]; then echo -e "$rc_done" @@ -3044,7 +3332,7 @@ EOF ## - Make dovecot start at boot time ## - - echononl "\tMake dovecot start at boottime.." + echononl " Make dovecot start at boottime.." systemctl enable dovecot > /dev/null 2>&1 if [ "$?" = 0 ]; then echo -e "$rc_done" @@ -3057,7 +3345,7 @@ else ## - Make dovecot start at boot time ## - - echononl "\tMake dovecot start at boottime.." + echononl " Make dovecot start at boottime.." update-rc.d dovecot defaults > /dev/null 2>&1 if [ "$?" = 0 ]; then echo -e "$rc_done" @@ -3078,7 +3366,7 @@ if $_new ; then echo -n "Create init script /etc/init.d/dovecot ? [y/n]: " read _create_init if [ "y" = "$_create_init" -o "Y" = "$_create_init" -o "Yes" = "$_create_init" -o "yes" = "$_create_init" ];then - echononl "\tCreate init script for dovecot .." + echononl " Create init script for dovecot .." ## - running dovecot service via init-script ## - cat < /etc/init.d/dovecot @@ -3278,7 +3566,7 @@ EOF chmod 755 /etc/init.d/dovecot else - echononl "\tCreate init script for dovecot .." + echononl " Create init script for dovecot .." echo -e "$rc_skipped" fi @@ -3292,7 +3580,7 @@ EOF ## - ## - Doimg a restart (after ipv6 adresses are present) fixes this. ## - - echononl "\tCreate cronjob to restart dovecot service after reboot.." + echononl " Create cronjob to restart dovecot service after reboot.." _crontab_tmp_file=/tmp/crontab_root.$$ crontab -l > $_crontab_tmp_file 2> /dev/null @@ -3323,7 +3611,7 @@ EOF ## - flags=drhu user=vmail:vmail argv=/usr/local/dovecot/libexec/dovecot/dovecot-lda -f ${sender} -d ${user}@${nexthop} if ! grep -e dovecot-lda /etc/postfix/master.cf > /dev/null ; then cp -a "/etc/postfix/master.cf" "/etc/postfix/master.cf.$backup_date" - echononl "\tConfigure /etc/postfix/master.cf to play with dovecot lda" + echononl " Configure /etc/postfix/master.cf to play with dovecot lda" echo -e "\ndovecot unix - n n - - pipe\n flags=drhu user=vmail:vmail argv=/usr/local/dovecot/libexec/dovecot/dovecot-lda -f \${sender} -d \${user}@\${nexthop}" >> /etc/postfix/master.cf if [ "$?" = 0 ]; then echo -e "$rc_done" @@ -3352,7 +3640,7 @@ EOF ## - permit_sasl_authenticated, ## - _failed=false - echononl "\tAdjust /etc/postfix/main.cf" + echononl " Adjust /etc/postfix/main.cf" perl -i.$backup_date -n -p -e "s#^(\s*)(smtpd_tls_auth_only\ *=.*)#smtpd_tls_auth_only = yes#" \ /etc/postfix/main.cf || _failed=true @@ -3378,7 +3666,7 @@ EOF ## - add a cronjob to run expunge scripts, to delete old mails ## - from users'mailbox. only cleanup spam and trash directories ## - - echononl "\tCreate cronjob to run expunge scripts" + echononl " Create cronjob to run expunge scripts" _crontab_tmp_file=/tmp/crontab_root.$$ crontab -l > $_crontab_tmp_file 2> /dev/null @@ -3412,7 +3700,7 @@ echo -e "\033[1mChange (from lda) to lmtp-service\033[m" ## - add "lmtp" to protocols ## - _failed=false -echononl "\tAdd lmtp to protocols (dovecot.conf)" +echononl " Add lmtp to protocols (dovecot.conf)" perl -i -n -p -e "s#^([ ]*)(protocols\ +=\ +.*)#\1\2 lmtp#" \ /usr/local/dovecot-${_version}/etc/dovecot/dovecot.conf || _failed=true if ! $_failed ; then @@ -3431,7 +3719,7 @@ fi ## - group = postfix ## - } ## - -echononl "\tAdding dovecot-lmtp listener to 10-master.conf" +echononl " Adding dovecot-lmtp listener to 10-master.conf" perl -i -n -p -e "s#^([ ]*)(unix_listener\ +lmtp\ .*)#\1unix_listener /var/spool/postfix/private/dovecot-lmtp {\n user = postfix\n mode = 0660\n group = postfix#g" \ /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-master.conf if ! $_failed ; then @@ -3455,7 +3743,7 @@ fi # - virtual_transport = lmtp:unix:private/dovecot-lmtp var="smtpd_sasl_auth_enable" val="yes" -echononl "\t${postfix_main_cf}: adjust '${var}'.." +echononl " ${postfix_main_cf}: adjust '${var}'.." if ! $(grep -E -q "^\s*${var}\s*=\s*${val}" ${postfix_main_cf} 2> /dev/null) ; then perl -i -n -p -e "s#^(\s*)(${var}\ *=.*)#${var} = ${val}#" \ /etc/postfix/main.cf > $log_file 2>&1 @@ -3472,7 +3760,7 @@ fi var="smtpd_sasl_type" val="dovecot" -echononl "\t${postfix_main_cf}: adjust '${var}'.." +echononl " ${postfix_main_cf}: adjust '${var}'.." if ! $(grep -E -q "^\s*${var}\s*=\s*${val}" ${postfix_main_cf} 2> /dev/null) ; then perl -i -n -p -e "s#^(\s*)(${var}\ *=.*)#${var} = ${val}#" \ /etc/postfix/main.cf > $log_file 2>&1 @@ -3489,7 +3777,7 @@ fi var="smtpd_sasl_path" val="private/dovecot-auth" -echononl "\t${postfix_main_cf}: adjust '${var}'.." +echononl " ${postfix_main_cf}: adjust '${var}'.." if ! $(grep -E -q "^\s*${var}\s*=\s*${val}" ${postfix_main_cf} 2> /dev/null) ; then perl -i -n -p -e "s#^(\s*)(${var}\ *=.*)#${var} = ${val}#" \ /etc/postfix/main.cf > $log_file 2>&1 @@ -3506,7 +3794,7 @@ fi var="virtual_transport" val="lmtp:unix:private/dovecot-lmtp" -echononl "\t${postfix_main_cf}: adjust '${var}'.." +echononl " ${postfix_main_cf}: adjust '${var}'.." if ! $(grep -E -q "^\s*${var}\s*=\s*${val}" ${postfix_main_cf} 2> /dev/null) ; then perl -i -n -p -e "s#^(\s*)(${var}\ *=.*)#${var} = ${val}#" \ /etc/postfix/main.cf > $log_file 2>&1 @@ -3522,7 +3810,7 @@ else fi -echononl "\tComment variable 'dovecot_destination_recipient_limit'.." +echononl " Comment variable 'dovecot_destination_recipient_limit'.." if $(grep -E -q "^\s*dovecot_destination_recipient_limit" ${postfix_main_cf} 2> /dev/null) ; then perl -i-n -p -e "s/^(\s*)(dovecot_destination_recipient_limit.*)/\1\#\2/" /etc/postfix/main.cf > $log_file 2>&1 if [[ $? -eq 0 ]]; then @@ -3585,7 +3873,7 @@ echo -e "\033[1mConfigure quota support for dovecot\033[m" ## - } ## - _failed=false -echononl "\tConfigure dict service (10-master.conf)" +echononl " Configure dict service (10-master.conf)" perl -i -n -p -e "s#^([ ]*)(unix_listener\ +dict.*)#\1\2\n\1 mode = 0600\n\1 user = vmail#g" \ /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-master.conf || _failed=true if ! $_failed ; then @@ -3604,7 +3892,7 @@ fi ## - quota = $db_driver:/usr/local/dovecot/etc/dovecot/sql-dict.conf.ext ## - } _failed=false -echononl "\tAdjust file dovecot.conf for (dict) quota service" +echononl " Adjust file dovecot.conf for (dict) quota service" perl -i -n -p -e "s#^([ ]*)(dict\ +{.*)#\1\2\n\1 quota = $db_driver:/usr/local/dovecot/etc/dovecot/sql-dict.conf.ext#g" \ /usr/local/dovecot-${_version}/etc/dovecot/dovecot.conf || _failed=true if ! $_failed ; then @@ -3619,7 +3907,7 @@ if $_new ; then if [ "$db_driver" = "pgsql" ]; then - echononl "\tCreate table quota2 in database \"$dbname\".." + echononl " Create table quota2 in database \"$dbname\".." cat << EOF | psql -U$dbuser $dbname > /dev/null 2>&1 CREATE TABLE IF NOT EXISTS quota2 ( username varchar(100) not null, @@ -3635,7 +3923,7 @@ EOF error "Creating table quota2 in database \"$dbname\" failed" fi - echononl "\tCreate Trigger mergequota2.." + echononl " Create Trigger mergequota2.." cat << EOF | psql -U$dbuser $dbname > /dev/null 2>&1 CREATE PROCEDURAL LANGUAGE plpgsql; @@ -3687,7 +3975,7 @@ EOF fi elif [ "$db_driver" = "mysql" ]; then - echononl "\tCreate table quota2 in database \"$dbname\".." + echononl " Create table quota2 in database \"$dbname\".." cat << EOF | mysql -u$dbuser -p$dbpassword $dbname > /dev/null 2>&1 CREATE TABLE IF NOT EXISTS quota2 ( username varchar(100) not null, @@ -3707,7 +3995,7 @@ EOF fi _failed=false -echononl "\tRenew file sql-dict.conf.ext" +echononl " Renew file sql-dict.conf.ext" if [ "$db_driver" = "pgsql" ]; then cat </usr/local/dovecot-${_version}/etc/dovecot/sql-dict.conf.ext @@ -3851,7 +4139,7 @@ EOF ## - "/usr/local/dovecot/etc/dovecot/sql-connect.conf.ext" to ## - support extra variable "quota_rule" ## - - echononl "\tRenew file sql-connect.conf.ext" + echononl " Renew file sql-connect.conf.ext" cat < /usr/local/dovecot-${_version}/etc/dovecot/sql-connect.conf.ext driver = $db_driver ## - if using unix-socket (host=/run/postgresql) ensure that @@ -3948,7 +4236,7 @@ EOF ## - "/usr/local/dovecot/etc/dovecot/sql-connect.conf.ext" to ## - support extra variable "quota_rule" ## - - echononl "\tRenew file sql-connect.conf.ext" + echononl " Renew file sql-connect.conf.ext" cat < /usr/local/dovecot-${_version}/etc/dovecot/sql-connect.conf.ext driver = $db_driver connect = host=$dbhost user=$dbuser password=$dbpassword dbname=$dbname @@ -3978,7 +4266,7 @@ fi ## - configure stats service (10-master.conf) ## - -echononl "\tConfigure stats service (10-master.conf)" +echononl " Configure stats service (10-master.conf)" cat <> /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-master.conf service stats { @@ -4015,7 +4303,7 @@ fi ## - ## - see also: https://wiki.dovecot.org/PostLoginScripting ## - -echononl "\tAdd script '/usr/local/dovecot-${_version}/bin/post-login.sh'.." +echononl " Add script '/usr/local/dovecot-${_version}/bin/post-login.sh'.." cat < /usr/local/dovecot-${_version}/bin/post-login.sh #!/usr/bin/env bash @@ -4030,7 +4318,7 @@ else echo -e "$rc_done" fi -echononl "\tSet Permissions of 'post-login.sh' .." +echononl " Set Permissions of 'post-login.sh' .." chmod 755 "/usr/local/dovecot-${_version}/bin/post-login.sh" > /dev/null 2>&1 if [[ $? -gt 0 ]] ; then echo -e "$rc_failed" @@ -4039,66 +4327,132 @@ else echo -e "$rc_done" fi + +# Configure post-login service (10-master.conf) +# _failed=false -echononl "\tConfigure post-login service (10-master.conf)" -perl -i -n -p -e "s#^(\s*)(service\s+imap\s+{.*)#\1\2\n\1 \# tell imap to do post-login lookup using a socket called \"imap-postlogin\"\n\1 executable = imap post-login\n#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-master.conf || _failed=true -perl -i -n -p -e "s#^(\s*)(service\s+pop3\s+{.*)#\1\2\n\1 \# tell imap to do post-login lookup using a socket called \"imap-postlogin\"\n\1 executable = pop3 post-login\n#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-master.conf || _failed=true -cat <> /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-master.conf +if [[ $dovecot_major_version -gt 2 ]] \ + || ( [[ $dovecot_major_version -eq 2 ]] && [[ $dovecot_minor_version -gt 3 ]] ); then + + echononl " Configure post-login service (10-master.conf).." + + _master_conf_file="/usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-master.conf" + + _service_imap_block="service imap {\n # tell imap to do post-login lookup using a socket called \"imap-postlogin\"\n executable = imap post-login\n}" + _service_pop3_block="service pop3 {\n # tell pop3 to do post-login lookup using a socket called \"pop3-postlogin\"\n executable = imap post-login\n}" + + if grep -qE '^\s*service\s+imap\s*{' "${_master_conf_file}"; then + sed -i "/^\s*service\s+imap\s*{/,/^}/c\ + ${_service_imap_block}" ${_master_conf_file} || _failed=true + else + cat <> "${_master_conf_file}" || _failed=true + +$(echo -e "${_service_imap_block}") +EOF + fi + + + if grep -qE '^\s*service\s+pop3\s*{' "${_master_conf_file}"; then + sed -i "/^\s*service\s+pop3\s*{/,/^}/c\ + ${_service_pop3_block}" ${_master_conf_file} || _failed=true + else + cat <> "${_master_conf_file}" || _failed=true + +$(echo -e "${_service_pop3_block}") +EOF + fi + + if ! $_failed ; then + echo -e "$rc_done" + else + echo -e "$rc_failed" + error "Configure post-login service (10-master.conf) failed" + + echo "" + 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 "Interupted by user" + + fi + +else + + echononl " Configure post-login service (10-master.conf)" + perl -i -n -p -e "s#^(\s*)(service\s+imap\s+{.*)#\1\2\n\1 \# tell imap to do post-login lookup using a socket called \"imap-postlogin\"\n\1 executable = imap post-login\n#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-master.conf || _failed=true + perl -i -n -p -e "s#^(\s*)(service\s+pop3\s+{.*)#\1\2\n\1 \# tell imap to do post-login lookup using a socket called \"imap-postlogin\"\n\1 executable = pop3 post-login\n#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-master.conf || _failed=true + cat <> /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-master.conf service post-login { - # all post-login scripts are executed via script-login binary - executable = script-login /usr/local/dovecot/bin/post-login.sh +# all post-login scripts are executed via script-login binary +executable = script-login /usr/local/dovecot/bin/post-login.sh - # the script process runs as the user specified here: - user = vmail +# the script process runs as the user specified here: +user = vmail - # this UNIX socket listener must use the same name as given to imap executable - unix_listener post-login { - } +# this UNIX socket listener must use the same name as given to imap executable +unix_listener post-login { +} } EOF -if [[ $? -gt 0 ]] ; then - _failed=true -fi + if [[ $? -gt 0 ]] ; then + _failed=true + fi + + if ! $_failed ; then + echo -e "$rc_done" + else + echo -e "$rc_failed" + fatal "Configuring 'post-login' service failed!" + fi + +fi # Configure post-login service (10-master.conf) + + +# edit /usr/local/dovecot/etc/dovecot/conf.d/90-quota.conf +# +if [[ $dovecot_major_version -gt 2 ]] \ + || ( [[ $dovecot_major_version -eq 2 ]] && [[ $dovecot_minor_version -gt 3 ]] ); then + + echononl " Adjust file '90-quota.conf'.." + echo -e "$rc_skipped" -if ! $_failed ; then - echo -e "$rc_done" else - echo -e "$rc_failed" - fatal "Configuring 'post-login' service failed!" -fi - -## - edit /usr/local/dovecot/etc/dovecot/conf.d/90-quota.conf -## - -## - add to the end of file or in seperate plugin-blocks -## - as designed in that file: -## - plugin { -## - # sql backend: -## - quota = dict:user quota::proxy::quota -## - -## - quota_rule = *:storage=1g -## - quota_rule2 = trash:storage=+100m -## - -## - quota_warning = storage=80%% quota-warning 80 %u -## - quota_warning2 = storage=95%% quota-warning 95 %u -## - } -## - -## - service quota-warning { -## - executable = script /usr/local/bin/quota-warning.sh -## - user = vmail -## - unix_listener quota-warning { -## - user = vmail -## - mode = 0666 -## - } -## - } -## - -echononl "\tAdjust file 90-quota.conf" -cp -a /usr/local/dovecot-${_version}/etc/dovecot/conf.d/90-quota.conf \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/90-quota.conf.ORIG -cat <>/usr/local/dovecot-${_version}/etc/dovecot/conf.d/90-quota.conf + ## - edit /usr/local/dovecot/etc/dovecot/conf.d/90-quota.conf + ## - + ## - add to the end of file or in seperate plugin-blocks + ## - as designed in that file: + ## - plugin { + ## - # sql backend: + ## - quota = dict:user quota::proxy::quota + ## - + ## - quota_rule = *:storage=1g + ## - quota_rule2 = trash:storage=+100m + ## - + ## - quota_warning = storage=80%% quota-warning 80 %u + ## - quota_warning2 = storage=95%% quota-warning 95 %u + ## - } + ## - + ## - service quota-warning { + ## - executable = script /usr/local/bin/quota-warning.sh + ## - user = vmail + ## - unix_listener quota-warning { + ## - user = vmail + ## - mode = 0666 + ## - } + ## - } + ## - + echononl " Adjust file 90-quota.conf" + cp -a /usr/local/dovecot-${_version}/etc/dovecot/conf.d/90-quota.conf \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/90-quota.conf.ORIG + cat <>/usr/local/dovecot-${_version}/etc/dovecot/conf.d/90-quota.conf ## - plugin { @@ -4121,17 +4475,19 @@ service quota-warning { } } EOF -if [ "$?" = 0 ]; then - echo -e "$rc_done" -else - echo -e "$rc_failed" - fatal "Adjusting file /usr/local/dovecot-${_version}/etc/dovecot/conf.d/90-quota.conf failed" -fi + if [ "$?" = 0 ]; then + echo -e "$rc_done" + else + echo -e "$rc_failed" + fatal "Adjusting file /usr/local/dovecot-${_version}/etc/dovecot/conf.d/90-quota.conf failed" + fi + +fi # edit /usr/local/dovecot/etc/dovecot/conf.d/90-quota.conf if $_new ; then - echononl "\tCreate quota warning script.." + echononl " Create quota warning script.." ## - create the user-warning script ## - cat </usr/local/bin/quota-warning.sh @@ -4204,91 +4560,120 @@ fi ## - -## - edit /usr/local/dovecot/etc/dovecot/conf.d/10-mail.conf -## - -## - Add namespaces type shared to 10-mail.conf -## - Take care to enable ACL plugin also, otherwise all users can access all the shared -## - mailboxes, assuming they have permissions on filesystem level to do so. -## - we will do that later.. -## - namespace { -## - type = shared -## - separator = / -## - prefix = shared/%%u/ -## - location = maildir:/var/vmail/%%d/%%n/Maildir:INDEX=~/Maildir/shared/%%u -## - subscriptions = no -## - list = children -## - } -## - -echononl "\tAdd namespaces type shared to 10-mail.conf" -cat <> /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf +# edit /usr/local/dovecot/etc/dovecot/conf.d/10-mail.conf +# +# Add namespaces type shared to 10-mail.conf +# +if [[ $dovecot_major_version -gt 2 ]] \ + || ( [[ $dovecot_major_version -eq 2 ]] && [[ $dovecot_minor_version -gt 3 ]] ); then + + echononl " Add namespaces type shared to '10-mail.conf'...." + echo -e "$rc_not_yet_implemented" + +else + + ## - edit /usr/local/dovecot/etc/dovecot/conf.d/10-mail.conf + ## - + ## - Add namespaces type shared to 10-mail.conf + ## - Take care to enable ACL plugin also, otherwise all users can access all the shared + ## - mailboxes, assuming they have permissions on filesystem level to do so. + ## - we will do that later.. + ## - namespace { + ## - type = shared + ## - separator = / + ## - prefix = shared/%%u/ + ## - location = maildir:/var/vmail/%%d/%%n/Maildir:INDEX=~/Maildir/shared/%%u + ## - subscriptions = no + ## - list = children + ## - } + ## - + echononl " Add namespaces type shared to 10-mail.conf" + cat <> /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf namespace { - #type = shared - #separator = / - type = shared - separator = / +#type = shared +#separator = / +type = shared +separator = / - # Mailboxes are visible under "shared/user@domain/" - # %%n, %%d and %%u are expanded to the destination user. - #prefix = shared/%%u/ - prefix = shared/%%u/ +# Mailboxes are visible under "shared/user@domain/" +# %%n, %%d and %%u are expanded to the destination user. +#prefix = shared/%%u/ +prefix = shared/%%u/ - # Mail location for other users' mailboxes. Note that %variables and ~/ - # expands to the logged in user's data. %%n, %%d, %%u and %%h expand to the - # destination user's data. - #location = maildir:%%h/Maildir:INDEX=~/Maildir/shared/%%u - location = maildir:/var/vmail/%%d/%%n/Maildir:INDEX=~/Maildir/shared/%%u +# Mail location for other users' mailboxes. Note that %variables and ~/ +# expands to the logged in user's data. %%n, %%d, %%u and %%h expand to the +# destination user's data. +#location = maildir:%%h/Maildir:INDEX=~/Maildir/shared/%%u +location = maildir:/var/vmail/%%d/%%n/Maildir:INDEX=~/Maildir/shared/%%u - # Use the default namespace for saving subscriptions. - subscriptions = no +# Use the default namespace for saving subscriptions. +subscriptions = no - # List the shared/ namespace only if there are visible shared mailboxes. - list = children +# List the shared/ namespace only if there are visible shared mailboxes. +list = children } EOF -if [ "$?" = 0 ]; then - echo -e "$rc_done" -else - echo -e "$rc_failed" - fatal "Adding namespaces to /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf failed" -fi + if [ "$?" = 0 ]; then + echo -e "$rc_done" + else + echo -e "$rc_failed" + fatal "Adding namespaces to /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf failed" + fi -## - edit /usr/local/dovecot/etc/dovecot/conf.d/20-imap.conf -## - -## - mail_plugins = $mail_plugins imap_quota imap_acl -## - +fi # edit /usr/local/dovecot/etc/dovecot/conf.d/10-mail.conf + + +# edit /usr/local/dovecot/etc/dovecot/conf.d/20-imap.conf +# +# mail_plugins = $mail_plugins imap_quota imap_acl +# _failed=false -echononl "\tAdd mail_plugin imap_acl to 20-imap.conf" -perl -i -n -p -e "s#^([ ]*)\#?\ ?(mail_plugins\ +=.*)#\1\#\# \2\n\1mail_plugins = \\\$mail_plugins imap_quota imap_acl#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-imap.conf || _failed=true -if ! $_failed ; then - echo -e "$rc_done" -else - echo -e "$rc_failed" - fatal "Adjusting file /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-imap.conf failed" -fi +if [[ $dovecot_major_version -gt 2 ]] \ + || ( [[ $dovecot_major_version -eq 2 ]] && [[ $dovecot_minor_version -gt 3 ]] ); then -## - edit /usr/local/dovecot/etc/dovecot/conf.d/10-mail.conf -## - -## - mail_plugins = quota expire acl -## - -_failed=false -echononl "\tAdd mail_plugin acl to 10-mail.conf" + echononl " Add mail_plugin imap_acl to '20-imap.conf'.." + echo -e "$rc_not_yet_implemented" -if $plugin_expire ; then - perl -i -n -p -e "s#^([ ]*)\#?\ ?(mail_plugins\ +=.*)#\1\#\# \2\n\1mail_plugins = quota expire acl#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf || _failed=true else - perl -i -n -p -e "s#^([ ]*)\#?\ ?(mail_plugins\ +=.*)#\1\#\# \2\n\1mail_plugins = quota acl#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf || _failed=true -fi -if ! $_failed ; then - echo -e "$rc_done" -else - echo -e "$rc_failed" - fatal "Adjusting file /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf failed" -fi + ## - edit /usr/local/dovecot/etc/dovecot/conf.d/20-imap.conf + ## - + ## - mail_plugins = $mail_plugins imap_quota imap_acl + ## - + echononl " Add mail_plugin imap_acl to 20-imap.conf" + perl -i -n -p -e "s#^([ ]*)\#?\ ?(mail_plugins\ +=.*)#\1\#\# \2\n\1mail_plugins = \\\$mail_plugins imap_quota imap_acl#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-imap.conf || _failed=true + if ! $_failed ; then + echo -e "$rc_done" + else + echo -e "$rc_failed" + fatal "Adjusting file /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-imap.conf failed" + fi + + ## - edit /usr/local/dovecot/etc/dovecot/conf.d/10-mail.conf + ## - + ## - mail_plugins = quota expire acl + ## - + _failed=false + echononl " Add mail_plugin acl to 10-mail.conf" + + if $plugin_expire ; then + perl -i -n -p -e "s#^([ ]*)\#?\ ?(mail_plugins\ +=.*)#\1\#\# \2\n\1mail_plugins = quota expire acl#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf || _failed=true + else + perl -i -n -p -e "s#^([ ]*)\#?\ ?(mail_plugins\ +=.*)#\1\#\# \2\n\1mail_plugins = quota acl#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf || _failed=true + fi + + if ! $_failed ; then + echo -e "$rc_done" + else + echo -e "$rc_failed" + fatal "Adjusting file /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf failed" + fi + +fi # edit /usr/local/dovecot/etc/dovecot/conf.d/20-imap.conf ## - !! Notice !! @@ -4332,56 +4717,71 @@ fi ## - Using SQL dictionary ## - -## - edit /usr/local/dovecot/etc/dovecot/conf.d/90-acl.conf -## - -## - plugin { -## - ## acl = vfile:/etc/dovecot/global-acls:cache_secs=300 -## - -## - # Without global ACLs: -## - acl = vfile -## - .. -## - } -## - plugin { -## - acl_shared_dict = proxy::acl -## - } -## - -_failed=false -echononl "\tConfigure acl (90-acl.conf)" -perl -i.ORIG -n -p -e "s#^([ ]*)\#?\ ?(acl\ +=.*)#\1\#\# \2\n\n\1\# Without global ACLs:\n\1acl = vfile\n\n\1\# With global ACLs in /etc/dovecot/acls/ directory:\n\1\#acl = vfile:/etc/dovecot/acls\n\1\#acl = vfile:/etc/dovecot/acls:cache_secs=300#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/90-acl.conf || _failed=true -perl -i -n -p -e "s#^([ ]*)\#?\ ?(acl_shared_dict\ +=.*)#\1\#\# \2\n\1acl_shared_dict = proxy::acl#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/90-acl.conf || _failed=true -if ! $_failed ; then - echo -e "$rc_done" -else - echo -e "$rc_failed" - fatal "Adjusting file /usr/local/dovecot-${_version}/etc/dovecot/conf.d/90-acl.conf failed" -fi -## - edit /usr/local/dovecot/etc/dovecot/dovecot.conf -## - -## - dict { -## - acl = $db_driver:/usr/local/dovecot/etc/dovecot/sql-dict.conf.ext -## - ... -## - } -## - +# edit /usr/local/dovecot/etc/dovecot/conf.d/90-acl.conf +# _failed=false -echononl "\tAdjust file dovecot.conf for (dict) acl service" -perl -i -n -p -e "s#^([ ]*)(dict\ +{.*)#\1\2\n\1 acl = $db_driver:/usr/local/dovecot/etc/dovecot/sql-dict.conf.ext#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/dovecot.conf || _failed=true -if ! $_failed ; then - echo -e "$rc_done" +if [[ $dovecot_major_version -gt 2 ]] \ + || ( [[ $dovecot_major_version -eq 2 ]] && [[ $dovecot_minor_version -gt 3 ]] ); then + + echononl " Configure acl - file '90-acl.conf'.." + echo -e "$rc_not_yet_implemented" + else - echo -e "$rc_failed" - fatal "Adjusting file /usr/local/dovecot-${_version}/etc/dovecot/dovecot.conf failed" -fi + + ## - edit /usr/local/dovecot/etc/dovecot/conf.d/90-acl.conf + ## - + ## - plugin { + ## - ## acl = vfile:/etc/dovecot/global-acls:cache_secs=300 + ## - + ## - # Without global ACLs: + ## - acl = vfile + ## - .. + ## - } + ## - plugin { + ## - acl_shared_dict = proxy::acl + ## - } + ## - + _failed=false + echononl " Configure acl (90-acl.conf)" + perl -i.ORIG -n -p -e "s#^([ ]*)\#?\ ?(acl\ +=.*)#\1\#\# \2\n\n\1\# Without global ACLs:\n\1acl = vfile\n\n\1\# With global ACLs in /etc/dovecot/acls/ directory:\n\1\#acl = vfile:/etc/dovecot/acls\n\1\#acl = vfile:/etc/dovecot/acls:cache_secs=300#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/90-acl.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)\#?\ ?(acl_shared_dict\ +=.*)#\1\#\# \2\n\1acl_shared_dict = proxy::acl#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/90-acl.conf || _failed=true + if ! $_failed ; then + echo -e "$rc_done" + else + echo -e "$rc_failed" + fatal "Adjusting file /usr/local/dovecot-${_version}/etc/dovecot/conf.d/90-acl.conf failed" + fi + + ## - edit /usr/local/dovecot/etc/dovecot/dovecot.conf + ## - + ## - dict { + ## - acl = $db_driver:/usr/local/dovecot/etc/dovecot/sql-dict.conf.ext + ## - ... + ## - } + ## - + _failed=false + echononl " Adjust file dovecot.conf for (dict) acl service" + perl -i -n -p -e "s#^([ ]*)(dict\ +{.*)#\1\2\n\1 acl = $db_driver:/usr/local/dovecot/etc/dovecot/sql-dict.conf.ext#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/dovecot.conf || _failed=true + if ! $_failed ; then + echo -e "$rc_done" + else + echo -e "$rc_failed" + fatal "Adjusting file /usr/local/dovecot-${_version}/etc/dovecot/dovecot.conf failed" + fi + +fi # edit /usr/local/dovecot/etc/dovecot/conf.d/90-acl.conf + if $_new ; then if [ "$db_driver" = "pgsql" ]; then ## - Create tables user_shares / anyone_shares ## - - echononl "\tCreate table user_share" + echononl " Create table user_share" cat << EOF | psql -U$dbuser $dbname > /dev/null 2>&1 CREATE TABLE IF NOT EXISTS user_shares ( from_user varchar(100) not null, @@ -4398,7 +4798,7 @@ EOF error "Creating table user_shares failed" fi - echononl "\tCreate table anyone_shares" + echononl " Create table anyone_shares" cat << EOF | psql -U$dbuser $dbname > /dev/null 2>&1 CREATE TABLE IF NOT EXISTS anyone_shares ( from_user varchar(100) not null, @@ -4418,7 +4818,7 @@ EOF ## - Create table user_shares / anyone_shares ## - - echononl "\tCreate table user_share" + echononl " Create table user_share" cat << EOF | mysql -u$dbuser -p$dbpassword $dbname > /dev/null 2>&1 CREATE TABLE IF NOT EXISTS user_shares ( from_user varchar(100) not null, @@ -4434,7 +4834,7 @@ EOF error "Creating table user_shares failed" fi - echononl "\tCreate table anyone_shares" + echononl " Create table anyone_shares" cat << EOF | mysql -u$dbuser -p$dbpassword $dbname > /dev/null 2>&1 CREATE TABLE IF NOT EXISTS anyone_shares ( from_user varchar(100) not null, @@ -4453,7 +4853,7 @@ fi _failed=false -echononl "\tRenew file sql-dict.conf.ext" +echononl " Renew file sql-dict.conf.ext" if [ "$db_driver" = "pgsql" ]; then ## - adjust/renew file /usr/local/dovecot/etc/dovecot/sql-dict.conf.ext @@ -4758,46 +5158,60 @@ fi ## ----------------- ## --- Configure managesieve support for dovecot -## - edit /usr/local/dovecot/etc/dovecot/conf.d/20-managesieve.conf -## - -## - service managesieve-login { -## - inet_listener sieve { -## - #address = 127.0.0.1 $ipv4 $ipv6 -## - address = 127.0.0.1 -## - port = 4190 -## - } -## - .. -## - } -## - -_failed=false -echononl "\tConfigure managesieve 20-managesieve.conf" -perl -i.ORIG -n -p -e "s#^([ ]*)\#?\ ?(service managesieve-login\ +{.*)#\1service managesieve-login {#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-managesieve.conf || _failed=true -if [[ -n "$ipv6" ]]; then - perl -i -n -p -e "s#^([ ]*)\#?\ ?(inet_listener\ +sieve\ +{.*)#\1inet_listener sieve {\n\1 \#address = 127.0.0.1 $ipv4 $ipv6\n\1 address = 127.0.0.1\n\1 port = 4190\n\1}\n\1\#\# \2#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-managesieve.conf || _failed=true -else - perl -i -n -p -e "s#^([ ]*)\#?\ ?(inet_listener\ +sieve\ +{.*)#\1inet_listener sieve {\n\1 \#address = 127.0.0.1 $ipv4\n\1 address = 127.0.0.1\n\1 port = 4190\n\1}\n\1\#\# \2#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-managesieve.conf || _failed=true -fi -perl -i -n -p -e "s#^([ ]*\#?\ ?vsz_limit.*)#\1\n}#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-managesieve.conf || _failed=true -perl -i -n -p -e "s#^([ ]*)\#?\ ?(service managesieve\ +{.*)#\1service managesieve {#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-managesieve.conf || _failed=true - -# since divecot 2.2.4: process_count changed to process_limit. +# edit /usr/local/dovecot/etc/dovecot/conf.d/20-managesieve.conf # -#perl -i -n -p -e "s#^([ ]*\#?\ ?process_count.*)#\1\n}#g" \ -# /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-managesieve.conf || _failed=true -perl -i -n -p -e "s#^([ ]*\#?\ ?process_limit.*)#\1\n}#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-managesieve.conf || _failed=true +_failed=false +if [[ $dovecot_major_version -gt 2 ]] \ + || ( [[ $dovecot_major_version -eq 2 ]] && [[ $dovecot_minor_version -gt 3 ]] ); then + + echononl " Configure managesieve '20-managesieve.conf'.." + echo -e "$rc_not_yet_implemented" -if ! $_failed ; then - echo -e "$rc_done" else - echo -e "$rc_failed" - fatal "Adjusting file /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-managesieve.conf failed" -fi + + ## - edit /usr/local/dovecot/etc/dovecot/conf.d/20-managesieve.conf + ## - + ## - service managesieve-login { + ## - inet_listener sieve { + ## - #address = 127.0.0.1 $ipv4 $ipv6 + ## - address = 127.0.0.1 + ## - port = 4190 + ## - } + ## - .. + ## - } + ## - + + echononl " Configure managesieve '20-managesieve.conf'.." + perl -i.ORIG -n -p -e "s#^([ ]*)\#?\ ?(service managesieve-login\ +{.*)#\1service managesieve-login {#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-managesieve.conf || _failed=true + if [[ -n "$ipv6" ]]; then + perl -i -n -p -e "s#^([ ]*)\#?\ ?(inet_listener\ +sieve\ +{.*)#\1inet_listener sieve {\n\1 \#address = 127.0.0.1 $ipv4 $ipv6\n\1 address = 127.0.0.1\n\1 port = 4190\n\1}\n\1\#\# \2#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-managesieve.conf || _failed=true + else + perl -i -n -p -e "s#^([ ]*)\#?\ ?(inet_listener\ +sieve\ +{.*)#\1inet_listener sieve {\n\1 \#address = 127.0.0.1 $ipv4\n\1 address = 127.0.0.1\n\1 port = 4190\n\1}\n\1\#\# \2#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-managesieve.conf || _failed=true + fi + perl -i -n -p -e "s#^([ ]*\#?\ ?vsz_limit.*)#\1\n}#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-managesieve.conf || _failed=true + perl -i -n -p -e "s#^([ ]*)\#?\ ?(service managesieve\ +{.*)#\1service managesieve {#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-managesieve.conf || _failed=true + + # since divecot 2.2.4: process_count changed to process_limit. + # + #perl -i -n -p -e "s#^([ ]*\#?\ ?process_count.*)#\1\n}#g" \ + # /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-managesieve.conf || _failed=true + perl -i -n -p -e "s#^([ ]*\#?\ ?process_limit.*)#\1\n}#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-managesieve.conf || _failed=true + + if ! $_failed ; then + echo -e "$rc_done" + else + echo -e "$rc_failed" + fatal "Adjusting file /usr/local/dovecot-${_version}/etc/dovecot/conf.d/20-managesieve.conf failed" + fi + +fi # edit /usr/local/dovecot/etc/dovecot/conf.d/20-managesieve.conf + #_set_link="" #echo @@ -4805,7 +5219,7 @@ fi #echo -e -n " /usr/local/dovecot --> dovecot-${_version} /usr/local/dovecot? [y/n]: " #read _set_link #if [ "y" = "$_set_link" -o "Y" = "$_set_link" -o "Yes" = "$_set_link" -o "yes" = "$_set_link" ];then -# echononl "\tCreate symlink.." +# echononl " Create symlink.." # rm -f /usr/local/dovecot # ln -s dovecot-${_version} /usr/local/dovecot # if [ "$?" = 0 ]; then @@ -4819,7 +5233,7 @@ fi ## - Add a cronjob to check if certifice/key for dovecot service is-up-to-date ## - -echononl "\tCreate cronjob for checking if certifice/key for dovecot service is-up-to-date" +echononl " Create cronjob for checking if certifice/key for dovecot service is-up-to-date" if [[ -f "$_backup_crontab_file" ]] ; then @@ -4857,7 +5271,7 @@ else fi -echononl "\tRun script 'check_cert_for_dovecot.sh' if possible.." +echononl " Run script 'check_cert_for_dovecot.sh' if possible.." if [[ -x "/root/bin/monitoring/check_cert_for_dovecot.sh" ]] ; then /root/bin/monitoring/check_cert_for_dovecot.sh > $log_file 2>&1 if [ "$?" = 0 ]; then @@ -4866,7 +5280,7 @@ if [[ -x "/root/bin/monitoring/check_cert_for_dovecot.sh" ]] ; then echo -e "$rc_failed" error "$(cat "$log_file")" - echononl "\tcontinue anyway [yes/no]: " + echononl " continue anyway [yes/no]: " read OK OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do @@ -4882,7 +5296,7 @@ fi blank_line -echononl "\tCreate symlink '/usr/local/dovecot' --> 'dovecot-${_version}'.." +echononl " Create symlink '/usr/local/dovecot' --> 'dovecot-${_version}'.." rm -f /usr/local/dovecot ln -s dovecot-${_version} /usr/local/dovecot if [ "$?" = 0 ]; then @@ -4897,7 +5311,7 @@ fi #echo -e -n "Start/Restart services (dovecot/postfix)? [y/n]: " #read _restart #if [ "y" = "$_restart" -o "Y" = "$_restart" -o "Yes" = "$_restart" -o "yes" = "$_restart" ];then -# echononl "\tStart dovecot service.." +# echononl " Start dovecot service.." # if $systemd_support ; then # systemctl start dovecot # else @@ -4909,7 +5323,7 @@ fi # echo -e "$rc_failed" # error "Starting dovecot service failed" # fi -# echononl "\tRestart postfix.." +# echononl " Restart postfix.." # if $SYSTEMD_EXISTS ; then # systemctl restart postfix # else @@ -4923,7 +5337,7 @@ fi # fi #fi -echononl "\tStart dovecot service.." +echononl " Start dovecot service.." if $systemd_support ; then systemctl start dovecot else @@ -4935,7 +5349,7 @@ else echo -e "$rc_failed" error "Starting dovecot service failed" fi -echononl "\tRestart postfix.." +echononl " Restart postfix.." if $SYSTEMD_EXISTS ; then systemctl restart postfix else @@ -4949,7 +5363,7 @@ else fi blank_line -echononl "\tSet '_update=true' in file '$(basename "$conf_file")'.." +echononl " Set '_update=true' in file '$(basename "$conf_file")'.." if grep -q -E "^\s*_update=false" "$conf_file" 2> /dev/null ; then perl -i -n -p -e "s/^\s*_update=.*/_update=true/" "$conf_file" if [ "$?" = 0 ]; then