summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2007-07-04 16:43:22 +0000
committertzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2007-07-04 16:43:22 +0000
commitf6e6153c44daa44cf9922e49e2d337e23e2d02dc (patch)
treeaeb200c8f3f5c43418843f722ffa0003e1071b62
parentc963f0243b078172d27c9dbbc055bc5b510ac485 (diff)
* Fix unloading of xpp modules.
* Initialize the Astribank (xpp) using the zaptel-perl utilities. (in trunk they are installed by default) (From branches/1.2 changesset:2670 and changeset:2673) git-svn-id: http://svn.digium.com/svn/zaptel/trunk@2686 5390a7c7-147a-4af0-8ec9-7488f05a26cb
-rw-r--r--zaptel.init83
1 files changed, 20 insertions, 63 deletions
diff --git a/zaptel.init b/zaptel.init
index 273cbb6..04916f7 100644
--- a/zaptel.init
+++ b/zaptel.init
@@ -13,6 +13,8 @@ initdir=/etc/init.d
ZTCFG=/sbin/ztcfg
ZTCFG_CMD="$ZTCFG" # e.g: for a custom zaptel.conf location
+XPP_SYNC=auto
+
#
# Determine which kind of configuration we're using
#
@@ -52,6 +54,9 @@ unload_module() {
set -- $line
# $1: the original module, $2: size, $3: refcount, $4: deps list
mods=`echo $4 | tr , ' '`
+ # xpp_usb keeps the xpds below busy if an xpp hardware is
+ # connected. Hence must be removed before them:
+ case "$module" in xpd_*) mods="xpp_usb $mods";; esac
for mod in $mods; do
# run in a subshell, so it won't step over our vars:
(unload_module $mod)
@@ -61,69 +66,23 @@ unload_module() {
rmmod $module
}
-# Wait for Astribank to initialize registers:
-wait_for_xpp() {
- if [ ! -d /proc/xpp ]; then return; fi
-
- # reading from waitfor_xpds only returns when the device
- # has finished initilizing its regiters and is available.
- cat /proc/xpp/XBUS-*/waitfor_xpds 2>/dev/null >/dev/null || true
-}
+# Initialize the Xorcom Astribank (xpp/) using perl utiliites:
+# intended to replace all the the three functions below if user has
+# installed the zaptel-perl utilities.
+xpp_startup() {
+ # do nothing if there are no astribank devices:
+ if ! grep -q connected /proc/xpp/xbuses 2>/dev/null; then return 0; fi
-# Register to zaptel Astribank spans that were not autoomatically registered
-# (useful when you have more than one Astribank)
-zap_reg_xpp() {
- if [ ! -d /proc/xpp ]; then return; fi
+ echo "Waiting for Astribank devices to initialize:"
+ cat /proc/xpp/XBUS-[0-9]*/waitfor_xpds 2>/dev/null || true
- # Get a list of connected Astribank devices, sorted by the name of
- # the USB connector. That order is rather arbitrary, but will not
- # change without changes to the cabling.
- xbusses=`sort -k 2 /proc/xpp/xbuses | awk -F: '/STATUS=connected/ {print $1}'`
-
- # get a list of XPDs that were not yet registered as zaptel spans.
- # this will be the case if you set the parameter zap_autoreg=0 to
- # the module xpp
- # Append /dev/null to provide a valid file name in case of an empty pattern.
- xbusses_pattern=`echo $xbusses| sed -e 's|XBUS-[0-9]*|/proc/xpp/&/XPD-*/zt_registration|g'`' /dev/null'
- xpds_to_register=`grep -l 0 $xbusses_pattern 2>/dev/null` || true
- for file in $xpds_to_register; do
- echo 1 >$file
- done
-}
+ # overriding locales for the above two, as perl can be noisy
+ # when locales are missing.
+ # No register all the devices if they didn't auto-register:
+ LC_ALL=C zt_registration on
-# If the system has an Astribank, select the right one as the sync source.
-# TODO: replace the sryptic awk code with 'xpp_sync auto' once it is in.
-fix_asterisbank_sync() {
- # do nothing if module not present
- if [ ! -d /proc/xpp ]; then return; fi
-
- #if ! grep -q '^HOST' /proc/xpp/sync 2>/dev/null; then return; fi
-
- case "$XPP_SYNC" in
- n*|N*) return;;
- host|HOST) sync_value="HOST";;
- [0-9]*)sync_value="$XPP_SYNC";;
- *)
- # find the number of the first bus, and sync from it:
- fxo_pat=`awk -F: '/STATUS=connected/{print $1}' /proc/xpp/xbuses | sed -e 's|.*|/proc/xpp/&/*/fxo_info|'`
- # find the first FXO unit, and set it as the sync master
- bus=`ls -1 $fxo_pat 2> /dev/null | head -n1 | cut -d- -f2 | cut -d/ -f1`
-
- if [ "$bus" = '' ]; then
- # no device with FXO found. Just get the first one
- bus=`awk -F: '/STATUS=connected/{print $1}' /proc/xpp/xbuses | head -n 1 | cut -d- -f2`
- fi
-
- # do nothing if there is no bus:
- case "$bus" in [0-9]*):;; *) return;; esac
- sync_value="SYNC=$bus"
- ;;
- esac
- # the built-in echo of bash fails to print a proper error on failure
- if ! /bin/echo "$sync_value" >/proc/xpp/sync
- then
- echo >2 "Updating XPP sync source failed (tried \"$sync_value\", XPP_SYNC='$XPP_SYNC')"
- fi
+ # this one could actually be run after ztcfg:
+ LC_ALL=C xpp_sync "$XPP_SYNC"
}
hpec_start() {
@@ -236,9 +195,7 @@ case "$1" in
done
sleep 3 # TODO: remove it
- wait_for_xpp
- zap_reg_xpp
- fix_asterisbank_sync # can actually be run after ztcfg
+ xpp_startup
if head -c 0 /dev/zap/pseudo; then
echo "No Zaptel timing source sound. loading ztdummy"