diff --git a/install_update_dovecot.sh b/install_update_dovecot.sh index 86d547d..3419530 100755 --- a/install_update_dovecot.sh +++ b/install_update_dovecot.sh @@ -2524,6 +2524,7 @@ else fatal "Adjusting file /usr/local/dovecot-${_version}/etc/dovecot/conf.d/10-master.conf failed" fi + ## - edit /usr/local/dovecot/etc/dovecot/dovecot.conf ## - ## - add: @@ -2877,6 +2878,66 @@ EOF fi +## - configure post-login service (10-master.conf) +## - +## - see also: https://wiki.dovecot.org/PostLoginScripting +## - +echononl "\tAdd script '/usr/local/dovecot-${_version}/bin/post-login.sh'.." +cat < /usr/local/dovecot-${_version}/bin/post-login.sh +#!/usr/bin/env bash + +touch ~/.last_login + +exec "\$@" +EOF +if [[ $? -gt 0 ]] ; then + echo -e "$rc_failed" + error "Adding script '/usr/local/dovecot-${_version}/bin/post-login.sh' failed!" +else + echo -e "$rc_done" +fi + +echononl "\tSet 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" + error "Setting permissions to '/usr/local/dovecot-${_version}/bin/post-login.sh' failed!" +else + echo -e "$rc_done" +fi + +_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 + +service post-login { + # 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 + + # 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 ! $_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