summaryrefslogtreecommitdiff
path: root/xpp/utils/genzaptelconf
diff options
context:
space:
mode:
Diffstat (limited to 'xpp/utils/genzaptelconf')
-rwxr-xr-xxpp/utils/genzaptelconf85
1 files changed, 70 insertions, 15 deletions
diff --git a/xpp/utils/genzaptelconf b/xpp/utils/genzaptelconf
index 67a0263..4bf8a38 100755
--- a/xpp/utils/genzaptelconf
+++ b/xpp/utils/genzaptelconf
@@ -66,12 +66,18 @@ MODLIST_FILE=/etc/modules
MODLIST_FILE_FEDORA=/etc/sysconfig/zaptel
exten_base_dir=/etc/asterisk/extensions-phones.d
exten_defs_file=/etc/asterisk/extensions-defs.conf
+# perl utilities:
+xpp_sync=/usr/sbin/xpp_sync
+zt_registration=/usr/sbin/zt_registration
# how long to wait for /dev/zap/ctl to appear? (seconds)
DEVZAP_TIMEOUT=${DEVZAP_TIMEOUT:-20}
ZTCFG=${ZTCFG:-/sbin/ztcfg}
# BRI/PRI spans will be in an additional per-span group whose number
# is SPAN_GROUP_BASE + span-number
SPAN_GROUP_BASE=10
+# set to "yes" to make BRI NT spans set overlapdial (handy for ISDN phones
+# and other devices).
+brint_overlap=no
# a temporary directory to store whatever we need to remember.
#
@@ -83,6 +89,12 @@ tmp_dir=
# - The module that will be deleted from /etc/modules , if -d -M is used
ALL_MODULES="vzaphfc zaphfc qozap ztgsm wctdm wctdm24xxp wcfxo wcfxs pciradio tor2 torisa wcte12xp wct1xxp wct4xxp wcte11xp wanpipe wcusb xpp_usb"
+# The name of the variable in /etc/sysconfig/zaptel into which to set
+# the list of detected modules.
+modules_var=MODULES
+# On SuSE with the rpm package:
+#modules_var=ZAPTEL_MODULES
+
# What signalling to give to ZapBRI channels?
# bri: bri_net; bri_cpe (Bristuffed Asterisk. No multi- support)
# bri_ptmpi: bri_net_ptmp; bri_cpe_ptmp (Bristuffed Asterisk, multi- support)
@@ -106,6 +118,8 @@ if [ ! -x "$ZTCFG" ]; then
fi
fi
+XPP_SYNC=auto # sync mode. can be set to '0' or '1' or HOST explicitly.
+
# it is safe to use -c twice: the last one will be used.
ztcfg_cmd="$ZTCFG -c $ZAPCONF_FILE"
@@ -197,8 +211,8 @@ update_module_list_debian() {
update_module_list_fedora() {
say "Updating modules list in zaptel init config $MODLIST_FILE_FEDORA."
- sed -i.bak -e '/^MODULES=/d' "$MODLIST_FILE_FEDORA"
- echo "MODULES=\"$*\"" >> "$MODLIST_FILE_FEDORA"
+ sed -i.bak -e "/^$modules_var=/d" "$MODLIST_FILE_FEDORA"
+ echo "$modules_var=\"$*\"" >> "$MODLIST_FILE_FEDORA"
}
update_module_list() {
@@ -234,6 +248,26 @@ zap_reg_xpp() {
done
}
+# Initialize the Xorcom Astribank (xpp/)
+xpp_startup() {
+ # do nothing if the module xpp was not loaded, or if no
+ # Astribanks connected:
+ if [ ! -d /proc/xpp ]; then return 0; fi
+ if ! grep -q 'STATUS=connected' /proc/xpp/xbuses; 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"
+}
+
+
usage() {
program=`basename $0`
@@ -306,8 +340,8 @@ print_pattern() {
method="$fxs_default_start"
fi
case "$sig" in
- fxs) sig_name=FXO; sig_name_sc=fxo ;;
- fxo) sig_name=FXS; sig_name_sc=fxs ;;
+ fxs) sig_name=FXO;;
+ fxo) sig_name=FXS;;
esac
case "$mode" in
list)
@@ -419,7 +453,7 @@ print_pattern() {
reset_zapata_entry $zapata_file $reset_values
echo "" >> $zapata_file
- print_zapscan_port "$sig_name_sc" "$chan"
+ print_zapscan_port "$sig" "$chan"
;;
esac
@@ -547,7 +581,7 @@ temporary_zapconf() {
case "$1" in
save)
say "Temporarily moving zaptel.conf aside to work around broken modprobe.conf"
- ZAPCONF_FILE_TMP=`mktemp -t zaptel.conf-XXXXXX` || die "Error creating temporary zaptel.conf"
+ ZAPCONF_FILE_TMP=`mktemp /tmp/genzaptelconf-zaptel.conf-XXXXXX` || die "Error creating temporary zaptel.conf"
cp -a $ZAPCONF_FILE_SYSTEM $ZAPCONF_FILE_TMP
echo -n >$ZAPCONF_FILE_SYSTEM
;;
@@ -566,12 +600,13 @@ reset_zapata_entry() {
for arg in "$@"; do
case "$arg" in
- busydetect) echo "busydetect=no" >>$conf_file;;
- context) echo "context=default" >>$conf_file;;
- immediate) echo "immediate=no" >>$conf_file;;
- rxgain) echo "rxgain=0" >>$conf_file;;
- txgain) echo "txgain=0" >>$conf_file;;
- *) echo "$arg=" >>$conf_file;;
+ busydetect) echo "$arg=no" >>$conf_file;;
+ context) echo "$arg=default" >>$conf_file;;
+ immediate) echo "$arg=no" >>$conf_file;;
+ overlapdial) echo "$arg=no" >>$conf_file;;
+ rxgain) echo "$arg=0" >>$conf_file;;
+ txgain) echo "$arg=0" >>$conf_file;;
+ *) echo "$arg=" >>$conf_file;;
esac
done
}
@@ -594,7 +629,9 @@ gen_tmp_conf() {
orig_cfg_file=$1
new_var=$2
- eval $new_var=`mktemp -t genzaptelconf-zapata-XXXXXX` # assign by reference
+ # assign to new_var by reference:
+ eval $new_var=`mktemp /tmp/genzaptelconf-conf-XXXXXX` \
+ || die "Unable to create temporary config file for $orig_cfg_file"
if [ -r "$orig_cfg_file" ]; then
chown --reference="$orig_cfg_file" ${!new_var} 2>/dev/null
chmod --reference="$orig_cfg_file" ${!new_var} 2>/dev/null
@@ -731,8 +768,12 @@ write_digital_config() {
if [ "$span_termtype" != '' ]
then echo "# termtype: $span_termtype" >>$zaptel_file
fi
+
echo bchan=$bchans >>$zaptel_file
echo dchan=$dchan >>$zaptel_file
+ if [ "$fxsdisable" = 'yes' ] && [ "$span_termtype" = 'nt' ]; then return; fi
+ # You should not send content to zapata.conf below this line
+
span_group=$(($SPAN_GROUP_BASE + $span_num))
if [ "$span_termtype" != '' ]
@@ -744,6 +785,11 @@ write_digital_config() {
echo "callerid=\"Channels $span_begin - $span_end\" <$span_begin>" >> $zapata_file
reset_values="$reset_values callerid"
#echo "mailbox=$exten"
+ if [ "$brint_overlap" = 'yes' ]
+ then
+ echo "overlapdial=yes" >> $zapata_file
+ reset_values="$reset_values overlapdial"
+ fi
if [ "$group_manual" != "yes" ]
then
echo "group=$group_phones,$span_group" >> $zapata_file
@@ -970,6 +1016,14 @@ EOF
mv $ZAPSCAN_FILE $ZAPSCAN_FILE.bak 2>/dev/null
mv $zapscan_file $ZAPSCAN_FILE
fi
+
+ zapata_file_name=`basename $ZAPATA_FILE`
+ if ! grep -q "^#include.*$zapata_file_name" \
+ /etc/asterisk/zapata.conf
+ then
+ say "Note: generated $ZAPATA_FILE not included in zapata.conf"
+ say "To fix: echo '#include $zapata_file_name' >>/etc/asterisk/zapata.conf"
+ fi
fi
}
@@ -1001,7 +1055,7 @@ if [ $# != 0 ]; then
exit 1
fi
-tmp_dir=`mktemp -d -t` || \
+tmp_dir=`mktemp -d /tmp/genzaptelconf-dir-XXXXXX` || \
die "$0: failed to create temporary directory. Aborting"
@@ -1050,7 +1104,8 @@ fi
if [ "$mode" = list ]; then
genconf list
else
- zap_reg_xpp
+ #zap_reg_xpp
+ xpp_startup
wait_for_zapctl
say "Generating '${ZAPCONF_FILE} and ${ZAPATA_FILE}'"
genconf files