Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 11 Feb 2011 13:08:03 GMT
From:      Mikhail <warrior-frela@mail.ru>
To:        freebsd-gnats-submit@FreeBSD.org
Subject:   ports/154682: [net/iaxmodem] add rc script for running more than 1 iaxmodem with configuration files
Message-ID:  <201102111308.p1BD83cn071392@red.freebsd.org>
Resent-Message-ID: <201102111310.p1BDA7Nj046298@freefall.freebsd.org>

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

>Number:         154682
>Category:       ports
>Synopsis:       [net/iaxmodem] add rc script for running more than 1 iaxmodem with configuration files
>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:   Fri Feb 11 13:10:07 UTC 2011
>Closed-Date:
>Last-Modified:
>Originator:     Mikhail
>Release:        7.3-STABLE
>Organization:
Meganet
>Environment:
FreeBSD 7.3-STABLE FreeBSD 7.3-STABLE #1: Thu May 13 12:24:05 MSD 2010     root@gate..ru:/usr/obj/usr/src/sys/GENERIC  i386
>Description:
new script running more than 1 iaxmodem, it`s needed for more than 1 receiving or sending fax message
>How-To-Repeat:
-
>Fix:
new script

Patch attached with submission follows:

--- iaxmodem.in.orig	2011-02-11 16:00:42.000000000 +0300
+++ iaxmodem.in	2011-02-11 16:06:33.000000000 +0300
@@ -6,20 +6,50 @@
 
 #
 # Add the following lines to /etc/rc.conf to enable iaxmodem:
-#
-# iaxmodem_enable="YES"
-#
+# iaxmodem_enable (bool):   Set to NO by default.
+#               Set it to YES to enable iaxmodem.
+# iaxmodem_daemons (array): 
+#	array of names of configuration files for running modems which located in /usr/local/etc/iaxmodem/
+# EXAMPLE:
+# 	iaxmodem_enable="YES"
+# 	iaxmodem_daemons="ttyIAX1 ttyIAX2 ttyIAX3 ttyIAX4 ttyIAX5 ttyIAX6 ttyIAX7 ttyIAX8 ttyIAX9 ttyIAX10"
 
 . /etc/rc.subr
 
 name=iaxmodem
 rcvar=`set_rcvar`
 
-command=%%PREFIX%%/sbin/iaxmodem
+load_rc_config $name
 
-pidfile=${iaxmodem_pidfile:-"/var/run/iaxmodem.pid"}
+_daemon_cmd="/usr/sbin/daemon"
 
 iaxmodem_enable=${iaxmodem_enable:-"NO"}
 
-load_rc_config $name
-run_rc_command "$1"
+do_cmd() {
+	local ret
+	ret=0
+	for daemon in ${iaxmodem_daemons}; do
+		pidfile=/var/run/iaxmodem/${daemon}.pid	
+		command="/usr/local/sbin/iaxmodem"
+		flags="-fp ${pidfile} /usr/local/sbin/iaxmodem ${daemon}"
+		name="iaxmodem_${daemon}"
+		case "$1" in
+			restart)
+				run_rc_command "stop"
+				command=${_daemon_cmd}
+				run_rc_command "start"
+			;;
+			start)
+				command=${_daemon_cmd}
+				run_rc_command "$1" || ret=1
+			;;
+			*)
+				run_rc_command "$1"
+		        ;;
+		esac
+		_rc_restart_done=false
+	done
+	return ${ret}
+}
+
+do_cmd "$1"


>Release-Note:
>Audit-Trail:
>Unformatted:



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