summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authortzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2006-11-06 20:09:45 +0000
committertzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2006-11-06 20:09:45 +0000
commit201e9dc274ae56d43d68326c9c0f9ae6e03736fa (patch)
tree40eb47921057c1581b12c71b711b852d3f7f4ace
parent085c150989f1202fe3321e39803fae633de66ca5 (diff)
* 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. git-svn-id: http://svn.digium.com/svn/zaptel/branches/1.2@1559 5390a7c7-147a-4af0-8ec9-7488f05a26cb
-rwxr-xr-xxpp/utils/genzaptelconf60
-rw-r--r--xpp/utils/genzaptelconf.8184
2 files changed, 153 insertions, 91 deletions
diff --git a/xpp/utils/genzaptelconf b/xpp/utils/genzaptelconf
index 522ef26..053bf1c 100755
--- a/xpp/utils/genzaptelconf
+++ b/xpp/utils/genzaptelconf
@@ -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 @@ group_lines=0 # group for lines
# 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 @@ usage() {
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 @@ usage() {
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 @@ print_pattern() {
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 @@ unload_modules() {
# 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 @@ genconf() {
#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 @@ genconf() {
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 @@ EOF
# 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 @@ EOF
*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 @@ EOF
#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
diff --git a/xpp/utils/genzaptelconf.8 b/xpp/utils/genzaptelconf.8
index 0ec62a2..081b52d 100644
--- a/xpp/utils/genzaptelconf.8
+++ b/xpp/utils/genzaptelconf.8
@@ -5,10 +5,10 @@
.SH SYNOPSIS
.PP
.B genzaptelconf
-[-sdv] [-c <country_code>] [-r |-e <base_exten>] [ -F ]
+[-sRdv] [-c <country_code>] [-e <base_exten>] [ -F ]
.B genzaptelconf
-[-sdv] -l -- only list to standard output
+[-sRdv] -l -- only list to standard output
.B genzaptelconf
-su -- only unload zaptel modules
@@ -65,7 +65,7 @@ as extension
.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 @@ This triggers the
option as well.
.RE
-.B -r
+.B -R
.RS
-Try to guess a useful
-.I zapata-channels
-configuration for Xorcom Rapid .
+Don't restart asterisk even if it was stopped using
+.I -s
+ .
.RE
.B -s
@@ -115,7 +115,6 @@ work if nobody uses the zaptel channels:
* 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,61 +126,29 @@ Be verbose. lists the detected modules if
is used. Lists detected channls. In the end tries to connect to asterisk
to get a list of configured zaptel channels.
.RE
-.SH FILES
-.I /etc/zaptel.conf
-.RS
-The configuration file used by
-.I ztcfg
-to configure zaptel devices. re-written by
-.I genzaptelconf
-.RE
-
-.I /etc/zaptel.conf.bak
-.RS
-When
-.I zaptel.conf
-The original zaptel.conf
-.RE
-
-.I /etc/asterisk/zapata.conf
-.RS
-The configuration file of Asterisk's
-.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
-.I zapata.conf:
-.RS
-#include "zapata-channels.conf"
-.RE
-.RE
-
-.I /etc/asterisk/zapata-channels.conf
-.RS
-This is the snippet of
-.I chan_zap
-configuration file that
-.I genzaptelconf generates.
-.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.
-.I /etc/asterisk/zapata-channels.conf.bak
-.RS
-The backup copy of
-.I zapata-channels.conf
-.RE
+The following variables may be set from the environment:
+ZAPCONF_FILE, ZAPATA_FILE, ZAPTEL_BOOT_DEBIAN, ZAPTEL_BOOT_FEDORA,
+DEVZAP_TIMEOUT, ZTCFG
-.I /etc/default/zaptel
.RS
-This file holds configuration for both
-.I genzaptelconf
-and
-.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
@@ -227,6 +194,94 @@ The group number for zaptel phones.
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
+The configuration file used by
+.I ztcfg
+to configure zaptel devices. re-written by
+.I genzaptelconf
+ . A backup copy is saved to
+.I /etc/zaptel.conf.bak
+ .
+.RE
+
+.I /etc/asterisk/zapata.conf
+.RS
+The configuration file of Asterisk's
+.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
+.I zapata.conf:
+.RS
+#include "zapata-channels.conf"
+.RE
+.RE
+
+.I /etc/asterisk/zapata-channels.conf
+.RS
+This is the snippet of
+.I chan_zap
+configuration file that
+.I genzaptelconf generates.
+ . A backup copy is saved to
+.I /etc/asterisk/zapata-channels.conf.bak
+ .
+.RE
+
+.I /etc/default/zaptel
+.RS
+This file holds configuration for both
+.I genzaptelconf
+and
+.I /etc/init.d/zaptel .
+It is sourced by both scripts and can thus be used to override settings
+of variables from those scripts.
.RE
.I /etc/modules
@@ -237,9 +292,9 @@ boot time. When the option
(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
@@ -248,6 +303,11 @@ The backup copy of
.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@xorcom.com>
Permission is granted to copy, distribute and/or modify this document under