Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 4 Oct 2002 16:02:14 -0500 (CDT)
From:      "Scot W. Hetzel" <hetzels@westbend.net>
To:        FreeBSD-gnats-submit@FreeBSD.org
Cc:        ume@FreeBSD.org
Subject:   ports/43668: RC_NG script for mail/cyrus_imapd2
Message-ID:  <200210042102.g94L2EY6030516@WBIw009.westbend.net>

next in thread | raw e-mail | index | archive | help

>Number:         43668
>Category:       ports
>Synopsis:       RC_NG script for mail/cyrus_imapd2
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Oct 04 14:10:02 PDT 2002
>Closed-Date:
>Last-Modified:
>Originator:     Scot W. Hetzel
>Release:        FreeBSD 5.0-CURRENT i386
>Organization:
West Bend Internet
>Environment:
System: FreeBSD Current.westbend.net 5.0-CURRENT FreeBSD 5.0-CURRENT #5: Tue Sep 24 11:27:41 CDT 2002 root@Current.westbend.net:/usr/obj/usr/src/srcC/sys/GENERIC-SMP i386

>Description:
	While looking at the RC_NG scripts on 5.0-CURRENT, I looked at converting the ports
	rc startup scripts to RC_NG.  I decided to start with cyrus-imapd2 and the ports that
	it depends on (cyrus-sasl2, openldap, openldap2, mysql323-client).

	To ensure compatibility with previous FreeBSD Releases, the rc scripts contain both
	the new RC_NG and pre RC_NG scripts.

>How-To-Repeat:

>Fix:

	Changed Files:       
	    Makefile       - Eenable the build & install of the idled daemon (WITH_IDLE)
	                   - rename installed imapd.sh.sample to cyrus_imapd.sh.sample
	    pkg-plist      - Add cyrus/bin/idled and rename imapd.sh.sample
	    files/imapd.sh - Update to RC_NG
	    files/patch-dd - Allow '_' in entry name in cyrus.conf.  Usefull for
                             setting up virtual domains (i.e. imap_d1 .. instead of imapd1 ..).

	    files/patch-dj - add missing header for imap/idle_idled.c

Index: Makefile
===================================================================
RCS file: /home/ncvs/ports/mail/cyrus-imapd2/Makefile,v
retrieving revision 1.66
diff -u -r1.66 Makefile
--- Makefile	1 Sep 2002 20:12:13 -0000	1.66
+++ Makefile	4 Oct 2002 14:46:32 -0000
@@ -32,6 +32,13 @@
 		--with-auth=unix \
 		--with-com_err
 
+.if defined(WITH_IDLE)
+CONFIUGRE_ARGS+=--with-idle=idled
+PLIST_SUB+=	IDLE=""
+.else
+PLIST_SUB+=	IDLE="@comment "
+.endif
+
 .if defined(WITH_SNMP)
 # It seems not compilable due to lack of auto_nlist_value() in libucdagent.
 LIB_DEPENDS+=	netsnmp.5:${PORTSDIR}/net/net-snmp
@@ -108,7 +115,7 @@
 		@${ECHO} "@dirrm share/doc/cyrus-imapd2" >>${TMPPLIST}
 .endif
 		${INSTALL_SCRIPT} ${FILESDIR}/imapd.sh \
-			${PREFIX}/etc/rc.d/imapd.sh.sample
+			${PREFIX}/etc/rc.d/cyrus_imapd.sh.sample
 		${INSTALL_DATA} ${FILESDIR}/imapd.conf \
 			${PREFIX}/etc/imapd.conf.dist
 		${INSTALL_DATA} ${WRKSRC}/master/conf/normal.conf \
Index: pkg-plist
===================================================================
RCS file: /home/ncvs/ports/mail/cyrus-imapd2/pkg-plist,v
retrieving revision 1.16
diff -u -r1.16 pkg-plist
--- pkg-plist	8 Aug 2002 14:06:48 -0000	1.16
+++ pkg-plist	4 Oct 2002 14:47:28 -0000
@@ -17,6 +17,7 @@
 cyrus/bin/deliver
 cyrus/bin/feedcyrus
 cyrus/bin/fud
+%%IDLE%%cyrus/bin/idled
 cyrus/bin/imapd
 cyrus/bin/ipurge
 cyrus/bin/lmtpd
@@ -35,7 +36,7 @@
 @unexec if cmp -s %D/etc/imapd.conf %D/etc/imapd.conf.dist; then rm -f %D/etc/imapd.conf; fi
 etc/imapd.conf.dist
 @exec [ -f %B/imapd.conf ] || cp %B/%f %B/imapd.conf
-etc/rc.d/imapd.sh.sample
+etc/rc.d/cyrus_imapd.sh.sample
 include/cyrus/acap.h
 include/cyrus/acl.h
 include/cyrus/assert.h
Index: files/imapd.sh
===================================================================
RCS file: /home/ncvs/ports/mail/cyrus-imapd2/files/imapd.sh,v
retrieving revision 1.4
diff -u -r1.4 imapd.sh
--- files/imapd.sh	12 Apr 2001 19:06:31 -0000	1.4
+++ files/imapd.sh	4 Oct 2002 17:06:38 -0000
@@ -3,21 +3,103 @@
 # Start or stop cyrus-imapd
 # $FreeBSD: ports/mail/cyrus-imapd2/files/imapd.sh,v 1.4 2001/04/12 19:06:31 ume Exp $
 
-case "$1" in
-start)
-	if [ -x /usr/local/cyrus/bin/master -a \
-	     -f /usr/local/etc/cyrus.conf -a \
-	     -f /usr/local/etc/imapd.conf ]; then
-		/usr/local/cyrus/bin/master &
-		echo -n ' imapd'
-	fi
-	;;
-stop)
-	kill `ps -U cyrus | awk '/master/ {print $1}'` && echo -n ' imapd'
-	;;
-*)
-	echo "Usage: `basename $0` {start|stop}" >&2
-	;;
-esac
+# PROVIDE: imap
+# PROVIDE: pop3
+# REQUIRE: DAEMON sasl
+# BEFORE: mail
+# KEYWORD: FreeBSD NetBSD shutdown
+#
+# NOTE for FreeBSD 5.0+:
+# If you want this script to start with the base rc scripts
+# copy cyrus_imapd.sh.sample to /etc/rc.d/cyrus_imapd, otherwise
+# copy it to cyrus_imapd.sh
 
-exit 0
+# Define the following cyrus_imapd_* variables in one of the following:
+#       /etc/rc.conf
+#       /etc/rc.conf.d/cyrus_imapd
+#       ${prefix}/etc/rc.conf.d/cyrus_imapd
+#
+#       cyrus_imapd_enable  - Set to YES to enable cyrus_imapd
+#                             Default: yes
+#
+#       cyrus_imapd_program - Path to cyrus_imapd program
+#                             Default: ${PREFIX}/cyrus/bin/master
+
+prefix=%%PREFIX%%
+
+master_stop()
+{
+	pid=`ps -U cyrus | awk '/master/ {print $1}'`
+
+	if [ -n "${pid}" ]; then
+		kill ${pid} && echo -n " ${name}"
+	fi
+}
+
+if [ -f /etc/rc.subr ]; then
+	. /etc/rc.subr
+
+	name="cyrus_imapd"
+	rcvar=`set_rcvar`
+	command=${cyrus_imapd_program:-${prefix}/cyrus/bin/master}
+	command_args="&"
+	required_files="${prefix}/etc/cyrus.conf ${prefix}/etc/imapd.conf"
+	# stop_cmd="master_stop"
+
+	# The below may be removed when load_local_rc_config is added to rc.subr
+
+	if [ -f ${prefix}/etc/rc.conf.d/"$name" ]; then
+		debug "Sourcing ${prefix}/etc/rc.conf.d/${name}"
+		. ${prefix}/etc/rc.conf.d/"$name"
+	fi
+
+	load_rc_config $name
+
+	if [ -z "#{cyrus_imapd_enable}" ]; then
+		cyrus_imapd_enable=yes
+	fi
+
+	# The above may be removed when load_local_rc_config is added to rc.subr
+	#
+	# load_local_rc_config $name
+	run_rc_command "$1"
+else
+	name="cyrus_imapd"
+
+	# Suck in the configuration variables.
+	if [ -z "${source_rc_confs_defined}" ]; then
+		if [ -r /etc/defaults/rc.conf ]; then
+			. /etc/defaults/rc.conf
+			source_rc_confs
+		elif [ -r /etc/rc.conf ]; then
+			. /etc/rc.conf
+		fi
+	fi
+
+	if [ -f ${prefix}/etc/rc.conf.d/${name} ]; then
+		. ${prefix}/etc/rc.conf.d/${name}
+	fi
+
+	if [ -z "${cyrus_imapd_program}" ]; then
+		cyrus_imapd_program=${prefix}/cyrus/bin/master
+	fi
+
+	case "$1" in
+	start)
+		if [ -x ${cyrus_imapd_program} -a \
+		     -f /usr/local/etc/cyrus.conf -a \
+		     -f /usr/local/etc/imapd.conf ]; then
+			${cyrus_imapd_program} ${cyrus_imapd_flags} &
+			echo -n ' ${name}'
+		fi
+		;;
+	stop)
+		master_stop
+		;;
+	*)
+		echo "Usage: `basename $0` {start|stop}" >&2
+		;;
+	esac
+
+	exit 0
+fi
Index: files/patch-dd
===================================================================
RCS file: /home/ncvs/ports/mail/cyrus-imapd2/files/patch-dd,v
retrieving revision 1.1
diff -u -r1.1 patch-dd
--- files/patch-dd	13 Mar 2001 11:15:12 -0000	1.1
+++ files/patch-dd	4 Oct 2002 15:04:05 -0000
@@ -1,8 +1,8 @@
 Index: master/masterconf.c
 diff -u master/masterconf.c.orig master/masterconf.c
---- master/masterconf.c.orig	Wed May 24 05:56:30 2000
-+++ master/masterconf.c	Sat Jan  6 06:07:22 2001
-@@ -60,7 +60,9 @@
+--- master/masterconf.c.orig	Wed Jul 24 14:30:53 2002
++++ master/masterconf.c	Tue Sep 24 15:51:53 2002
+@@ -59,7 +59,9 @@
  
  extern int errno;
  
@@ -12,3 +12,12 @@
  
  struct configlist {
      char *key;
+@@ -172,7 +174,7 @@
+ 	if (!*p) continue;
+ 	if (*p == '}') break;
+ 
+-	for (q = p; isalnum((int) *q); q++) ;
++	for (q = p; isalnum((int) *q) || *q == '_' ; q++) ;
+ 	if (q) { *q = '\0'; q++; }
+ 	
+ 	if (q - p > 0) {
Index: files/patch-dj
===================================================================
RCS file: files/patch-dj
diff -N files/patch-dj
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ files/patch-dj	24 Sep 2002 21:47:41 -0000
@@ -0,0 +1,12 @@
+Index: imap/idle_idled.c
+diff -u imap/idle_idled.c.orig imap/idle_idled.c
+--- imap/idle_idled.c	Fri Jan 18 16:58:47 2002
++++ imap/idle_idled.c	Tue Sep 24 16:03:27 2002
+@@ -54,6 +54,7 @@
+ #include <unistd.h>
+ #endif
+ #include <signal.h>
++#include <strings.h>
+ 
+ #include "idle.h"
+ #include "idled.h"
>Release-Note:
>Audit-Trail:
>Unformatted:

To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200210042102.g94L2EY6030516>