diff --git a/install_update_dovecot.sh b/install_update_dovecot.sh index 6035547..6606928 100755 --- a/install_update_dovecot.sh +++ b/install_update_dovecot.sh @@ -94,6 +94,12 @@ warn(){ echo "" } +info(){ + echo "" + echo -e "\t[ \033[32m\033[1mInfo\033[m ]: $*" + echo "" +} + blank_line() { echo "" } @@ -196,6 +202,10 @@ fi [[ -n "$max_userip_connections" ]] || max_userip_connections=24 [[ -n "$auth_mechanisms" ]] || auth_mechanisms="plain login" +declare -i dovecot_major_version=0 +declare -i dovecot_minor_version=0 +declare -i dovecot_patch_level=0 + echo -e "\033[32m--\033[m" echo "" echo "Version Number of Dovecot to install" @@ -214,6 +224,39 @@ done dovecot_main_version="$(echo $_version | cut -d '.' -f1,2)" dovecot_major_version="$(echo $_version | cut -d '.' -f1)" dovecot_minor_version="$(echo $_version | cut -d '.' -f2)" +dovecot_patch_level="$(echo $_version | cut -d '.' -f3)" + +#echo "" +#echo "_version: $_version" +#echo "dovecot_main_version $dovecot_main_version" +#echo "dovecot_major_version $dovecot_major_version" +#echo "dovecot_minor_version $dovecot_minor_version" +#echo "dovecot_patch_level $dovecot_patch_level" +#echo "" + +# 'expire plugin'was rRemoved in version 2.3.14: This plugin is not needed. +# Use mailbox { autoexpunge } Mailbox settings instead. +# +if [[ $dovecot_major_version -gt 2 ]] \ + || ( [[ $dovecot_major_version -eq 2 ]] \ + && [[ $dovecot_minor_version -gt 3 ]] \ + ) \ + || ( [[ $dovecot_major_version -eq 2 ]] \ + && [[ $dovecot_minor_version -eq 3 ]] \ + && [[ $dovecot_patch_level -gt 13 ]] \ + ) ; then + plugin_expire=false +else + plugin_expire=true +fi + +#if $plugin_expire ; then +# info "Install plugin 'expire'.." +#else +# warn "Plugin 'expire' is no longer supported.." +#fi + +#exit 0 _log_dir=${_src_base_dir}/log-dovecot-$_version @@ -359,6 +402,8 @@ if $xmpp_listener ; then echo -e "\t AUTH Listener PORT.........: $xmpp_listener_port" fi echo "" +echo -e "\tInstall Plugin 'expire'.......: $plugin_expire" +echo "" if ! $update ;then if [[ "$database" = "psql" ]] || [[ "$database" = "postgres" ]]; then @@ -479,6 +524,16 @@ if [[ -d "/usr/local/dovecot-${_version}" ]]; then else echo -e "$rc_failed" error "Cannot Backup (move) directory '${_log_dir}'" + + echononl "Proceed instllation [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + fi else echo -e "$rc_skipped" @@ -491,7 +546,17 @@ if [[ -d "${_src_base_dir}/dovecot-${_version}" ]]; then echo -e "$rc_done" else echo -e "$rc_failed" - fatal "Cannot Backup (move) directory '${_src_base_dir}/dovecot-${_version}'" + error "Cannot Backup (move) directory '${_src_base_dir}/dovecot-${_version}'" + + echononl "Proceed instllation [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + fi else echo -e "$rc_skipped" @@ -904,8 +969,12 @@ perl -i -n -p -e "s#^([ ]*)\#?\ ?(base_dir\ ?=.*)#\1\#\# \2\n\1base_dir = /var/r /usr/local/dovecot-${_version}/etc/dovecot/dovecot.conf || _failed=true perl -i -n -p -e "s#^([ ]*)\#?\ ?(shutdown_clients\ ?=.*)#\1\#\# \2\n\1shutdown_clients = no#g" \ /usr/local/dovecot-${_version}/etc/dovecot/dovecot.conf || _failed=true -perl -i -n -p -e "s#^([ ]*)(dict\ +{.*)#\1\2\n\1 expire = $db_driver:/usr/local/dovecot/etc/dovecot/sql-dict.conf.ext#g" \ - /usr/local/dovecot-${_version}/etc/dovecot/dovecot.conf || _failed=true + +if $plugin_expire ; then + perl -i -n -p \ + -e "s#^([ ]*)(dict\ +{.*)#\1\2\n\1 expire = $db_driver:/usr/local/dovecot/etc/dovecot/sql-dict.conf.ext#g" \ + /usr/local/dovecot-${_version}/etc/dovecot/dovecot.conf || _failed=true +fi if ! $_failed ; then @@ -966,7 +1035,8 @@ if $_new ; then ## - Create table expires in database ${dbname} ## - echononl "\tCreate table expires in database ${dbname}.." - cat << EOF | psql -U$dbuser $dbname > ${_log_dir}/error.log 2>&1 + if $plugin_expire ; then + cat << EOF | psql -U$dbuser $dbname > ${_log_dir}/error.log 2>&1 CREATE TABLE IF NOT EXISTS expires ( username varchar(100) not null, @@ -976,25 +1046,29 @@ CREATE TABLE IF NOT EXISTS expires ( ); EOF - if [ "$?" = 0 ]; then - echo -e "$rc_done" - else - echo -e "$rc_failed" - error "$(cat ${_log_dir}/error.log)" + if [ "$?" = 0 ]; then + echo -e "$rc_done" + else + echo -e "$rc_failed" + error "$(cat ${_log_dir}/error.log)" - echononl "\tcontinue anyway [yes/no]: " - read OK - OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" - while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do - echononl "Wrong entry! - repeat [yes/nno]: " + echononl "\tcontinue anyway [yes/no]: " read OK - done - [[ $OK = "yes" ]] || fatal "Abbruch durch User" + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + fi + else + echo -e "$rc_skipped" fi echononl "\tCreate function merge_expires() / trigger mergeexpires.." - cat << EOF | psql -U$dbuser $dbname > /dev/null 2>&1 + if $plugin_expire ; then + cat << EOF | psql -U$dbuser $dbname > /dev/null 2>&1 CREATE LANGUAGE plpgsql; create or replace function merge_expires() returns trigger as \$\$ @@ -1013,20 +1087,23 @@ create trigger mergeexpires before insert on expires for each row execute procedure merge_expires(); EOF - if [ "$?" = 0 ]; then - echo -e "$rc_done" - else - echo -e "$rc_failed" - error "$(cat ${_log_dir}/error.log)" + if [ "$?" = 0 ]; then + echo -e "$rc_done" + else + echo -e "$rc_failed" + error "$(cat ${_log_dir}/error.log)" - echononl "\tcontinue anyway [yes/no]: " - read OK - OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" - while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do - echononl "Wrong entry! - repeat [yes/nno]: " + echononl "\tcontinue anyway [yes/no]: " read OK - done - [[ $OK = "yes" ]] || fatal "Abbruch durch User" + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + fi + else + echo -e "$rc_skipped" fi elif [ "$db_driver" = "mysql" ]; then @@ -1100,7 +1177,8 @@ EOF ## - Create table expires in database ${dbname} ## - echononl "\tCreate table expires in database ${dbname}.." - cat << EOF | mysql -u$dbuser -p$dbpassword $dbname > /dev/null 2>&1 + if $plugin_expire ; then + cat << EOF | mysql -u$dbuser -p$dbpassword $dbname > /dev/null 2>&1 CREATE TABLE IF NOT EXISTS expires ( username varchar(100) not null, @@ -1109,22 +1187,26 @@ CREATE TABLE IF NOT EXISTS expires ( primary key (username, mailbox) ); EOF - if [ "$?" = 0 ]; then - echo -e "$rc_done" + if [ "$?" = 0 ]; then + echo -e "$rc_done" + else + echo -e "$rc_failed" + error "Creating table expires failed" + fi else - echo -e "$rc_failed" - error "Creating table expires failed" + echo -e "$rc_skipped" fi fi fi -if [ "$db_driver" = "pgsql" ]; then +## - create sql-dict.conf.ext file +## - +echononl "\tCreate file sql-dict.conf.ext with plugin 'expire'.." +if $plugin_expire ; then + if [ "$db_driver" = "pgsql" ]; then - ## - create sql-dict.conf.ext file - ## - - echononl "\tCreate file sql-dict.conf.ext" - cat </usr/local/dovecot-${_version}/etc/dovecot/sql-dict.conf.ext + cat </usr/local/dovecot-${_version}/etc/dovecot/sql-dict.conf.ext connect = host=$dbhost user=$dbuser password=$dbpassword dbname=$dbname @@ -1169,19 +1251,19 @@ fields { } EOF - if [ "$?" = 0 ]; then - echo -e "$rc_done" - else - echo -e "$rc_failed" - fatal "Creating file sql-dict.conf.ext failed" - fi + if [ "$?" = 0 ]; then + echo -e "$rc_done" + else + echo -e "$rc_failed" + fatal "Creating file sql-dict.conf.ext failed" + fi -elif [ "$db_driver" = "mysql" ]; then + elif [ "$db_driver" = "mysql" ]; then - ## - create sql-dict.conf.ext file - ## - - echononl "\tCreate file sql-dict.conf.ext" - cat </usr/local/dovecot-${_version}/etc/dovecot/sql-dict.conf.ext + ## - create sql-dict.conf.ext file + ## - + echononl "\tCreate file sql-dict.conf.ext" + cat </usr/local/dovecot-${_version}/etc/dovecot/sql-dict.conf.ext # CREATE TABLE expires ( # username varchar(100) not null, # mailbox varchar(255) not null, @@ -1201,13 +1283,16 @@ fields { } } EOF - if [ "$?" = 0 ]; then - echo -e "$rc_done" - else - echo -e "$rc_failed" - fatal "Creating file sql-dict.conf.ext failed" - fi -fi + if [ "$?" = 0 ]; then + echo -e "$rc_done" + else + echo -e "$rc_failed" + fatal "Creating file sql-dict.conf.ext failed" + fi + fi +else + echo -e "$rc_skipped" +fi ## - edit /usr/local/dovecot/etc/dovecot/conf.d/10-master.conf @@ -1483,7 +1568,9 @@ fi ## - last_valid_gid = 5000 ## - ## - auth_socket_path = /var/run/dovecot/auth-userdb -## - mail_plugins = quota expire +## - mail_plugins = quota | mail_plugins = quota expire +## - +## - mailbox_list_index = yes ## - _failed=false echononl "\tAdjusting file 10-mail.conf" @@ -1505,7 +1592,17 @@ perl -i -n -p -e "s#^([ ]*)\#?\ ?(last_valid_gid.*)#\1\#\# \2\n\1last_valid_gid /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 = /var/run/dovecot/auth-userdb#g" \ /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf || _failed=true -perl -i -n -p -e "s#^([ ]*)\#?\ ?(mail_plugins\ +=.*)#\1\#\# \2\n\1mail_plugins = quota expire#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 if ! $_failed ; then @@ -1514,6 +1611,7 @@ else echo -e "$rc_failed" fatal "Adjusting file '10-mail.conf' failed" fi + echononl "\tCreate TEMP directory '/var/vmail/tmp' .." @@ -1576,7 +1674,7 @@ 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.ORIG + /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-mail.conf.TMP if [[ "$?" != "0" ]] ; then _failed=true fi @@ -1699,16 +1797,33 @@ 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 - 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" \ + 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\ +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\ +$spam_folder\ +{.*)#\1\2\n\1 auto = subscribe#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 -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 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" \ @@ -2071,14 +2186,19 @@ fi ## - _failed=false echononl "\tAdjusting file 90-plugin.conf" -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" \ +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" + + 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_failed" - fatal "Adjusting /usr/local/dovecot-${_version}/etc/dovecot/conf.d/90-plugin.conf failed" + echo -e "$rc_skipped" fi @@ -2131,7 +2251,17 @@ if [ "$?" = 0 ]; then echo -e "$rc_done" else echo -e "$rc_failed" - fatal "Creating global sieve script failed" + error "Creating global sieve script failed" + + echononl "\tcontinue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + fi ## - NOTICE: if you pre-compile your (global) scripts, you will increase @@ -2147,6 +2277,16 @@ if [ "$?" = 0 ]; then else echo -e "$rc_failed" error "$(cat $log_file)" + + echononl "\tcontinue anyway [yes/no]: " + read OK + OK="$(echo "$OK" | tr '[:upper:]' '[:lower:]')" + while [[ "$OK" != "yes" ]] && [[ "$OK" != "no" ]] ; do + echononl "Wrong entry! - repeat [yes/nno]: " + read OK + done + [[ $OK = "yes" ]] || fatal "Abbruch durch User" + fi @@ -2562,7 +2702,7 @@ EOF echo "" >> $_crontab_tmp_file echo "# - cleanup spam and trash directories of users'mailboxes" >> $_crontab_tmp_file echo "# -" >> $_crontab_tmp_file - echo "13 3 * * * /usr/local/dovecot/bin/doveadm expunge -A mailbox Trash* savedbefore 1d; /usr/local/dovecot/bin/doveadm expunge -A mailbox ${spam_folder}* savedbefore 30d" >> $_crontab_tmp_file + echo "13 3 * * * /usr/local/dovecot/bin/doveadm expunge -A mailbox Trash* savedbefore 3d; /usr/local/dovecot/bin/doveadm expunge -A mailbox ${spam_folder}* savedbefore 30d" >> $_crontab_tmp_file crontab $_crontab_tmp_file echo -e "$rc_done" else @@ -2840,6 +2980,7 @@ EOF fi +_failed=false echononl "\tRenew file sql-dict.conf.ext" if [ "$db_driver" = "pgsql" ]; then @@ -2920,6 +3061,13 @@ map { username_field = username value_field = messages } +EOF + if [[ "$?" -gt 0 ]]; then + _failed=true + fi + + if $plugin_expire ; then + cat <> /usr/local/dovecot-${_version}/etc/dovecot/sql-dict.conf.ext # CREATE TABLE expires ( # username varchar(100) not null, @@ -2960,7 +3108,13 @@ map { } } EOF - if [ "$?" = 0 ]; then + if [[ "$?" -gt 0 ]]; then + _failed=true + fi + + fi + + if ! $_failed ; then echo -e "$rc_done" else echo -e "$rc_failed" @@ -3025,6 +3179,13 @@ map { username_field = username value_field = messages } +EOF + if [[ "$?" -gt 0 ]]; then + _failed=true + fi + + if $plugin_expire ; then + cat <> /usr/local/dovecot-${_version}/etc/dovecot/sql-dict.conf.ext # CREATE TABLE expires ( # username varchar(100) not null, @@ -3044,7 +3205,13 @@ map { } } EOF - if [ "$?" = 0 ]; then + if [[ "$?" -gt 0 ]]; then + _failed=true + fi + + fi + + if ! $_failed ; then echo -e "$rc_done" else echo -e "$rc_failed" @@ -3381,8 +3548,15 @@ fi ## - _failed=false echononl "\tAdd mail_plugin acl to 10-mail.conf" -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 + +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 @@ -3552,11 +3726,12 @@ EOF fi +_failed=false +echononl "\tRenew file sql-dict.conf.ext" if [ "$db_driver" = "pgsql" ]; then ## - adjust/renew file /usr/local/dovecot/etc/dovecot/sql-dict.conf.ext ## - - echononl "\tRenew file sql-dict.conf.ext" cat </usr/local/dovecot-${_version}/etc/dovecot/sql-dict.conf.ext ## - if using unix-socket (host=/var/run/postgresql) ensure that ## - coresponding entries in pg_hba.cof fits @@ -3642,6 +3817,13 @@ map { username_field = username value_field = messages } +EOF + if [[ "$?" -gt 0 ]]; then + _failed=true + fi + + if $plugin_expire ; then + cat <> /usr/local/dovecot-${_version}/etc/dovecot/sql-dict.conf.ext # CREATE TABLE expires ( # username varchar(100) not null, @@ -3682,6 +3864,12 @@ map { mailbox = \$mailbox } } +EOF + if [[ "$?" -gt 0 ]]; then + _failed=true + fi + fi + cat <> /usr/local/dovecot-${_version}/etc/dovecot/sql-dict.conf.ext # CREATE TABLE user_shares ( @@ -3720,7 +3908,11 @@ map { } } EOF - if [ "$?" = 0 ]; then + if [[ "$?" -gt 0 ]]; then + _failed=true + fi + + if ! $_failed ; then echo -e "$rc_done" else echo -e "$rc_failed" @@ -3731,7 +3923,6 @@ elif [ "$db_driver" = "mysql" ]; then ## - adjust/renew file /usr/local/dovecot/etc/dovecot/sql-dict.conf.ext ## - - echononl "\tRenew file sql-dict.conf.ext" cat </usr/local/dovecot-${_version}/etc/dovecot/sql-dict.conf.ext connect = host=$dbhost user=$dbuser password=$dbpassword dbname=$dbname @@ -3754,6 +3945,13 @@ map { username_field = username value_field = messages } +EOF + if [[ "$?" -gt 0 ]]; then + _failed=true + fi + + if $plugin_expire ; then + cat <> /usr/local/dovecot-${_version}/etc/dovecot/sql-dict.conf.ext # CREATE TABLE expires ( # username varchar(100) not null, @@ -3773,6 +3971,12 @@ map { mailbox = \$mailbox } } +EOF + if [[ "$?" -gt 0 ]]; then + _failed=true + fi + fi + cat <> /usr/local/dovecot-${_version}/etc/dovecot/sql-dict.conf.ext # CREATE TABLE user_shares ( @@ -3809,7 +4013,10 @@ map { } } EOF - if [ "$?" = 0 ]; then + if [[ "$?" -gt 0 ]]; then + _failed=true + fi + if !_failed ; then echo -e "$rc_done" else echo -e "$rc_failed"