Bug 91595 - [patch] mail/dk-milter startup stript using rc.subr(8)
Summary: [patch] mail/dk-milter startup stript using rc.subr(8)
Status: Closed FIXED
Alias: None
Product: Ports & Packages
Classification: Unclassified
Component: Individual Port(s) (show other bugs)
Version: Latest
Hardware: Any Any
: Normal Affects Only Me
Assignee: freebsd-ports-bugs (Nobody)
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-01-10 13:00 UTC by Hirohisa Yamaguchi
Modified: 2006-01-15 09:11 UTC (History)
0 users

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Hirohisa Yamaguchi 2006-01-10 13:00:19 UTC
	I wrote a startup script using rc.subr(8).

Fix: patch follows:



Date: Tue, 10 Jan 2006 22:56:09 +0900
From: Hirohisa Yamaguchi <umq@ueo.co.jp>
Subject: Re: [patch] mail/dk-milter startup stript using rc.subr(8)

 a socket remains after stop command, and it prevents from starting again.
 this one should work okay.
 
 diff -pru tmp/ports/mail/dk-milter/Makefile ports/mail/dk-milter/Makefile
 --- tmp/ports/mail/dk-milter/Makefile	Tue Jan 10 21:26:59 2006
 +++ ports/mail/dk-milter/Makefile	Tue Jan 10 21:43:41 2006
 @@ -7,6 +7,7 @@
  
  PORTNAME=	dk-milter
  PORTVERSION=	0.3.2
 +PORTREVISION=	1
  CATEGORIES=	mail
  MASTER_SITES=	${MASTER_SITE_SOURCEFORGE}
  MASTER_SITE_SUBDIR=	dk-milter
 @@ -14,6 +15,8 @@ MASTER_SITE_SUBDIR=	dk-milter
  MAINTAINER=	ports@FreeBSD.org
  COMMENT=	Domainkeys milter for Sendmail
  
 +USE_RC_SUBR=	milter-dk.sh
 +
  .if !defined(SENDMAIL_MILTER_IN_BASE)
  .if defined(SENDMAIL_WITH_SHARED_MILTER)
  LIB_DEPENDS+=	milter.3:${PORTSDIR}/mail/${SENDMAIL_MILTER_PORT}
 @@ -59,8 +62,6 @@ post-install:
  	-${STRIP_CMD} ${PREFIX}/libexec/dk-filter
  	${INSTALL_SCRIPT} ${WRKSRC}/dk-filter/gentxt.csh \
  		${PREFIX}/sbin/gentxt
 -	${INSTALL_DATA} ${WRKDIR}/milter-dk.sh \
 -		${PREFIX}/etc/rc.d/milter-dk.sh.sample
  .for i in ${MAN8}
  	@${RM} -f ${MANPREFIX}/man/cat8/${i} ${MANPREFIX}/man/cat8/${i}.gz
  	${INSTALL_MAN} ${WRKSRC}/*/${i} ${MANPREFIX}/man/man8/
 diff -pru tmp/ports/mail/dk-milter/files/milter-dk.sh.in ports/mail/dk-milter/files/milter-dk.sh.in
 --- tmp/ports/mail/dk-milter/files/milter-dk.sh.in	Mon May 23 17:23:05 2005
 +++ ports/mail/dk-milter/files/milter-dk.sh.in	Tue Jan 10 22:42:39 2006
 @@ -1,51 +1,46 @@
  #!/bin/sh
  #
 -# $FreeBSD: ports/mail/dk-milter/files/milter-dk.sh.in,v 1.1 2005/05/23 08:23:05 ache Exp $
 -# 
 -if ! test -x %%PREFIX%%/libexec/dk-filter
 -then
 -	exit 0
 -fi
 -dk_filter_args="-d example.com -c nofws -H -m MSA -s /var/db/domainkeys/default.key.pem -S default"
 -case "$1" in
 -start)
 -	sh "${0}" wait
 -	rm -f /var/run/dk-filter.pid /var/run/dk-filter
 -	%%PREFIX%%/libexec/dk-filter -l -p local:/var/run/dk-filter \
 -		-P /var/run/dk-filter.pid ${dk_filter_args}
 -	echo -n ' dk-filter'
 -	;;
 -stop)
 -	if test -r /var/run/dk-filter.pid
 -	then
 -		kill `head -1 /var/run/dk-filter.pid`
 -	else
 -		echo " dk-filter: not running" 2>&1
 -	fi
 -	sh "${0}" wait
 -	rm -f /var/run/dk-filter.pid
 -	;;
 -wait)
 -	while ps -axw -o pid,command | egrep "^[0-9]+ %%PREFIX%%/libexec/dk-filter "
 -	do
 -		echo "please wait"
 -		sleep 1
 -	done
 -	;;
 -restart)
 -	"$0" stop
 -	"$0" start
 -	;;
 -status)
 -	if [ -z "$(ps -axw -o pid,command | egrep "^[0-9]+ %%PREFIX%%/libexec/dk-filter ")" ]
 -	then
 -		echo "FAILED dk-filter is not running!"
 -	else
 -		echo "OK dk-filter is running!"
 -	fi
 -	;;
 -*)
 -	echo "Usage: ${0##*/}: {start|stop|restart|status}" >&2
 -	exit 64
 -	;;
 -esac
 +# $FreeBSD$
 +#
 +
 +# PROVIDE: milterdk
 +# REQUIRE: DAEMON
 +# BEFORE: sendmail
 +# KEYWORD: shutdown
 +
 +# Define these milterdk_* variables in one of these files:
 +#	/etc/rc.conf
 +#	/etc/rc.conf.local
 +#	/etc/rc.conf.d/milterdk
 +#
 +# DO NOT CHANGE THESE DEFAULT VALUES HERE
 +#
 +milterdk_enable=${milterdk_enable:-"NO"}
 +milterdk_socket=${milterdk_socket:-"local:/var/run/dk-filter"}
 +milterdk_pid=${milterdk_pid:-"/var/run/dk-filter.pid"}
 +milterdk_domain=${milterdk_domain:-"example.com"}
 +milterdk_key=${milterdk_key:-"/var/db/domainkeys/default.key.pem"}
 +milterdk_flags=${milterdk_flags:-"-d ${milterdk_domain} -c nofws -H -m MSA \
 +-s ${milterdk_key} -S default"}
 +
 +. %%RC_SUBR%%
 +
 +name="milterdk"
 +pidfile=${milterdk_pid}
 +rcvar=`set_rcvar`
 +command="%%PREFIX%%/libexec/dk-filter"
 +command_args="-l -p ${milterdk_socket} -P ${milterdk_pid}"
 +stop_postcmd="dk_postcmd"
 +
 +load_rc_config $name
 +
 +dk_postcmd ()
 +{
 +    if [ -S ${milterdk_socket##local:} ] ; then
 +        rm -f ${milterdk_socket##local:}
 +    elif [ -S ${milterdk_socket##unix:} ] ; then
 +        rm -f ${milterdk_socket##unix:}
 +    fi
 +}
 +
 +run_rc_command "$1"
 diff -pru tmp/ports/mail/dk-milter/pkg-plist ports/mail/dk-milter/pkg-plist
 --- tmp/ports/mail/dk-milter/pkg-plist	Sun May 22 22:39:11 2005
 +++ ports/mail/dk-milter/pkg-plist	Tue Jan 10 21:22:46 2006
 @@ -1,4 +1,3 @@
 -etc/rc.d/milter-dk.sh.sample
  libexec/dk-filter
  sbin/gentxt
  %%PORTDOCS%%%%DOCSDIR%%/FEATURES--P29Ny0oH1Zy479z81ycflaW2CFryAvgItt4LwCL1etjEwPTJ
Content-Type: text/plain; name="file.diff"
Content-Transfer-Encoding: 7bit
Content-Disposition: attachment; filename="file.diff"

diff -pru tmp/ports/mail/dk-milter/Makefile ports/mail/dk-milter/Makefile
--- tmp/ports/mail/dk-milter/Makefile	Tue Jan 10 21:26:59 2006
+++ ports/mail/dk-milter/Makefile	Tue Jan 10 21:43:41 2006
@@ -7,6 +7,7 @@
 
 PORTNAME=	dk-milter
 PORTVERSION=	0.3.2
+PORTREVISION=	1
 CATEGORIES=	mail
 MASTER_SITES=	${MASTER_SITE_SOURCEFORGE}
 MASTER_SITE_SUBDIR=	dk-milter
@@ -14,6 +15,8 @@ MASTER_SITE_SUBDIR=	dk-milter
 MAINTAINER=	ports@FreeBSD.org
 COMMENT=	Domainkeys milter for Sendmail
 
+USE_RC_SUBR=	milter-dk.sh
+
 .if !defined(SENDMAIL_MILTER_IN_BASE)
 .if defined(SENDMAIL_WITH_SHARED_MILTER)
 LIB_DEPENDS+=	milter.3:${PORTSDIR}/mail/${SENDMAIL_MILTER_PORT}
@@ -59,8 +62,6 @@ post-install:
 	-${STRIP_CMD} ${PREFIX}/libexec/dk-filter
 	${INSTALL_SCRIPT} ${WRKSRC}/dk-filter/gentxt.csh \
 		${PREFIX}/sbin/gentxt
-	${INSTALL_DATA} ${WRKDIR}/milter-dk.sh \
-		${PREFIX}/etc/rc.d/milter-dk.sh.sample
 .for i in ${MAN8}
 	@${RM} -f ${MANPREFIX}/man/cat8/${i} ${MANPREFIX}/man/cat8/${i}.gz
 	${INSTALL_MAN} ${WRKSRC}/*/${i} ${MANPREFIX}/man/man8/
diff -pru tmp/ports/mail/dk-milter/files/milter-dk.sh.in ports/mail/dk-milter/files/milter-dk.sh.in
--- tmp/ports/mail/dk-milter/files/milter-dk.sh.in	Mon May 23 17:23:05 2005
+++ ports/mail/dk-milter/files/milter-dk.sh.in	Tue Jan 10 21:22:38 2006
@@ -1,51 +1,35 @@
 #!/bin/sh
 #
-# $FreeBSD: ports/mail/dk-milter/files/milter-dk.sh.in,v 1.1 2005/05/23 08:23:05 ache Exp $
-# 
-if ! test -x %%PREFIX%%/libexec/dk-filter
-then
-	exit 0
-fi
-dk_filter_args="-d example.com -c nofws -H -m MSA -s /var/db/domainkeys/default.key.pem -S default"
-case "$1" in
-start)
-	sh "${0}" wait
-	rm -f /var/run/dk-filter.pid /var/run/dk-filter
-	%%PREFIX%%/libexec/dk-filter -l -p local:/var/run/dk-filter \
-		-P /var/run/dk-filter.pid ${dk_filter_args}
-	echo -n ' dk-filter'
-	;;
-stop)
-	if test -r /var/run/dk-filter.pid
-	then
-		kill `head -1 /var/run/dk-filter.pid`
-	else
-		echo " dk-filter: not running" 2>&1
-	fi
-	sh "${0}" wait
-	rm -f /var/run/dk-filter.pid
-	;;
-wait)
-	while ps -axw -o pid,command | egrep "^[0-9]+ %%PREFIX%%/libexec/dk-filter "
-	do
-		echo "please wait"
-		sleep 1
-	done
-	;;
-restart)
-	"$0" stop
-	"$0" start
-	;;
-status)
-	if [ -z "$(ps -axw -o pid,command | egrep "^[0-9]+ %%PREFIX%%/libexec/dk-filter ")" ]
-	then
-		echo "FAILED dk-filter is not running!"
-	else
-		echo "OK dk-filter is running!"
-	fi
-	;;
-*)
-	echo "Usage: ${0##*/}: {start|stop|restart|status}" >&2
-	exit 64
-	;;
-esac
+# $FreeBSD$
+#
+
+# PROVIDE: milterdk
+# REQUIRE: DAEMON
+# BEFORE: sendmail
+# KEYWORD: shutdown
+
+# Define these milterdk_* variables in one of these files:
+#	/etc/rc.conf
+#	/etc/rc.conf.local
+#	/etc/rc.conf.d/milterdk
+#
+# DO NOT CHdANGE THESE DEFAULT VALUES HERE
+#
+milterdk_enable=${milterdk_enable:-"NO"}
+milterdk_socket=${milterdk_socket:-"local:/var/run/dk-filter"}
+milterdk_pid=${milterdk_pid:-"/var/run/dk-filter.pid"}
+milterdk_domain=${milterdk_domain:-"example.com"}
+milterdk_key=${milterdk_key:-"/var/db/domainkeys/default.key.pem"}
+milterdk_flags=${milterdk_flags:-"-d ${milterdk_domain} -c nofws -H -m MSA \
+-s ${milterdk_key} -S default"}
+
+. %%RC_SUBR%%
+
+name="milterdk"
+pidfile=${milterdk_pid}
+rcvar=`set_rcvar`
+command="%%PREFIX%%/libexec/dk-filter"
+command_args="-l -p ${milterdk_socket} -P ${milterdk_pid}"
+
+load_rc_config $name
+run_rc_command "$1"
diff -pru tmp/ports/mail/dk-milter/pkg-plist ports/mail/dk-milter/pkg-plist
--- tmp/ports/mail/dk-milter/pkg-plist	Sun May 22 22:39:11 2005
+++ ports/mail/dk-milter/pkg-plist	Tue Jan 10 21:22:46 2006
@@ -1,4 +1,3 @@
-etc/rc.d/milter-dk.sh.sample
 libexec/dk-filter
 sbin/gentxt
 %%PORTDOCS%%%%DOCSDIR%%/FEATURES
Comment 1 Pav Lucistnik freebsd_committer freebsd_triage 2006-01-15 09:11:14 UTC
State Changed
From-To: open->closed

Committed, thanks!