ports/128681: Update smstools3 to improve rc script and enable statistics feature
Sean McAfee
smcafee at collaborativefusion.com
Fri Nov 7 17:30:05 UTC 2008
>Number: 128681
>Category: ports
>Synopsis: Update smstools3 to improve rc script and enable statistics feature
>Confidential: no
>Severity: non-critical
>Priority: low
>Responsible: freebsd-ports-bugs
>State: open
>Quarter:
>Keywords:
>Date-Required:
>Class: change-request
>Submitter-Id: current-users
>Arrival-Date: Fri Nov 07 17:30:04 UTC 2008
>Closed-Date:
>Last-Modified:
>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:
>Unformatted:
More information about the freebsd-ports-bugs
mailing list