[svn-commits] tzafrir: branch tzafrir/zaphelper r2033 - in /team/tzafrir/zaphelper: ./ exam...

svn-commits at lists.digium.com svn-commits at lists.digium.com
Tue Jan 30 17:52:04 MST 2007


Author: tzafrir
Date: Tue Jan 30 18:52:03 2007
New Revision: 2033

URL: http://svn.digium.com/view/zaptel?view=rev&rev=2033
Log:
 * Fixed some syntax and such errors:
 - Call "unload" instead of unload_modules" that did not exist.
 - Don't check for $system = 'redhat' if you're in a distro-specific 
   script anyway.
 * Added a few other helpers:
 - kill_zaptel_users: kill all the processes that have a zaptel file open.
   Otherwise they would have prevented Zaptel modules from shutting down.
 - run_fxotune: run fxotune without completely shutting down Asterisk.
   This one is over-aggressive and thus potentially dangerous.
 - xpp_blink: Identify Astrianks by blinking their leds.
 - run_adj_clock: for xpp/utils/adj_clock

Modified:
    team/tzafrir/zaphelper/examples/zaptel.rh.init
    team/tzafrir/zaphelper/examples/zaptel.suse.init
    team/tzafrir/zaphelper/zaptel-helper

Modified: team/tzafrir/zaphelper/examples/zaptel.rh.init
URL: http://svn.digium.com/view/zaptel/team/tzafrir/zaphelper/examples/zaptel.rh.init?view=diff&rev=2033&r1=2032&r2=2033
==============================================================================
--- team/tzafrir/zaphelper/examples/zaptel.rh.init (original)
+++ team/tzafrir/zaphelper/examples/zaptel.rh.init Tue Jan 30 18:52:03 2007
@@ -41,11 +41,9 @@
 case "$1" in
 start)
 	echo -n "Loading zaptel hardware modules:"
-	if [ "$system" = redhat ]; then
-		for mod in ${MODULES}; do
-			modprobe $mod
-		done
-	fi
+	for mod in ${MODULES}; do
+		modprobe $mod
+	done
 
 	# Get the Astribank module loaded properly:
 	init_astribank
@@ -67,10 +65,8 @@
 	[ $RETVAL -eq 0 ] && touch $LOCKFILE
 	;;
 stop)
-	# Unload drivers
-	# FIXME: Not for Debian?
 	echo -n "Unloading zaptel hardware drivers:"
-	unload_modules
+	unload
 	echo .
 	
 	RETVAL=$?

Modified: team/tzafrir/zaphelper/examples/zaptel.suse.init
URL: http://svn.digium.com/view/zaptel/team/tzafrir/zaphelper/examples/zaptel.suse.init?view=diff&rev=2033&r1=2032&r2=2033
==============================================================================
--- team/tzafrir/zaphelper/examples/zaptel.suse.init (original)
+++ team/tzafrir/zaphelper/examples/zaptel.suse.init Tue Jan 30 18:52:03 2007
@@ -50,11 +50,9 @@
 case "$1" in
 start)
 	echo -n "Loading zaptel hardware modules:"
-	if [ "$system" = redhat ]; then
-		for mod in ${MODULES}; do
-			modprobe $mod
-		done
-	fi
+	for mod in ${MODULES}; do
+		modprobe $mod
+	done
 
 	# Get the Astribank module loaded properly:
 	init_astribank
@@ -79,7 +77,7 @@
 	# Unload drivers
 	# FIXME: Not for Debian?
 	echo -n "Unloading zaptel hardware drivers:"
-	unload_modules
+	unload
 	echo .
 	
 	$ZTCFG || rc_failed 1 ; rc_status -v

Modified: team/tzafrir/zaphelper/zaptel-helper
URL: http://svn.digium.com/view/zaptel/team/tzafrir/zaphelper/zaptel-helper?view=diff&rev=2033&r1=2032&r2=2033
==============================================================================
--- team/tzafrir/zaphelper/zaptel-helper (original)
+++ team/tzafrir/zaphelper/zaptel-helper Tue Jan 30 18:52:03 2007
@@ -86,6 +86,10 @@
 	fi
 }
 
+kill_zaptel_users() {
+	fuser -k /dev/zap/*
+}
+
 # recursively unload a module and its dependencies, if possible.
 # where's modprobe -r when you need it?
 # inputs: module to unload.
@@ -165,10 +169,55 @@
 	fi
 }
 
+run_adj_clock() {
+	if [ "$XPP_RUN_ADJ_CLOCK" = '' ]; then return; fi
+
+	# daemonize adj_clock:
+	(adj_clock </dev/null >/dev/null 2>&1 &)&
+}
+
 init_astribank() {
-	wait_fox_xpp
+	wait_for_xpp
 	zap_reg_xpp
 	fix_asterisbank_sync
+	run_adj_clock
+}
+
+xpp_do_blink() {
+	val="$1"
+	shift
+	for xbus in $*
+	do
+		for xpd in /proc/xpp/XBUS-"$xbus"/XPD-*
+		do
+			echo "$val" > "$xpd/blink"
+		done
+	done
+}
+
+xpp_blink() {
+	xbuses=`grep STATUS=connected /proc/xpp/xbuses | sed -e 's/^XBUS-//' -e 's/:.*$//'`
+	num=`echo $1 | tr -c -d 0-9`
+	case "$num" in
+	[0-9]*)
+		shift
+		xpp_do_blink 1 $xbuses
+		sleep 2
+		xpp_do_blink 0 $xbuses
+		;;
+	*)
+		shift
+		echo 1>&2 Enumerating $xbuses
+		xpp_do_blink 0 $xbuses
+		for i in $xbuses
+		do
+			echo "BLINKING: $i"
+			xpp_do_blink 1 "$i"
+			sleep 2
+			xpp_do_blink 0 "$i"
+		done
+		;;
+	esac
 }
 
 # The current Debian start function.
@@ -189,6 +238,23 @@
 }
 
 
+# run_fxotune: destroy all FXO channels and run fxotune.
+# This allows running fxotune without completly shutting down Asterisk.
+#
+# A simplistic assumption: every zaptel channel in the context from-pstn 
+# is a FXO ones.
+# or rather: all tunable FXO channels are in the context from-pstn are
+# not defined by zaptel.
+run_fxotune() {
+  xpp_fxo_chans=`cat /proc/zaptel/* | awk '/XPP_FXO/{print $1}'`
+  for chan in $xpp_fxo_chans; do
+    asterisk -rx "zap destroy channel $chan"
+  done
+  $FXOTUNE
+  asterisk -rx "zap restart"
+}
+
+
 # recursively unload a module and its dependencies, if possible.
 # where's modprobe -r when you need it?
 # inputs: module to unload.
@@ -209,6 +275,10 @@
 	done
 	rmmod $module || true
 	set -e
+}
+
+unload() {
+	unload_module zaptel
 }
 
 # sleep a while until the xpp modules fully register
@@ -302,6 +372,6 @@
 
 # unless we wanted to use this as a set of functions, run 
 # the given function with its parameters:
-if [ "$ZAPHELPER_ONLY_INCLUDE" != '' ]; then
+if [ "$ZAPHELPER_ONLY_INCLUDE" = '' ]; then
   "$@"
 fi



More information about the svn-commits mailing list