Bug 176475 - rewritten mail/sympa startup script to make it freebsd compatible
Summary: rewritten mail/sympa startup script to make it freebsd compatible
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: Chris Rees
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2013-02-27 10:30 UTC by ekoort
Modified: 2013-03-18 21:46 UTC (History)
0 users

See Also:


Attachments
file.diff (7.89 KB, patch)
2013-02-27 10:30 UTC, ekoort
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description ekoort 2013-02-27 10:30:00 UTC
With original sympa startup script services were not started after boot. 

So i took the liberty, removed non-freebsd stuff from there and made it more suitable for FreeBSD (rc.conf: sympa_enable="YES")

Also made it start after mysql or postgresql. Otherwise it won't start properly.

OTOH i'm not sure what happends when e.g. mysql is requirement in order to start but mysql server is not runnig on localhost.

Fix: Patch attached with submission follows:
Comment 1 Edwin Groothuis freebsd_committer freebsd_triage 2013-02-27 14:53:39 UTC
Responsible Changed
From-To: freebsd-ports-bugs->crees

Over to maintainer (via the GNATS Auto Assign Tool)
Comment 2 Chris Rees freebsd_committer freebsd_triage 2013-03-02 16:35:47 UTC
State Changed
From-To: open->feedback

Nice, thank you!  I've made a few style fixes, including moving the file 
testing into the start and stop sequence (checking for file existence is 
slow and shouldn't be done unless necessary), and converted leading 
spaces to tabs, removing the already builtin restart command.  Choose:
Comment 3 Chris Rees freebsd_committer freebsd_triage 2013-03-02 16:36:52 UTC
Oops, paste failed.

http://www.bayofrum.net/~crees/patches/sympa-rc.diff

Does it still work for you after this patch?

Chris
Comment 4 ekoort 2013-03-04 07:58:08 UTC
Works fine. Tnx.
Comment 5 dfilter service freebsd_committer freebsd_triage 2013-03-14 19:15:05 UTC
Author: crees
Date: Thu Mar 14 19:14:47 2013
New Revision: 314178
URL: http://svnweb.freebsd.org/changeset/ports/314178

Log:
  Add new rc script for sympa
  
  PR:		ports/176475
  Submitted by:	Eimar Koort <eimar.koort@gmail.com>

Added:
  head/mail/sympa/files/patch-src-etc-script-Makefile.in   (contents, props changed)
  head/mail/sympa/files/sympa.in   (contents, props changed)
Deleted:
  head/mail/sympa/files/patch-src__etc__script__sympa.in
Modified:
  head/mail/sympa/Makefile
  head/mail/sympa/pkg-plist

Modified: head/mail/sympa/Makefile
==============================================================================
--- head/mail/sympa/Makefile	Thu Mar 14 18:54:56 2013	(r314177)
+++ head/mail/sympa/Makefile	Thu Mar 14 19:14:47 2013	(r314178)
@@ -3,6 +3,7 @@
 
 PORTNAME=	sympa
 PORTVERSION=	6.1.17
+PORTREVISION=	1
 CATEGORIES=	mail
 MASTER_SITES=	http://www.sympa.org/distribution/ \
 		http://www.sympa.org/distribution/old/
@@ -52,7 +53,6 @@ CONFIGURE_ARGS+=--bindir=${PREFIX}/libex
 		--with-confdir=${PREFIX}/etc		\
 		--with-docdir=${EXAMPLESDIR}		\
 		--with-expldir=${DATADIR}/list_data	\
-		--with-iconsdir=${PREFIX}/${ICONSDIR}	\
 		--with-initdir=${PREFIX}/etc/rc.d	\
 		--with-lockdir=/var/spool/lock		\
 		--with-modulesdir=${PREFIX}/libexec/${PORTNAME} \
@@ -63,6 +63,8 @@ CONFIGURE_ENV+=	lt_cv_sys_max_cmd_len=${
 MAKE_ENV?=	PERL_EXTUTILS_AUTOINSTALL=--skip
 SUB_FILES=	pkg-install
 
+USE_RC_SUBR=	sympa
+
 .if !defined(WITHOUT_NLS)
 USE_GETTEXT=	yes
 PLIST_SUB+=	NLS=""
@@ -87,6 +89,7 @@ DB_TYPE:=	${DB_TYPE:U}
 .  for option in ${OPTIONS_RADIO_DATABASE}
 .    if ${DB_TYPE} == ${option:S,PGSQL,PG,}
 OPTIONS_SET+=	${option}
+.warning You need to replace your DB_TYPE variable in make.conf with OPTIONS_SET+=${option}
 .    endif
 .  endfor
 .endif
@@ -104,10 +107,12 @@ RUN_DEPENDS+=	${LOCALBASE}/${APACHEMODDI
 .if ${PORT_OPTIONS:MORACLE}
 RUN_DEPENDS+=	p5-DBD-Oracle>=0:${PORTSDIR}/databases/p5-DBD-Oracle
 .elif ${PORT_OPTIONS:MPGSQL}
+SUB_LIST+=	REQ_MYSQL="" REQ_PGSQL=postgresql
 RUN_DEPENDS+=	p5-DBD-Pg>=0:${PORTSDIR}/databases/p5-DBD-Pg
 .elif ${PORT_OPTIONS:MSYBASE}
 RUN_DEPENDS+=	p5-DBD-Sybase>=0:${PORTSDIR}/databases/p5-DBD-Sybase
 .elif ${PORT_OPTIONS:MMYSQL}
+SUB_LIST+=	REQ_MYSQL=mysql REQ_PGSQL=""
 RUN_DEPENDS+=	p5-DBD-mysql>=0:${PORTSDIR}/databases/p5-DBD-mysql
 .endif
 

Added: head/mail/sympa/files/patch-src-etc-script-Makefile.in
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/mail/sympa/files/patch-src-etc-script-Makefile.in	Thu Mar 14 19:14:47 2013	(r314178)
@@ -0,0 +1,11 @@
+--- src/etc/script/Makefile.in.orig	2013-03-13 18:06:41.202599651 +0000
++++ src/etc/script/Makefile.in	2013-03-13 18:06:05.882611401 +0000
+@@ -355,7 +355,7 @@
+ 
+ info-am:
+ 
+-install-data-am: install-initSCRIPTS install-scriptSCRIPTS
++install-data-am: install-scriptSCRIPTS
+ 
+ install-exec-am:
+ 

Added: head/mail/sympa/files/sympa.in
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ head/mail/sympa/files/sympa.in	Thu Mar 14 19:14:47 2013	(r314178)
@@ -0,0 +1,211 @@
+#!/bin/sh
+#
+# PROVIDE: sympa
+# REQUIRE: LOGIN cleanvar %%REQ_MYSQL%% %%REQ_PGSQL%% 
+# KEYWORD: shutdown
+#
+# $FreeBSD$
+#
+# Written by Michel Bouissou  20/07/2000
+#
+# Modified by Olivier Salaun 27/07/2000
+#    - translations
+#    - lang parameter deleted (defined in sympa.conf)
+#    - introduced --VARS-- parsed by Makefile
+#    - no more sympauser since sympa sets its UID
+# Modified by Michel Bouissou  27/07/2000
+# Modified by Eimar Koort 27/02/2013
+# 	- optimized for FreeBSD
+#
+# sympa_enable (bool):	Set to NO by default.
+# 			Set it to YES to enable sympa.
+#
+
+. /etc/rc.subr
+
+name=sympa
+rcvar=sympa_enable
+
+load_rc_config $name
+
+: ${sympa_enable:=no}
+
+start_cmd=sympa_start
+stop_cmd=sympa_stop
+status_cmd=sympa_status
+extra_commands=status
+
+sympadir=%%PREFIX%%/libexec/sympa
+
+sympaconf=%%PREFIX%%/etc/sympa.conf
+wwsympaconf=%%PREFIX%%/etc/wwsympa.conf
+
+sub_status()
+{
+	# Test syntax.
+	if [ $# = 0 ] ; then
+		echo "Usage: sub_status {program}"
+		return 1
+	fi
+	# First try "/u1/home/sympa/*.pid" files
+	if [ -f /var/run/sympa/$1.pid ] ; then
+		pid=`head -1 /var/run/sympa/$1.pid | tr -s ' ' '|'`
+		if [ "$pid" != "" ] ; then
+			running=`ps -A | egrep "$pid"`
+			if [ "$running" != "" ]; then
+				echo "$1 (pid(s) $pid) is active..."
+				return 0
+					else
+				echo "$1 died, pid file remains."
+				return 1
+			fi
+		fi
+	fi
+	echo "$1 is stopped."
+	return 3
+}
+
+sub_module_start()
+{
+	# Start a module
+	if [ $# = 0 ] ; then
+		echo "Usage: sub_module_start {program}"
+		return 1
+	fi
+	$sympadir/$1.pl $startparam && echo "success" || echo "failure"
+	echo
+}
+
+sub_start()
+{
+	# Test state of module before startup
+	if [ $# = 0 ] ; then
+		echo "Usage: sub_start {program}"
+		return 1
+	fi
+	sub_status $1 > /dev/null
+	case "$?" in
+		3)
+			echo $echo_opt "Starting module $1.pl: "
+			sub_module_start $1
+			;;
+		1) 
+			echo $echo_opt "Starting $1, overwriting old pid file."
+			sub_module_start $1
+			;;
+		0)
+			echo "$1 seems active. No action will be taken."
+			echo "Try \"sympa status\" or \"sympa restart"\".
+			;;
+	esac
+}
+
+sub_stop()
+{
+    # Stop a module
+    if [ $# = 0 ] ; then
+	echo "Usage: sub_stop {program}"
+	return 1
+    fi
+ 
+    if [ -f /var/run/sympa/$1.pid ]; then
+	echo $echo_opt "Stopping module $1.pl: "
+	pids=`head -1 /var/run/sympa/$1.pid`
+	runcount=0
+	if [ "$pids" != "" ]; then
+	    for pid in $pids; do
+		killcount=0
+		running=`ps -A | grep "^[[:space:]]*$pid[[:space:]].*$1\\.pl"`
+		while [ "$running" != "" ]; do
+		    if [ $killcount -gt 10 ]; then
+			echo 'failure'
+			return 3
+		    fi
+
+		    kill -TERM $pid >/dev/null 2>&1
+		    running=`ps -A | grep "^[[:space:]]*$pid[[:space:]].*$1\\.pl"`
+		    if [ "$running" = "" ]; then
+			runcount=`expr $runcount + 1`
+			break
+		    fi
+		    sleep 2
+		    running=`ps -A | grep "^[[:space:]]*$pid[[:space:]].*$1\\.pl"`
+		    if [ "$running" = "" ]; then
+			runcount=`expr $runcount + 1`
+			break
+		    fi
+		    killcount=`expr $killcount + 1`
+		done
+	    done
+	fi
+	if [ $runcount -gt 0 ]; then
+		echo 'success'
+	else
+	    echo 'died'
+	fi
+	echo
+    else
+	echo "Module $1.pl not running"
+    fi
+    return 0
+}
+
+sympa_check_config()
+{
+	# Check config files
+	[ -d $sympadir ] || exit 0
+	[ -f $sympaconf ] || exit 0
+	[ -f $wwsympaconf ] || exit 0
+}
+
+sympa_start()
+{
+	sympa_check_config
+	if [ ! -f /var/spool/lock/sympa ]; then
+		echo "Starting Sympa subsystem: "
+		sub_start sympa
+		sub_start bulk
+		sub_start archived
+		sub_start bounced
+		sub_start task_manager
+		touch /var/spool/lock/sympa
+		echo
+	else
+		echo "Sympa seems active. No action will be taken."
+		echo "Try \"sympa status\" or \"sympa restart"\".
+	fi
+}
+
+sympa_stop()
+{
+	sympa_check_config
+	echo "Stopping Sympa subsystem: "
+	sub_stop bounced
+	sub_stop archived
+	sub_stop bulk
+	sub_stop sympa
+	if [ -f /var/run/sympa/sympa-creation.pid ]; then
+		sub_stop sympa-creation
+	fi
+	sub_stop task_manager
+	if [ -f /var/spool/lock/sympa ]; then
+		rm -f /var/spool/lock/sympa
+	fi
+}
+
+sympa_status()
+{
+	echo "Status of Sympa subsystem: "
+	if [ -f /var/spool/lock/sympa ]; then
+		echo "Status file for subsystem found."
+	else
+		echo "Status file for subsystem NOT found."
+	fi
+	sub_status sympa
+	sub_status bulk
+	sub_status archived
+	sub_status bounced
+	sub_status task_manager
+}
+
+run_rc_command $1

Modified: head/mail/sympa/pkg-plist
==============================================================================
--- head/mail/sympa/pkg-plist	Thu Mar 14 18:54:56 2013	(r314177)
+++ head/mail/sympa/pkg-plist	Thu Mar 14 19:14:47 2013	(r314178)
@@ -1,4 +1,3 @@
-etc/rc.d/sympa
 @comment copyover handled in pkg-install
 @unexec cmp -s %D/etc/sympa.conf.sample %D/etc/sympa.conf && rm -f %D/etc/sympa.conf
 etc/sympa.conf.sample
_______________________________________________
svn-ports-all@freebsd.org mailing list
http://lists.freebsd.org/mailman/listinfo/svn-ports-all
To unsubscribe, send any mail to "svn-ports-all-unsubscribe@freebsd.org"
Comment 6 Chris Rees freebsd_committer freebsd_triage 2013-03-18 21:46:24 UTC
State Changed
From-To: feedback->closed

Committed. Thanks!