[Pkg-voip-commits] r1003 - in zaptel/trunk/debian: . patches

Tzafrir Cohen tzafrir-guest at costa.debian.org
Fri Nov 18 02:20:21 UTC 2005


Author: tzafrir-guest
Date: 2005-11-18 02:20:21 +0000 (Fri, 18 Nov 2005)
New Revision: 1003

Added:
   zaptel/trunk/debian/patches/echocan_env.dpatch
Modified:
   zaptel/trunk/debian/genzaptelconf
   zaptel/trunk/debian/genzaptelconf.8
Log:
* echocan_env.dpatch: allow changing the echo canceller at zaptel modules 
  build time
* updates to genazptelconf.


Modified: zaptel/trunk/debian/genzaptelconf
===================================================================
--- zaptel/trunk/debian/genzaptelconf	2005-11-18 00:02:11 UTC (rev 1002)
+++ zaptel/trunk/debian/genzaptelconf	2005-11-18 02:20:21 UTC (rev 1003)
@@ -4,7 +4,7 @@
 #		/etc/zaptel.conf
 #		/etc/asterisk/zapata-channels.conf (to be #include-d into zapata.conf)
 #	update:
-#		/etc/default/zaptel (list of modules to load)
+#		With '-M' /etc/modules (list of modules to load)
 #
 # Copyright (C) 2005 by Xorcom <support at xorcom.com>
 #
@@ -35,20 +35,31 @@
 
 # The script uses a number of bash-specific features
 # TODO: either ditch them or convert to perl
+# Don't override variables here. Override them in /etc/default/zaptel
 
 # /etc/default/zaptel may override the following variables
-VERSION=0.3.5
+VERSION=0.3.7
 lc_country=us
 #method=ls
 #method=ks
 base_exten=6000
+# If set: no context changes are made in zapata-channels.conf
+#context_manual=yes
+context_lines=from-pstn      # context into which PSTN calls go
+context_phones=from-internal # context for internal phones calls.
+# TODO: what about PRI/BRI?
+# If set: no group changes are made in zapata-channels.conf
+#group_manual=yes
+group_phones=0 # group for phones
+group_lines=1  # group for lines
 
 ZAPCONF_FILE=/etc/zaptel.conf
 ZAPATA_FILE=/etc/asterisk/zapata-channels.conf
 ZAPTEL_BOOT=/etc/default/zaptel
+MODLIST_FILE=/etc/modules
 exten_base_dir=/etc/asterisk/extensions-phones.d
 exten_defs_file=/etc/asterisk/extensions-defs.conf
-ztcfg_cmd=ztcfg
+ZTCFG=/sbin/ztcfg
 
 # a temporary directory. Created when the switch -r is parsed on getopts
 # and deleted in the end on update_extensions_defs
@@ -57,13 +68,17 @@
 # read default configuration from /etc/default/zaptel
 if [ -r $ZAPTEL_BOOT ]; then . $ZAPTEL_BOOT; fi
 
+# it is safe to use -c twice: the last one will be used.
+ztcfg_cmd="$ZTCFG -c $ZAPCONF_FILE"
+
 # work around a bug (that was already fixed) in the installer:
 if [ "$lc_country" = '' ]; then lc_country=us; fi
 
-ALL_MODULES="zaphfc qozap wctdm wcfxo wcfxs pciradio tor2 torisa wct1xxp wct4xxp wcte11xp wcusb ztd_eth ztdummy"
+ALL_MODULES="zaphfc qozap wctdm wcfxo wcfxs pciradio tor2 torisa wct1xxp wct4xxp wcte11xp wcusb ztd_eth ztdummy xpp_usb xpp"
 force_stop_ast=no
 do_detect=no
 do_unload=no
+do_module_list=no
 verbose=no
 rapid_extens=''
 # global: current extension number in extensions list. Should only be 
@@ -92,6 +107,23 @@
 	fi
 }
 
+update_module_list() {
+	del_args=`for i in $ALL_MODULES
+	do
+		echo "$i" | sed s:.\*:-e\ '/^&/d':
+	done`
+	add_args=`for i in $*
+	do
+		echo "$i" | sed s:.\*:-e\ '\$a&':
+	done`
+	
+	sed -i.bak $del_args "$MODLIST_FILE"
+	for i in $*
+	do
+		echo "$i"
+	done >> "$MODLIST_FILE"
+}
+
 do_update() {
 	if [ ! -d `dirname ${ZAPTEL_BOOT}` ]
 	then
@@ -167,7 +199,7 @@
 	echo >&2 "  -e NUM: set the base extension number (default: $base_exten)"
 	echo >&2 "  -m: set signalling method (gs/ks/ls, default: $method)"
 	echo >&2 "  -l: output a list of detected channels instead of zaptel.conf"
-	echo >&2 "  -d: Perform hardware detection -- update /etc/default/zaptel"
+	echo >&2 "  -d: Perform hardware detection"
 	echo >&2 "  -u: Unload zaptel modules"
 	echo >&2 "  -v: verbose"
 	echo >&2 "  -s: Don't fail if asterisk is running. Stop it"
@@ -231,9 +263,21 @@
 			fi
 			echo "callerid=\"Channel $chan\" <$exten>"
 			echo "mailbox=$exten"
+			if [ "$group_manual" != "yes" ]
+			then 
+				echo "group=$group_phones"
+			fi
+			if [ "$context_manual" != "yes" ]
+			then 
+				echo "context=$context_phones"
+			fi
 		else # we have may have set it. So reset it:
 			echo "callerid=\"\" <0>"
 			echo "mailbox="
+			if [ "$context_manual" != "yes" ]
+			then 
+				echo "context=$context_lines"
+			fi
 			echo "cidsignalling=v23"
 			case $line in 
 			*WCFXO*) echo "cidstart=history";;
@@ -334,8 +378,11 @@
 	if [ "$modlist" = '' ]; then
 		modlist=ztdummy			# Fallback
 	fi
-	say "Updating '${ZAPTEL_BOOT}'"
-	do_update ZAPTEL_MODS  "$modlist"
+	if [ "$do_module_list" = yes ]
+	then
+		say "Updating '${MODLIST_FILE}'"
+		update_module_list "$modlist"
+	fi
 }
 
 check_tdm_sigtype() {
@@ -468,6 +515,12 @@
 				check_tdm_sigtype $chan_num fxo $mode || \
 				echo "$rem_char channel $chan_num, WCFXO, inactive."
 				;;
+			*XPP_FXO/*)
+				print_pattern $chan_num fxs $mode
+				;;
+			*XPP_FXS/*)
+				print_pattern $chan_num fxo $mode
+				;;
 			*ZTHFC*/*|*ztqoz*/*|*WCT1/*) # should also be used for other PRI channels
 				if [ "`cat $tmp_dir/span_begin`" = "-1" ]
 				then
@@ -484,6 +537,17 @@
 						echo 'b8zs'      >$tmp_dir/span_coding
 						echo 'national'  >$tmp_dir/span_switchtype
 						echo 'pri_cpe'   >$tmp_dir/span_signalling
+						# an example of country-specific setup. This is probably not accurate
+						# Contributions are welcome
+						case "$lc_country" in dk)
+							# (Just an example for per-country info)
+							echo 'ccs'       >$tmp_dir/span_framing
+							echo 'hdb3'      >$tmp_dir/span_coding
+							echo 'crc4'      >$tmp_dir/span_yellow
+							echo 'euroisdn'  >$tmp_dir/span_switchtype
+							echo 'pri_cpe'   >$tmp_dir/span_signalling
+							;;
+						esac
 					;;
 					esac
 				fi
@@ -499,12 +563,13 @@
 		then # write PRI span ocnfig:
 			# read files to variables:
 			for suffix in num begin end timing lbo framing \
-				coding switchtype signalling
+				coding switchtype signalling yellow
 			do
-				eval span_$suffix=`cat $tmp_dir/span_$suffix`
+				eval span_$suffix=`cat $tmp_dir/span_$suffix 2>/dev/null`
 			done
+			if [ "$span_yellow" != '' ]; then span_yellow=",$span_yellow"; fi
 			# exactly the same logic is used in asterisk's chan_zap.c.
-			# aslo not that $(( )) is bash-specific
+			# also not that $(( )) is bash-specific
 			case "$((1+ $span_end - $span_begin))" in
 			3|24) #BRI or T1
 			  dchan=$span_end
@@ -517,7 +582,7 @@
 			esac
 			case "$mode" in
 			zaptel)
-				echo span=$span_num,$span_timing,$span_lbo,$span_framing,$span_coding
+				echo span=$span_num,$span_timing,$span_lbo,$span_framing,$span_coding$span_yellow
 				echo bchan=$bchans
 				echo dchan=$dchan
 				;;
@@ -550,7 +615,7 @@
 	fi
 }
 
-while getopts 'c:de:E:hlm:rsuv' arg
+while getopts 'c:de:hlm:Mrsuv' arg
 do
 	case "$arg" in
 		e) # guarantee that it is a number:
@@ -568,6 +633,7 @@
 			*) echo >&2 "unknown signalling method ${OPTARG}s, defaulting to \"$method\"";;
 			esac
 			;;
+		M) do_module_list=yes; do_detect=yes ;;
 		s) force_stop_ast=yes ;;
 		r) 
 			rapid_conf_mode=yes 
@@ -583,7 +649,7 @@
 	exit 1
 fi
 
-tmp_dir=`mktemp -d genzaptelconf.XXXXXX` || \
+tmp_dir=`mktemp -d -t` || \
 	die "$0: failed to create temporary directory. Aborting"
 
 
@@ -615,7 +681,7 @@
 then
   /etc/init.d/asterisk stop 1>&2
 else
-	if ps auxww |grep asterisk | grep -v -- -r | grep -q -v grep
+	if pidof asterisk >/dev/null
 	then
 	  echo >&2 "Asterisk is already running. Configuration left untouched"
 		echo >&2 "You can use the option -s to shut down Asterisk for the"
@@ -648,13 +714,21 @@
 	run_ztcfg
 fi
 
+if [ "$tmp_dir" != '' ]
+then
+  rm -rf "$tmp_dir"
+fi
+
 if [ "$force_stop_ast" = 'yes' ]
 then
-  /etc/init.d/asterisk start 1>&2
+  if [ -x /etc/init.d/asterisk ]
+  then
+    /etc/init.d/asterisk start 1>&2
+  fi
 fi
 
 # if in verbose mode: verify that asterisk is running
-if [ "$verify" != 'no' ]
+if [ "$verbose" != 'no' ] && [ "$force_stop_ast" = 'yes' ]
 	then
 	say "Checking channels configured in Asterisk:"
 	sleep 1 # give it some time. This is enough on our simple test server
@@ -665,3 +739,5 @@
 		asterisk -rx "zap show channels"
 	fi
 fi
+
+# vim:ts=2:

Modified: zaptel/trunk/debian/genzaptelconf.8
===================================================================
--- zaptel/trunk/debian/genzaptelconf.8	2005-11-18 00:02:11 UTC (rev 1002)
+++ zaptel/trunk/debian/genzaptelconf.8	2005-11-18 02:20:21 UTC (rev 1003)
@@ -81,6 +81,19 @@
 above).
 .RE
 
+.B -M
+.RS
+Update
+.I /etc/modules
+with a list of our modules, thereby
+triggers their loading via modprobe on the next boot.
+
+This triggers the
+.I -d
+option as well.
+.RE
+
+
 .B -m k|l
 .RS
 Sets the signalling mode: Kewlstart or Loopstart. By default the 
@@ -143,7 +156,8 @@
 .I chan_zap.
 Not modified directly by 
 .I genzaptelconf.
-If you want genzaptelconf's setting to take effect, add the following line at the end of 
+If you want genzaptelconf's setting to take effect, add the following 
+line at the end of 
 .I zapata.conf:
 .RS
 #include "zapata-channels.conf"
@@ -169,10 +183,25 @@
 This file holds configuration for both 
 .I genzaptelconf
 and
-.I /etc/init.d/zaptel 
- . 
+.I /etc/init.d/zaptel .
 .RE
 
+.I /etc/modules
+.RS
+A debian-specific list of kernel modules to be loaded by modprobe at 
+boot time. When the option 
+.I -d
+(detect) is used, genzaptelconf will write in this file zaptel modules
+to be loaded. If you want to use a different file, set 
+.I MOD_FILELIST
+.RE
+
+.I /etc/modules.bak
+.RS
+The backup copy of 
+.I /etc/modules
+.RE
+
 .SH "SEE ALSO" 
 ztcfg(8) asterisk(8). 
 

Added: zaptel/trunk/debian/patches/echocan_env.dpatch
===================================================================
--- zaptel/trunk/debian/patches/echocan_env.dpatch	2005-11-18 00:02:11 UTC (rev 1002)
+++ zaptel/trunk/debian/patches/echocan_env.dpatch	2005-11-18 02:20:21 UTC (rev 1003)
@@ -0,0 +1,48 @@
+#! /bin/sh /usr/share/dpatch/dpatch-run
+## echhcan_env.dpatch by Tzafrir Cohen <tzafrir.cohen at xorcom.com>
+##
+## All lines beginning with `## DP:' are a description of the patch.
+## DP: Allow setting the echo cancceler from the environment at (modules) 
+## DP: build time.
+
+ at DPATCH@
+diff -urNad zaptel-1.1.9.0rc1/Makefile /tmp/dpep.m12xU5/zaptel-1.1.9.0rc1/Makefile
+--- zaptel-1.1.9.0rc1/Makefile	2005-11-10 09:02:00.424207126 +0200
++++ /tmp/dpep.m12xU5/zaptel-1.1.9.0rc1/Makefile	2005-11-10 09:04:15.366618603 +0200
+@@ -217,7 +217,12 @@
+ 
+ gendigits: LDFLAGS+=-lm
+ 
+-zaptel.c: tones.h 
++ifndef EC_TYPE
++  EC_TYPE:=KB1
++endif
++# only for for 2.6 kernel:
++EXTRA_CFLAGS+=-DECHO_CAN_SET -DECHO_CAN_$(EC_TYPE)
++zaptel.c: tones.h
+ 
+ prereq: tones.h tor2fw.h radfw.h
+ 
+diff -urNad zaptel-1.1.9.0rc1/zconfig.h /tmp/dpep.m12xU5/zaptel-1.1.9.0rc1/zconfig.h
+--- zaptel-1.1.9.0rc1/zconfig.h	2005-11-10 09:01:58.140487865 +0200
++++ /tmp/dpep.m12xU5/zaptel-1.1.9.0rc1/zconfig.h	2005-11-10 09:02:01.534070690 +0200
+@@ -44,12 +44,18 @@
+  * Pick your echo canceller: MARK2, MARK3, STEVE, or STEVE2 :)
+  * 
+  */ 
++
++// you must define externally both ECHO_CAN_SET and ECHO_CAN_foo
++#ifndef ECHO_CAN_SET
++#define ECHO_CAN_SET ECHO_CAN_KB1
++#define ECHO_CAN_KB1
++#endif
+ /* #define ECHO_CAN_STEVE */
+ /* #define ECHO_CAN_STEVE2 */
+ /* #define ECHO_CAN_MARK */
+ /* #define ECHO_CAN_MARK2 */
+ /* #define ECHO_CAN_MARK3 */
+-#define ECHO_CAN_KB1
++/*#define ECHO_CAN_KB1 */
+ /* MG2 is a version of KB1 that has some changes to it that are
+  * supposed to improve how it performs.  If you have echo problems,
+  * try it out! */


Property changes on: zaptel/trunk/debian/patches/echocan_env.dpatch
___________________________________________________________________
Name: svn:executable
   + *




More information about the Pkg-voip-commits mailing list