ports/146442: Updates for the net/freeswitch rc.d script

Doug Barton dougb at FreeBSD.org
Sun May 9 21:50:02 UTC 2010


>Number:         146442
>Category:       ports
>Synopsis:       Updates for the net/freeswitch rc.d script
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-ports-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Sun May 09 21:50:01 UTC 2010
>Closed-Date:
>Last-Modified:
>Originator:     Doug Barton
>Release:        FreeBSD 7.3-PRERELEASE amd64
>Organization:
AAAG
>Environment:
	DNA
>Description:
	Updates for the net/freeswitch rc.d script
>How-To-Repeat:
	There are numerous problems with this script, some more serious
	than others. The issue that brought it to my attention is the
	"KEYWORD: FreeBSD" that needs to be removed as that has not been
	necessary for years now, and I don't want the example perpetuated.

	Please see http://www.freebsd.org/doc/en_US.ISO8859-1/books/porters-handbook/rc-scripts.html for more information.

	Other changes:
	1. Add a $FreeBSD$ CVS Id
	2. Add KEYWORD: shutdown since this script seems to start a
	   persistent service which should be shut down cleanly when
	   the system is shut down.
	3. Move the default value assignments down after load_rc_config.
	   This is particularly important for _pidfile which would not
	   have actually picked up the value from rc.conf.
	4. Remove the return statements from the ends of the functions,
	   since that's what will happen anyway.
	5. Remove a bunch of trailing whitespace
	These two need testing:
	6. The _restart method is probably not needed, since it is a
	   duplicate of the same procedure from rc.subr.
	7. In the _start method $command_args doesn't seem to be taken
	   into account because the script is not using the method from
	   rc.subr.
>Fix:
	Apply the following patch, then test 6 and 7 above.

Index: freeswitch.in
===================================================================
RCS file: /home/pcvs/ports/net/freeswitch/files/freeswitch.in,v
retrieving revision 1.2
diff -u -r1.2 freeswitch.in
--- freeswitch.in	27 Mar 2010 00:13:42 -0000	1.2
+++ freeswitch.in	9 May 2010 21:35:40 -0000
@@ -1,8 +1,10 @@
 #!/bin/sh
 
+# $FreeBSD$
+#
 # PROVIDE: freeswitch
 # REQUIRE: DAEMON
-# KEYWORD: FreeBSD
+# KEYWORD: shutdown
 
 . /etc/rc.subr
 
@@ -12,39 +14,35 @@
 command=%%PREFIX%%/freeswitch/bin/freeswitch
 command_args="-nc"
 
-pidfile=${freeswitch_pidfile:-"%%PREFIX%%/freeswitch/log/freeswitch.pid"}
-
-freeswitch_enable=${freeswitch_enable-"YES"}
-
 start_cmd="freeswitch_start"
 stop_precmd="freeswitch_stop"
 restart_cmd="freeswitch_restart"
 
-sig_stop=KILL  
-
-load_rc_config $name
+sig_stop=KILL
 
 freeswitch_stop () {
         echo "Stopping Freeswitch."
         %%PREFIX%%/freeswitch/bin/freeswitch -stop
         sleep 1
-        return 0
 }
 
-freeswitch_start () {                                                            
-        echo "Starting FreeSwitch."                                              
-        /usr/sbin/daemon -f /bin/sh -c "$command"
+freeswitch_start () {
+        echo "Starting FreeSwitch."
+        /usr/sbin/daemon -f /bin/sh -c "$command"	# $command_args?
         sleep 1
-        return
 }
 
+# Probably not necessary?
 freeswitch_restart () {
-        echo "ReStarting FreeSwitch."
-        freeswitch_stop                                                      
+        echo "Restarting FreeSwitch."
+        freeswitch_stop
         freeswitch_start
         sleep 1
-        return
-} 
+}
 
-run_rc_command "$1"
+load_rc_config $name
 
+: ${freeswitch_enable="YES"}
+pidfile="${freeswitch_pidfile:-"%%PREFIX%%/freeswitch/log/freeswitch.pid"}"
+
+run_rc_command "$1"
>Release-Note:
>Audit-Trail:
>Unformatted:



More information about the freebsd-ports-bugs mailing list