[zaptel-commits] tzafrir: branch 1.2 r1559 -
/branches/1.2/xpp/utils/
zaptel-commits at lists.digium.com
zaptel-commits at lists.digium.com
Mon Nov 6 13:09:46 MST 2006
Author: tzafrir
Date: Mon Nov 6 14:09:45 2006
New Revision: 1559
URL: http://svn.digium.com/view/zaptel?rev=1559&view=rev
Log:
* genzaptelconf: Set modes of generated files to original ones or sane
defaults.
* genzaptelconf: Don't check for zap_autoreg in wait_for_xpp .
* genzaptelconf: Add support for fxs_immediate: option to set FXS port as
immediate.
* genzaptelconf: Fix few left over writes to stdout for config files.
* genzaptelconf: Documentation fixes.
* genzaptelconf.8: bring up-to-date.
Modified:
branches/1.2/xpp/utils/genzaptelconf
branches/1.2/xpp/utils/genzaptelconf.8
Modified: branches/1.2/xpp/utils/genzaptelconf
URL: http://svn.digium.com/view/zaptel/branches/1.2/xpp/utils/genzaptelconf?rev=1559&r1=1558&r2=1559&view=diff
==============================================================================
--- branches/1.2/xpp/utils/genzaptelconf (original)
+++ branches/1.2/xpp/utils/genzaptelconf Mon Nov 6 14:09:45 2006
@@ -34,7 +34,7 @@
# (redhat/centos)
# /etc/default/zaptel may override the following variables
-VERSION=0.5.6
+VERSION=0.5.7
rcsid='$Id$'
lc_country=us
base_exten=6000
@@ -54,6 +54,8 @@
# for others. Note that if an Astribank is not detected, the script
# will set this to "no", so you can safely leave it as "yes".
set_immediate=yes
+# Set fxs_immediate to 'yes' to make all FXS lines answer immediately.
+fxs_immediate=no
ZAPCONF_FILE=${ZAPCONF_FILE:-/etc/zaptel.conf}
ZAPCONF_FILE_SYSTEM=$ZAPCONF_FILE
@@ -224,8 +226,8 @@
echo >&2 "$program: generate zaptel.conf and zapata.conf"
echo >&2 "(version $VERSION, $rcsid)"
echo >&2 "usage:"
- echo >&2 " $program [-sdv] [-m k|l|g] [-c <country_code>] [-r |-e <base_exten>] "
- echo >&2 " $program [-sdv] -l"
+ echo >&2 " $program [-sRdv] [-m k|l|g] [-c <country_code>] [-e <base_exten>] [-F]"
+ echo >&2 " $program [-sRdv] -l"
echo >&2 " $program -su"
echo >&2 " $program -h (this screen)"
echo >&2 ""
@@ -235,9 +237,9 @@
echo >&2 " -F: Don't print FXSs in zapata.conf"
echo >&2 " -l: output a list of detected channels instead of zaptel.conf"
echo >&2 " -d: Perform hardware detection"
- echo >&2 " -u: Unload zaptel modules"
+ echo >&2 " -u: Unload zaptel modules (will not restart Asterisk)."
echo >&2 " -v: verbose"
- echo >&2 " -s: Don't fail if asterisk is running. Stop it"
+ echo >&2 " -s: Stop Asterisk before running, and start it at the end."
echo >&2 " -R: Don't restart asterisk in the end."
}
@@ -346,7 +348,8 @@
if [ "$set_immediate" = 'yes' ]
then
- if [ "$astbank_type" = 'input' ]
+ if [ "$astbank_type" = 'input' ] || \
+ ( [ "$fxs_immediate" = 'yes' ] && [ "$sig" = "fxo" ] )
then echo 'immediate=yes' >> $zapata_file
else echo 'immediate=no' >> $zapata_file
fi
@@ -454,16 +457,7 @@
# sleep a while until the xpp modules fully register
wait_for_xpp() {
- case "`uname -r`" in
- 2.6.8*)
- autoreg="/sys/module/xpp/zap_autoreg"
- ;;
- *)
- autoreg="/sys/module/xpp/parameters/zap_autoreg"
- ;;
- esac
- if [ -d /proc/xpp ] && \
- [ "`cat $autoreg`" = 'Y' ]
+ if [ -d /proc/xpp ]
then
# wait for the XPDs to register:
# TODO: improve error reporting and produce a messagee here
@@ -547,14 +541,10 @@
#say "DEBUG: resetting channels lists"
rm -f $tmp_dir/fx{s,o}_*
- if [ "$mode" = 'zapata' ]
- then
- rem_char=';'
- else
- rem_char='#'
- fi
-
- spanlist=`echo /proc/zaptel/* | grep -v '\*'`
+# spanlist=`echo /proc/zaptel/* | grep -v '\*'`
+# spanlist=$(for i in `for i in /proc/zaptel/*; do if [ -f $i ]; then echo $i | cut -f 4 -d / ; fi; done | sort -n`; do echo -n "/proc/zaptel/$i "; done)
+# spanlist=(cd /proc/zaptel; ls | sort -n | sed 's|^|/proc/zaptel/|')
+ spanlist=`ls /proc/zaptel/ 2>/dev/null | sort -n | sed 's|^|/proc/zaptel/|'`
#if [ "$spanlist" == "" ]; then
# die "No zapata interfaces in /proc/zaptel"
@@ -565,6 +555,18 @@
files)
local zaptel_file=`mktemp -t genzaptelconf-zaptel-XXXXXX`
local zapata_file=`mktemp -t genzaptelconf-zapata-XXXXXX`
+ if [ -r "${ZAPCONF_FILE}" ]; then
+ chown --reference="${ZAPCONF_FILE}" $zaptel_file || true
+ chmod --reference="${ZAPCONF_FILE}" $zaptel_file
+ else
+ chmod 644 $zaptel_file
+ fi
+ if [ -r "${ZAPATA_FILE}" ]; then
+ chown --reference="${ZAPATA_FILE}" $zapata_file || true
+ chmod --reference="${ZAPATA_FILE}" $zapata_file
+ else
+ chmod 644 $zapata_file
+ fi
cat <<EOF >$zaptel_file
# Autogenerated by $0 -- do not hand edit
# Zaptel Configuration File
@@ -641,15 +643,15 @@
# this can be either FXS or FXO
maybe_fxs=0
maybe_fxo=0
- $ztcfg_cmd -c <(print_pattern $chan_num fxo zaptel) &>/dev/null && maybe_fxs=1
- $ztcfg_cmd -c <(print_pattern $chan_num fxs zaptel) &>/dev/null && maybe_fxo=1
+ $ztcfg_cmd -c <(echo fxoks=$chan_num) &>/dev/null && maybe_fxs=1
+ $ztcfg_cmd -c <(echo fxsks=$chan_num) &>/dev/null && maybe_fxo=1
if [ $maybe_fxs = 1 ] && [ $maybe_fxo = 1 ]
then
# An installed module won't accept both FXS and FXO signalling types:
# this is an empty slot.
# TODO: I believe that the Sangoma A20x will reject both and thus
# print nothing here.
- echo "$rem_char channel $chan_num, WCTDM, no module."
+ echo "# channel $chan_num, WCTDM, no module." >> $zaptel_file
continue
fi
@@ -659,7 +661,7 @@
*WCFXO/*)
# X100P
print_pattern $chan_num fxs $mode || \
- echo "$rem_char channel $chan_num, WCFXO, inactive."
+ echo "# channel $chan_num, WCFXO, inactive." >>$zaptel_file
;;
*WCUSB/*)
print_pattern $chan_num fxo $mode
@@ -730,7 +732,7 @@
#echo 'euroisdn' >$tmp_dir/span_switchtype
#echo 'pri_cpe' >$tmp_dir/span_signalling
;;
- il)
+ il|de|au)
echo 'ccs' >$tmp_dir/span_framing
echo 'hdb3' >$tmp_dir/span_coding
echo 'crc4' >$tmp_dir/span_yellow
Modified: branches/1.2/xpp/utils/genzaptelconf.8
URL: http://svn.digium.com/view/zaptel/branches/1.2/xpp/utils/genzaptelconf.8?rev=1559&r1=1558&r2=1559&view=diff
==============================================================================
--- branches/1.2/xpp/utils/genzaptelconf.8 (original)
+++ branches/1.2/xpp/utils/genzaptelconf.8 Mon Nov 6 14:09:45 2006
@@ -5,10 +5,10 @@
.SH SYNOPSIS
.PP
.B genzaptelconf
-[-sdv] [-c <country_code>] [-r |-e <base_exten>] [ -F ]
-
-.B genzaptelconf
-[-sdv] -l -- only list to standard output
+[-sRdv] [-c <country_code>] [-e <base_exten>] [ -F ]
+
+.B genzaptelconf
+[-sRdv] -l -- only list to standard output
.B genzaptelconf
-su -- only unload zaptel modules
@@ -65,7 +65,7 @@
.I exten_num
+
.I i
-. This is mostly for the caller-id values. Crude, but may be good enough.
+ . This is mostly for the caller-id values. Crude, but may be good enough.
See also
.I -r
.RE
@@ -99,11 +99,11 @@
option as well.
.RE
-.B -r
-.RS
-Try to guess a useful
-.I zapata-channels
-configuration for Xorcom Rapid .
+.B -R
+.RS
+Don't restart asterisk even if it was stopped using
+.I -s
+ .
.RE
.B -s
@@ -115,7 +115,6 @@
* to allow reading configuration files.
-By default the script will check if asterisk is running and alert if so.
This option tells the script to stop asterisk (if it was running) and to
try to start it after the end of the test.
.RE
@@ -127,6 +126,117 @@
is used. Lists detected channls. In the end tries to connect to asterisk
to get a list of configured zaptel channels.
.RE
+.SH CONFIGURATION
+Look at the beginning of the script for a number of variables that can
+be overriden through the configuraion file. Some variables can also be
+overriden through the environment. The configuration file is sourced by
+bash but for compatibility expected to have only 'var=VALUE' lines and
+comments or empty lines.
+
+The configuration will first be read from
+.I /etc/default/zaptel
+if it exists, and
+.I /etc/sysconfig/zaptel
+otherwise (But those file names may be overriden, see
+.I ZAPTEL_BOOT_DEBIAN
+and
+.I ZAPTEL_BOOT_FEDORA
+below). Variables set in those files will override the default settings
+and setting rom the environment.
+
+The following variables may be set from the environment:
+ZAPCONF_FILE, ZAPATA_FILE, ZAPTEL_BOOT_DEBIAN, ZAPTEL_BOOT_FEDORA,
+DEVZAP_TIMEOUT, ZTCFG
+
+.RS
+.I lc_country
+.RS
+The default country. Can be also overriden by the option -c
+.RE
+
+.I base_exten
+.RS
+The base number used for automatic numbering
+.RE
+
+.I context_manual
+.RS
+If set to 'yes', no context changes are made in zapata-channels.conf
+.RE
+
+.I context_lines
+.RS
+The context into which calls will go from zaptel trunks.
+.RE
+
+.I context_phones
+.RS
+The context into which calls will go from zaptel phones.
+.RE
+
+.I context_manual
+.RS
+If set to 'yes', no group settings are made in zapata-channels.conf
+.RE
+
+.I group_lines
+.RS
+The group number for zaptel trunks.
+.RE
+
+.I group_phones
+.RS
+The group number for zaptel phones.
+.RE
+
+.I ALL_MODULES
+.RS
+modules list. Used for unloading and modules detection. The order of modules
+is the same for both.
+.RE
+
+.I ZAPCONF_FILE
+.RS
+ztcfg's configuration file. The sane default is /etc/zaptel.conf .
+.RE
+
+.I ZAPATA_FILE
+.RS
+The generated partial zapata.conf snippet. Default:
+/etc/asterisk/zapata-channels.conf .
+.RE
+
+.I ZAPTEL_BOOT_DEBIAN
+.RS
+The Debian Zaptel defaults file. Normally
+.I /etc/default/zaptel
+.
+.RE
+
+
+.I ZAPTEL_BOOT_FEDORA
+.RS
+The Zaptel defaults file on various other distributions. Normally
+.I /etc/sysconfig/zaptel
+ .
+.RE
+
+.I DEVZAP_TIMEOUT
+.RS
+Maximal number of seconds to wait for /dev/zap to be initializaed by
+udev.
+.RE
+
+.I ZTCFG
+.RS
+The full path to the ztcfg tool. Default:
+.I /sbin/ztcfg
+genzaptelconf will also explicitly test for
+.I /usr/sbin/ztcfg
+as a last resort.
+.RE
+.RE
+
.SH FILES
.I /etc/zaptel.conf
.RS
@@ -134,13 +244,9 @@
.I ztcfg
to configure zaptel devices. re-written by
.I genzaptelconf
-.RE
-
+ . A backup copy is saved to
.I /etc/zaptel.conf.bak
-.RS
-When
-.I zaptel.conf
-The original zaptel.conf
+ .
.RE
.I /etc/asterisk/zapata.conf
@@ -163,12 +269,9 @@
.I chan_zap
configuration file that
.I genzaptelconf generates.
-.RE
-
+ . A backup copy is saved to
.I /etc/asterisk/zapata-channels.conf.bak
-.RS
-The backup copy of
-.I zapata-channels.conf
+ .
.RE
.I /etc/default/zaptel
@@ -179,54 +282,6 @@
.I /etc/init.d/zaptel .
It is sourced by both scripts and can thus be used to override settings
of variables from those scripts.
-Some of the variables that can be set in /etc/default/zaptel and affect
-genzaptelconf:
-
-.I lc_country
-.RS
-The default country. Can be also overriden by the option -c
-.RE
-
-.I base_exten
-.RS
-The base number used for automatic numbering
-.RE
-
-.I context_manual
-.RS
-If set to 'yes', no context changes are made in zapata-channels.conf
-.RE
-
-.I context_lines
-.RS
-The context into which calls will go from zaptel trunks.
-.RE
-
-.I context_phones
-.RS
-The context into which calls will go from zaptel phones.
-.RE
-
-.I context_manual
-.RS
-If set to 'yes', no group settings are made in zapata-channels.conf
-.RE
-
-.I group_lines
-.RS
-The group number for zaptel trunks.
-.RE
-
-.I group_phones
-.RS
-The group number for zaptel phones.
-.RE
-
-.I ALL_MODULES
-.RS
-modules list. Used for unloading and modules detection. The order of modules
-is the same for both.
-.RE
.RE
.I /etc/modules
@@ -237,9 +292,9 @@
(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
-
+ . If it is rewritten, a backup copy is saved to
.I /etc/modules.bak
+ .
.RS
The backup copy of
.I /etc/modules
@@ -247,6 +302,11 @@
.SH "SEE ALSO"
ztcfg(8) asterisk(8).
+
+.SH BUGS
+If you override a configuration variable both through the environment
+and through the configuration file, the value from the configuration
+file wins.
.SH "AUTHOR"
This manual page was written by Tzafrir Cohen <tzafrir.cohen at xorcom.com>
More information about the zaptel-commits
mailing list