Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 15 May 2011 19:31:16 GMT
From:      Doug Barton <dougb@FreeBSD.org>
To:        FreeBSD-gnats-submit@FreeBSD.org
Subject:   ports/157073: Convert net/mediaproxy to rc.d, small fix for ${WRKSRC}
Message-ID:  <201105151931.p4FJVGms078262@freefall.freebsd.org>
Resent-Message-ID: <201105151940.p4FJe72U084110@freefall.freebsd.org>

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

>Number:         157073
>Category:       ports
>Synopsis:       Convert net/mediaproxy to rc.d, small fix for ${WRKSRC}
>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:   Sun May 15 19:40:07 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator:     Doug Barton
>Release:        FreeBSD 8.2-STABLE i386
>Organization:
AAAG
>Environment:
	DNA
>Description:
	Currently mediaproxy is using an old-style .sh script for start, stop,
	etc. This patch does the following:
	1. Convert to proper rc.d scripts for mediaproxy and proxydispatcher
	2. Maintains the mediaproxy script as the "master," so the user
	   experience of 'service mediaproxy <start|stop>' will be the same.
	3. Instead of resetting ${WRKSRC}, mv the directory to the more typical
	   name so that we can use mediaproxy.in instead of mediaproxy.sh.in.
	
	The one thing I was not sure about was the order of stopping the
	dispatcher. If it's necessary to stop that before stopping mediaproxy
	then in mediaproxy.in the stop_postcmd can easily be changed to
	stop_precmd. Please let me know. 
>How-To-Repeat:
	DNA
>Fix:
	Apply the following patch:

Index: Makefile
===================================================================
RCS file: /home/pcvs/ports/net/mediaproxy/Makefile,v
retrieving revision 1.10
diff -u -r1.10 Makefile
--- Makefile	19 Mar 2011 13:15:26 -0000	1.10
+++ Makefile	15 May 2011 19:22:05 -0000
@@ -6,7 +6,7 @@
 
 PORTNAME=	mediaproxy
 PORTVERSION=	1.8.2
-PORTREVISION=	3
+PORTREVISION=	4
 CATEGORIES=	net
 MASTER_SITES=	http://mediaproxy.ag-projects.com/ \
 		http://mediaproxy.ag-projects.com/old/
@@ -14,12 +14,12 @@
 MAINTAINER=	steve@energistic.com
 COMMENT=	A far-end NAT traversal solution for SER/OpenSER
 
-USE_RC_SUBR=	mediaproxy.sh
-
-WRKSRC=		${WRKDIR}/${PORTNAME}
+USE_RC_SUBR=	mediaproxy proxydispatcher
 
 USE_PYTHON=	2.5+
 
+SUB_LIST+=	PYTHON_CMD=${PYTHON_CMD}
+
 OPTIONS=	ACCOUNTING "ACCOUNTING support (Requires MySQL)" off
 
 .include <bsd.port.pre.mk>
@@ -28,6 +28,9 @@
 USE_MYSQL=	yes
 .endif
 
+post-extract:
+	@${MV} ${WRKDIR}/${PORTNAME} ${WRKSRC}
+
 post-install:
 	${CP} -pRP ${WRKSRC}/ ${PREFIX}/mediaproxy
 	${CHOWN} -R 0:0 ${PREFIX}/mediaproxy
Index: files/mediaproxy.in
===================================================================
RCS file: files/mediaproxy.in
diff -N files/mediaproxy.in
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ files/mediaproxy.in	15 May 2011 19:22:05 -0000
@@ -0,0 +1,35 @@
+#!/bin/sh
+
+# $FreeBSD$
+#
+# PROVIDE: mediaproxy
+# REQUIRE: LOGIN
+# KEYWORD: shutdown
+#
+# mediaproxy   starts and stops the SER MediaProxy server
+#
+# Add the following line to /etc/rc.conf to enable mediaproxy:
+# mediaproxy_enable (bool):	Set to "NO" by default.
+#				Set it to "YES" to enable mediaproxy.
+#
+# mediaproxy_flags (string):	Set command line options
+
+. /etc/rc.subr
+
+name="mediaproxy"
+rcvar="${name}_enable"
+
+pidfile="/var/run/${name}.pid"
+
+command="%%PREFIX%%/mediaproxy/mediaproxy.py"
+command_interpreter="%%PYTHON_CMD%%"
+command_args="--pid $pidfile"
+
+start_postcmd="%%PREFIX%%/etc/rc.d/proxydispatcher onestart"
+stop_postcmd="%%PREFIX%%/etc/rc.d/proxydispatcher stop"
+
+load_rc_config $name
+
+: ${mediaproxy_enable="NO"}
+
+run_rc_command "$1"
Index: files/mediaproxy.sh.in
===================================================================
RCS file: files/mediaproxy.sh.in
diff -N files/mediaproxy.sh.in
--- files/mediaproxy.sh.in	15 May 2011 02:49:10 -0000	1.3
+++ /dev/null	1 Jan 1970 00:00:00 -0000
@@ -1,88 +0,0 @@
-#!/bin/sh
-
-# $FreeBSD: ports/net/mediaproxy/files/mediaproxy.sh.in,v 1.3 2011/05/15 02:49:10 dougb Exp $
-#
-# mediaproxy   starts and stops the SER MediaProxy server
-
-# PROVIDE: mediaproxy
-
-# Add the following line to /etc/rc.conf to enable mysql:
-# mediaproxy_enable (bool):	Set to "NO" by default.
-#				Set it to "YES" to enable mediaproxy.
-
-. /etc/rc.subr
-
-name="mediaproxy"
-rcvar=`set_rcvar`
-
-load_rc_config $name
-
-: ${mediaproxy_enable="NO"}
-
-INSTALL_DIR="%%PREFIX%%"
-RUNTIME_DIR="/var/run"
-
-PROXY="$INSTALL_DIR/mediaproxy/mediaproxy.py"
-DISPATCHER="$INSTALL_DIR/mediaproxy/proxydispatcher.py"
-PROXY_PID="$RUNTIME_DIR/mediaproxy.pid"
-DISPATCHER_PID="$RUNTIME_DIR/proxydispatcher.pid"
-
-# Options for mediaproxy and dispatcher. Do not include --pid <pidfile>
-# --pid <pidfile> will be added automatically if needed.
-PROXY_OPTIONS=""
-DISPATCHER_OPTIONS=""
-
-NAME="mediaproxy"
-DESC="SER MediaProxy server"
-
-echo $PROXY
-test -f $PROXY      || exit 0
-test -f $DISPATCHER || exit 0
-
-if [ "$PROXY_PID" != "/var/run/mediaproxy.pid" ]; then
-    PROXY_OPTIONS="--pid $PROXY_PID $PROXY_OPTIONS"
-fi
-if [ "$DISPATCHER_PID" != "/var/run/proxydispatcher.pid" ]; then
-    DISPATCHER_OPTIONS="--pid $DISPATCHER_PID $DISPATCHER_OPTIONS"
-fi
-
-start() {
-    if [ $mediaproxy_enable = "YES" ]; then
-        echo -n "Starting $DESC: $NAME"
-        $PROXY $PROXY_OPTIONS
-        $DISPATCHER $DISPATCHER_OPTIONS
-        echo "."
-    fi
-}
-
-stop () {
-    echo -n "Stopping $DESC: $NAME"
-    if [ -f $PROXY_PID ]; then
-        kill `cat $PROXY_PID`
-    fi
-    if [ -f $DISPATCHER_PID ]; then
-        kill `cat $DISPATCHER_PID`
-    fi
-    echo "."
-}
-
-case "$1" in
-    start)
-        start
-        ;;
-    stop)
-        stop
-        ;;
-    restart|force-reload)
-        stop
-        #sleep 1
-        start
-        ;;
-    *)
-        echo "Usage: ${INSTALL_DIR}/etc/rc.d/$NAME {start|stop|restart|force-reload}" >&2
-        exit 1
-        ;;
-esac
-
-exit 0
-
Index: files/proxydispatcher.in
===================================================================
RCS file: files/proxydispatcher.in
diff -N files/proxydispatcher.in
--- /dev/null	1 Jan 1970 00:00:00 -0000
+++ files/proxydispatcher.in	15 May 2011 19:22:05 -0000
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+# $FreeBSD$
+#
+# PROVIDE: proxydispatcher
+# REQUIRE: mediaproxy
+# KEYWORD: nostart
+#
+# proxydispatcher   starts and stops the SER MediaProxy dispatcher
+#
+# This script is usually run by %%PREFIX%%/etc/rc.d/mediaproxy
+#
+# Add the following line to /etc/rc.conf to enable proxydispatcher:
+# proxydispatcher_enable (bool):	Set to "NO" by default.
+#					Set it to "YES" to enable dispatcher.
+# proxydispatcher_flags (string):	Set command line options
+
+. /etc/rc.subr
+
+name="proxydispatcher"
+rcvar="${name}_enable"
+
+pidfile="/var/run/${name}.pid"
+
+command="%%PREFIX%%/mediaproxy/proxydispatcher.py"
+command_interpreter="%%PYTHON_CMD%%"
+command_args="--pid $pidfile"
+
+load_rc_config $name
+
+: ${proxydispatcher_enable="NO"}
+
+run_rc_command "$1"
>Release-Note:
>Audit-Trail:
>Unformatted:



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