Date: Sat, 29 Nov 2008 07:59:34 GMT From: Darren Pilgrim <phi@evilphi.com> To: freebsd-gnats-submit@FreeBSD.org Subject: ports/129274: [mail/dovecot] Patch to dovecot.sh.in to facilitate multi-instance configurations Message-ID: <200811290759.mAT7xYob020193@www.freebsd.org> Resent-Message-ID: <200811290800.mAT80G0n037595@freefall.freebsd.org>
next in thread | raw e-mail | index | archive | help
>Number: 129274 >Category: ports >Synopsis: [mail/dovecot] Patch to dovecot.sh.in to facilitate multi-instance configurations >Confidential: no >Severity: non-critical >Priority: medium >Responsible: freebsd-ports-bugs >State: open >Quarter: >Keywords: >Date-Required: >Class: change-request >Submitter-Id: current-users >Arrival-Date: Sat Nov 29 08:00:16 UTC 2008 >Closed-Date: >Last-Modified: >Originator: Darren Pilgrim >Release: RELENG_6_3, RELENG_7 >Organization: >Environment: n/a >Description: Dovecot requires multiple instances with separate configuration files if your configuration requires differing settings across multiple addresses/ports. This isn't an uncommon requirement (i.e., a single server with secure services via more than one hostname requires more than one SSL certificate; however, Dovecot only permits one SSL certificate per configuration). Making copies of the current RC script and editting them to run the extra configurations creates the following problems: - Port upgrades will not stop all running Dovecot instances prior to the deinstall/reinstall phase; - Port upgrades that change the RC script result in outdated/broken RC scripts; - Port deinstalls result in orphaned files; >How-To-Repeat: n/a >Fix: The provided patch to dovecot.sh.in introduces the dovecot_extra_configs variable which specifies the configuration files of additional instances. When dovecot_extra_configs is defined, the script iterates over dovecot_config and each extra config, starting, stopping or restarting each in turn. The single-instance behavior (dovecot_extra_configs is empty) is the same as the current script. I received no response from the maintainer to my original inquiry on 2008-11-11 about the issue of controlling multiple Dovecot instances. Patch attached with submission follows: --- /usr/ports/mail/dovecot/files/dovecot.sh.in 2008-11-28 10:49:23.000000000 -0800 +++ dovecot.sh.in.new 2008-11-28 23:24:09.000000000 -0800 @@ -20,23 +20,27 @@ # read configuration and set defaults load_rc_config ${name} : ${dovecot_enable:="NO"} +: ${dovecot_config:="/usr/local/etc/dovecot.conf"} +: ${dovecot_extra_configs:=""} command="%%PREFIX%%/sbin/${name}" -command_args="-c ${dovecot_config:="%%PREFIX%%/etc/${name}.conf"}" -required_files="${dovecot_config}" +required_files="${dovecot_config} ${dovecot_extra_configs}" +restart_cmd="restart_cmd" start_precmd="start_precmd" stop_postcmd="stop_postcmd" extra_commands="restart" -base_dir=$(${command} ${command_args} -a | /usr/bin/awk -F ': ' '/^base_dir:/ { print $2 }') -login_dir=$(${command} ${command_args} -a | /usr/bin/awk -F ': ' '/^login_dir:/ { print $2 }') -login_user=$(${command} ${command_args} -a | /usr/bin/awk -F ': ' '/^login_user:/ { print $2 }') - -pidfile="${base_dir}/master.pid" - +restart_cmd() +{ # Overriding this makes rc.subr run this once for each instance + run_rc_command stop + run_rc_command start +} + start_precmd() { # Ensure runtime directories exist with correct permissions - local gid + local login_dir login_user gid + login_dir=$(${command} ${command_args} -a | /usr/bin/awk -F ': ' '/^login_dir:/ { print $2 }') + login_user=$(${command} ${command_args} -a | /usr/bin/awk -F ': ' '/^login_user:/ { print $2 }') gid=$(/usr/sbin/pw usershow -n "${login_user}" 2>/dev/null | /usr/bin/cut -d: -f4) /usr/bin/install -o root -g wheel -m 0755 -d ${base_dir} /usr/bin/install -o root -g ${gid} -m 0750 -d ${login_dir} @@ -47,4 +51,9 @@ rm -rf ${base_dir} 2>/dev/null } -run_rc_command "$1" +for config in ${dovecot_config} ${dovecot_extra_configs}; do + command_args="-c ${config}" + base_dir=$(${command} ${command_args} -a | /usr/bin/awk -F ': ' '/^base_dir:/ { print $2 }') + pidfile="${base_dir}/master.pid" + run_rc_command "$1" +done >Release-Note: >Audit-Trail: >Unformatted:
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200811290759.mAT7xYob020193>