From nobody@FreeBSD.org  Fri Nov  7 17:28:13 2008
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34])
	by hub.freebsd.org (Postfix) with ESMTP id 3BEE6106564A
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  7 Nov 2008 17:28:13 +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 2A9628FC12
	for <freebsd-gnats-submit@FreeBSD.org>; Fri,  7 Nov 2008 17:28:13 +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 mA7HSCws031199
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 7 Nov 2008 17:28:12 GMT
	(envelope-from nobody@www.freebsd.org)
Received: (from nobody@localhost)
	by www.freebsd.org (8.14.3/8.14.3/Submit) id mA7HSCEf031198;
	Fri, 7 Nov 2008 17:28:12 GMT
	(envelope-from nobody)
Message-Id: <200811071728.mA7HSCEf031198@www.freebsd.org>
Date: Fri, 7 Nov 2008 17:28:12 GMT
From: Sean McAfee <smcafee@collaborativefusion.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Update smstools3 to improve rc script and enable statistics feature
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         128681
>Category:       ports
>Synopsis:       Update comms/smstools3 to improve rc script and enable statistics feature
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    mm
>State:          closed
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          change-request
>Submitter-Id:   current-users
>Arrival-Date:   Fri Nov 07 17:30:04 UTC 2008
>Closed-Date:    Fri Nov 21 12:12:33 UTC 2008
>Last-Modified:  Fri Nov 21 12:12:33 UTC 2008
>Originator:     Sean McAfee
>Release:        6.3R-p4
>Organization:
Collaborative Fusion, Inc.
>Environment:
>Description:
The current revision of the port does not allow for building of the statistics gathering feature, likely because attempting to manually build it from source results in an error due to a missing CFLAGS include.

Additionally, the rc script was basic and did not allow for conffile/pidfile/flags knobs via rc.conf (among other issues.)

A patch is attached.
>How-To-Repeat:

>Fix:


Patch attached with submission follows:

diff -ruN smstools3.bak/Makefile smstools3/Makefile
--- smstools3/Makefile	2008-10-02 22:35:31.000000000 -0400
+++ smstools3/Makefile	2008-11-07 08:23:58.000000000 -0500
@@ -18,6 +18,8 @@
 
 CONFLICTS=	smstools-2.*
 
+OPTIONS=        STATS "Build status and statistics support" off
+
 WRKSRC=		${WRKDIR}/smstools3
 USE_GMAKE=	yes
 USE_RC_SUBR=	smsd
@@ -50,6 +52,12 @@
 		sms2unicode sms2xml sms3 smsevent smsresend smstest.php \
 		sql_demo unicode2sms
 
+.include <bsd.port.pre.mk>
+
+.if defined(WITH_STATS)
+CFLAGS+= -I${PREFIX}/include
+.endif
+
 post-patch:
 	@${REINPLACE_CMD} 's|%%PREFIX%%|${PREFIX}|g' ${WRKSRC}/install.sh \
 		${WRKSRC}/src/smsd_cfg.c
@@ -57,6 +65,9 @@
 		${WRKSRC}/examples/smsd.conf.easy \
 		${WRKSRC}/examples/smsd.conf.full \
 		${WRKSRC}/examples/smsd.conf.non-root
+.if defined(WITH_STATS)
+	@${REINPLACE_CMD} 's|CFLAGS\ \+\=\ \-D\ NOSTATS|\#CFLAGS\ \+\=\ \-D\ NOSTATS|g' ${WRKSRC}/src/Makefile
+.endif
 
 post-install:
 	@${MKDIR} ${DATADIR}
@@ -78,4 +89,5 @@
 	@${MKDIR} ${EXAMPLESDIR}
 	@${INSTALL_DATA} ${EXAMPLES:S,^,${WRKSRC}/examples/,} ${EXAMPLESDIR}/
 .endif
-.include <bsd.port.mk>
+
+.include <bsd.port.post.mk>
diff -ruN smstools3.bak/files/smsd.in smstools3/files/smsd.in
--- smstools3/files/smsd.in	2008-06-07 12:28:46.000000000 -0400
+++ smstools3/files/smsd.in	2008-11-07 08:23:58.000000000 -0500
@@ -11,24 +11,59 @@
 # smsd_enable="YES"
 #
 smsd_enable=${smsd_enable-"NO"}
+smsd_flags=${smsd_flags-""}
+smsd_pidfile=${smsd_pidfile-"/var/run/smsd.pid"}
+smsd_conffile=${smsd_conffile-"/usr/local/etc/smsd.conf"}
 
-. %%RC_SUBR%%
+
+. /etc/rc.subr
 
 name="smsd"
 rcvar=`set_rcvar`
 load_rc_config $name
-pidfile="/var/run/smsd.pid"
-command="%%PREFIX%%/bin/smsd"
-command_args='&'
+command="/usr/local/bin/smsd"
+command_args=''
+
+start_precmd="${name}_prestart"
+stop_cmd="${name}_stop"
 
-# Unfortunally we need to this because as the program won't
+smsd_prestart()
+{
+    echo $smsd_flags | /usr/bin/grep - "-s" > /dev/null
+    if [ $? = 0 ] ; then
+        echo "CRITICAL: \$smsd_flags includes -s option." 
+        echo "Since this prints to stout, it should only be used in foreground mode."
+	return 1
+    else
+        return 0
+    fi
+}
+
+# Unfortunately we need to this because as the program won't
 # exit cleanly and the terminal will be stuck forever in waitpid.
-case "$1" in
-	stop)
-		pkill smsd
-		;;
-	*)
-		run_rc_command "$1"
-		;;
-esac
+smsd_stop()
+{
+    if [ -e ${smsd_pidfile} ]; then
+            pkill smsd
+            echo "Stopping smsd."
+	    sleep 5
+    else
+           echo "${name} not running? (check ${smsd_pidfile})."
+           exit 1
+    fi
+}
+
+for conffile in ${smsd_conffile}; do
+        if [ ! -z ${conffile} -a -f ${conffile} ]; then
+               if [ -z ${smsd_conffile_set} ]; then
+                       smsd_conffile_set="${conffile}"
+               else
+                       smsd_conffile_set="${smsd_conffile_set},${conffile}"
+               fi
+        else
+               echo "smsd configuration file $conffile not set or not found."
+               exit 1
+        fi
+done
 
+run_rc_command "$1"


>Release-Note:
>Audit-Trail:
Responsible-Changed-From-To: freebsd-ports-bugs->mm 
Responsible-Changed-By: edwin 
Responsible-Changed-When: Fri Nov 7 19:26:27 UTC 2008 
Responsible-Changed-Why:  
Over to maintainer (via the GNATS Auto Assign Tool) 

http://www.freebsd.org/cgi/query-pr.cgi?pr=128681 

From: dfilter@FreeBSD.ORG (dfilter service)
To: bug-followup@FreeBSD.org
Cc:  
Subject: Re: ports/128681: commit references a PR
Date: Fri, 21 Nov 2008 12:04:06 +0000 (UTC)

 mm          2008-11-21 12:03:56 UTC
 
   FreeBSD ports repository
 
   Modified files:
     .                    UPDATING 
     comms/smstools3      Makefile pkg-plist 
     comms/smstools3/files smsd.in 
   Added files:
     comms/smstools3/files patch-src-Makefile 
   Log:
   - New RCNG script for smstools3
   - Improved security (runas uucp:dialer)
   - Some ideas imported from [1]
   
   PR:             ports/128681 [1]
   Submitted by:   Sean McAfee <smcafee at collaborativefusion.com> [1]
   
   Revision  Changes    Path
   1.729     +12 -1     ports/UPDATING
   1.5       +23 -6     ports/comms/smstools3/Makefile
   1.1       +20 -0     ports/comms/smstools3/files/patch-src-Makefile (new)
   1.2       +15 -18    ports/comms/smstools3/files/smsd.in
   1.3       +4 -1      ports/comms/smstools3/pkg-plist
 _______________________________________________
 cvs-all@freebsd.org mailing list
 http://lists.freebsd.org/mailman/listinfo/cvs-all
 To unsubscribe, send any mail to "cvs-all-unsubscribe@freebsd.org"
 
State-Changed-From-To: open->closed 
State-Changed-By: mm 
State-Changed-When: Fri Nov 21 12:12:32 UTC 2008 
State-Changed-Why:  
Some ideas imported. 

http://www.freebsd.org/cgi/query-pr.cgi?pr=128681 
>Unformatted:
