From owner-freebsd-ports-bugs@FreeBSD.ORG Sat Nov 29 08:00:16 2008 Return-Path: Delivered-To: freebsd-ports-bugs@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D5D071065675 for ; Sat, 29 Nov 2008 08:00:16 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id A083E8FC14 for ; Sat, 29 Nov 2008 08:00:16 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (gnats@localhost [127.0.0.1]) by freefall.freebsd.org (8.14.3/8.14.3) with ESMTP id mAT80GaS037596 for ; Sat, 29 Nov 2008 08:00:16 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.3/8.14.3/Submit) id mAT80G0n037595; Sat, 29 Nov 2008 08:00:16 GMT (envelope-from gnats) Resent-Date: Sat, 29 Nov 2008 08:00:16 GMT Resent-Message-Id: <200811290800.mAT80G0n037595@freefall.freebsd.org> Resent-From: FreeBSD-gnats-submit@FreeBSD.org (GNATS Filer) Resent-To: freebsd-ports-bugs@FreeBSD.org Resent-Reply-To: FreeBSD-gnats-submit@FreeBSD.org, Darren Pilgrim Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 251EF1065672 for ; Sat, 29 Nov 2008 07:59:36 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (www.freebsd.org [IPv6:2001:4f8:fff6::21]) by mx1.freebsd.org (Postfix) with ESMTP id 0A8738FC1A for ; Sat, 29 Nov 2008 07:59:36 +0000 (UTC) (envelope-from nobody@FreeBSD.org) Received: from www.freebsd.org (localhost [127.0.0.1]) by www.freebsd.org (8.14.3/8.14.3) with ESMTP id mAT7xZcp020194 for ; Sat, 29 Nov 2008 07:59:35 GMT (envelope-from nobody@www.freebsd.org) Received: (from nobody@localhost) by www.freebsd.org (8.14.3/8.14.3/Submit) id mAT7xYob020193; Sat, 29 Nov 2008 07:59:34 GMT (envelope-from nobody) Message-Id: <200811290759.mAT7xYob020193@www.freebsd.org> Date: Sat, 29 Nov 2008 07:59:34 GMT From: Darren Pilgrim To: freebsd-gnats-submit@FreeBSD.org X-Send-Pr-Version: www-3.1 Cc: Subject: ports/129274: [mail/dovecot] Patch to dovecot.sh.in to facilitate multi-instance configurations X-BeenThere: freebsd-ports-bugs@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Ports bug reports List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 29 Nov 2008 08:00:16 -0000 >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: