[svn-commits] tzafrir: branch 1.4 r3308 - in /branches/1.4: README live_zap
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Tue Dec 4 17:15:05 CST 2007
Author: tzafrir
Date: Tue Dec 4 17:15:04 2007
New Revision: 3308
URL: http://svn.digium.com/view/zaptel?view=rev&rev=3308
Log:
live_zap - A script to test Zaptel without fully installing it.
Added:
branches/1.4/live_zap (with props)
Modified:
branches/1.4/README
Modified: branches/1.4/README
URL: http://svn.digium.com/view/zaptel/branches/1.4/README?view=diff&rev=3308&r1=3307&r2=3308
==============================================================================
--- branches/1.4/README (original)
+++ branches/1.4/README Tue Dec 4 17:15:04 2007
@@ -239,6 +239,28 @@
make install DESTDIR=$PWD/target DYNFS=
+Test Install: live_ast
+^^^^^^^^^^^^^^^^^^^^^^
+If you need to test a version of Zaptel without touching the version
+installed on your system, you can use the script live_zap . Note,
+however, that it may take some extra configuration to be used right.
+
+Basica usage:
+
+ ./configure
+ make
+ ./live_ast install # instead of 'make install'
+ ./live_ast config # instead of 'make config'
+ ./live_ast unload # instead of '/etc/init.d/zaptel stop'
+ ./live_ast load # instead of '/etc/init.d/zaptel start'
+
+Everything is installed under the subdirectory live/ . You will probably
+need to adjust MODULES . Generally you should not edit the script
+itself, but , rather, edit live/live.conf . Please let me know if you
+needed to change anything in the script beyond changing live.conf so I
+can include useful fixes.
+
+
./configure Options
^^^^^^^^^^^^^^^^^^^
The configure script various several tests and based on them generates
Added: branches/1.4/live_zap
URL: http://svn.digium.com/view/zaptel/branches/1.4/live_zap?view=auto&rev=3308
==============================================================================
--- branches/1.4/live_zap (added)
+++ branches/1.4/live_zap Tue Dec 4 17:15:04 2007
@@ -1,0 +1,121 @@
+#!/bin/sh
+
+set -e
+
+DESTDIR=$PWD/live
+KVERS=${KVERS:-`uname -r`}
+MODULES_DIR="$DESTDIR/lib/modules/$KVERS/misc"
+XPP_SYNC=auto
+AST_SCRIPT=/etc/init.d/asterisk
+# Use this file to pass options to modules:
+MODPROBE_FILE=$DESTDIR/modprobe.conf
+PERLLIBDIR=`perl -V:sitelib | cut -d "'" -f 2`
+
+# Manual list of modules. They will be loaded by insmod.
+# If reside in a subdir, add it explicitly.
+MODULES_LOAD="zaptel xpp/xpp xpp/xpd_fxs xpp/xpd_fxo xpp/xpp_usb"
+
+if [ -r $DESTDIR/live.conf ]; then . $DESTDIR/live.conf; fi
+
+# 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
+
+ echo "Waiting for Astribank devices to initialize:"
+ cat /proc/xpp/XBUS-[0-9]*/waitfor_xpds 2>/dev/null || true
+
+ # 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
+
+ # this one could actually be run after ztcfg:
+ LC_ALL=C xpp_sync "$XPP_SYNC"
+}
+
+# recursively unload a module and its dependencies, if possible.
+# where's modprobe -r when you need it?
+# inputs: module to unload.
+# returns: the result from
+unload_module() {
+ module="$1"
+ line=`lsmod 2>/dev/null | grep "^$1 "`
+ if [ "$line" = '' ]; then return; fi # module was not loaded
+
+ 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)
+ # TODO: the following is probably the error handling we want:
+ # if [ $? != 0 ]; then return 1; fi
+ done
+ rmmod $module
+}
+
+usage() {
+ me=`basename $0`
+ echo "$me: Run Zaptel in a test environment"
+ echo 'Version: $Id$'
+ echo ''
+ echo "Usage: equivalent of:"
+ echo "$me install make install"
+ echo "$me config make config"
+ echo "$me unload /etc/init.d/zaptel stop"
+ echo "$me load /etc/init.d/zaptel start"
+}
+
+# Give priority to our installed binaries:
+PATH=$DESTDIR/sbin:$DESTDIR/usr/sbin:$PATH
+export PATH
+
+# TODO: If you already use PERL5DIR, please fix this part:
+PERL5LIB="$DESTDIR/$PERLLIBDIR"
+export PERL5LIB
+
+case "$1" in
+install)
+ make install DESTDIR=$DESTDIR
+ ;;
+config)
+ make config DESTDIR=$DESTDIR
+ touch $MODPROBE_FILE
+ mkdir -p $DESTDIR/etc/asterisk
+ ;;
+unload)
+ $AST_SCRIPT stop
+ unload_module zaptel
+ ;;
+load)
+ # TODO: Find a way to use modprobe.
+ # Or implement a way to pass arguments to modules here (yuck)
+ for module in $MODULES_LOAD; do
+ insmod $MODULES_DIR/$module.ko
+ done
+ xpp_startup
+ ZAPTEL_FILE=$DESTDIR/etc/zaptel.conf \
+ ZAPATA_FILE=$DESTDIR/etc/asterisk/zapata-channels.conf \
+ zapconf
+ ztcfg
+ # TODO: fxotune, hpec
+ # or find a way to reuse init.d start sequence.
+
+ # TODO: A local copy of Asterisk, configured with zapconf.
+ # doable, but trickier.
+ $AST_SCRIPT start
+ ;;
+help)
+ usage
+ ;;
+*)
+ echo >&2 "$0: Error: incorrect command \"$1\". Aborting"
+ usage
+ exit 1
+esac
Propchange: branches/1.4/live_zap
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: branches/1.4/live_zap
------------------------------------------------------------------------------
svn:executable = *
Propchange: branches/1.4/live_zap
------------------------------------------------------------------------------
svn:keywords = Auther Date Id Revision
Propchange: branches/1.4/live_zap
------------------------------------------------------------------------------
svn:mime-type = text/plain
More information about the svn-commits
mailing list