summaryrefslogtreecommitdiff
path: root/xpp/utils
diff options
context:
space:
mode:
authortzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2006-08-10 03:56:43 +0000
committertzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2006-08-10 03:56:43 +0000
commitb3d8734dd193a728dc0344c6cf20cbdcec170dfe (patch)
treef150ab7ad71493c5c3f29e6dfff3fb2cd6ff9a4a /xpp/utils
parent5fb2c4a56db124c344d5c468c2885738d2455aec (diff)
* A delay loop waiting for a slow udev to generate /dev/zap/ctl
* Work around stupid call to ztcfg on modprobe (as inserted by zaptel install script) * -M now edits /etc/sysconfig/zaptel if it find that file and not /etc/modules * editing of /etc/sysconfig/zaptel: remove all lines that begin with MODULES=, and add MODULES="list of modules" to the end. git-svn-id: http://svn.digium.com/svn/zaptel/trunk@1293 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'xpp/utils')
-rwxr-xr-xxpp/utils/genzaptelconf79
1 files changed, 71 insertions, 8 deletions
diff --git a/xpp/utils/genzaptelconf b/xpp/utils/genzaptelconf
index ea81ad4..7dce37d 100755
--- a/xpp/utils/genzaptelconf
+++ b/xpp/utils/genzaptelconf
@@ -87,10 +87,12 @@ group_lines=0 # group for lines
set_immediate=yes
ZAPCONF_FILE=/etc/zaptel.conf
+ZAPCONF_FILE_SYSTEM=$ZAPCONF_FILE
ZAPATA_FILE=/etc/asterisk/zapata-channels.conf
ZAPTEL_BOOT_DEBIAN=${ZAPTEL_BOOT_DEBIAN:-/etc/default/zaptel}
ZAPTEL_BOOT_FEDORA=${ZAPTEL_BOOT_FEDORA:-/etc/sysconfig/zaptel}
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
ZTCFG=/sbin/ztcfg
@@ -139,6 +141,25 @@ say() {
}
run_ztcfg() {
+ # Wait for udev to generate /dev/zap/ctl, if needed:
+ if [ ! -c /dev/zap/ctl ] && grep -q zaptel /proc/modules ; then
+ say "Waiting for /dev/zap/ctl to be generated"
+ devzap_found=0
+ devzap_timeout=5
+ for i in `seq $devzap_timeout`; do
+ sleep 1
+ if [ -c /dev/zap/ctl ]; then
+ devzap_found=1
+ break
+ fi
+ done
+ if [ "$devzap_found" != 1 ]; then
+ say "Still no /dev/zap/ctl after $devzap_timeout seconds."
+ echo >&2 "No /dev/zap/ctl: cannot run ztcfg. Aborting."
+ fi
+ fi
+
+ # Run ztcfg itself
if [ "$verbose" = no ]; then
$ztcfg_cmd "$@"
else
@@ -147,7 +168,8 @@ run_ztcfg() {
fi
}
-update_module_list() {
+update_module_list_debian() {
+ say "Updating Debian modules list $MODLIST_FILE."
del_args=`for i in $ALL_MODULES ztdummy
do
echo "$i" | sed s:.\*:-e\ '/^&/d':
@@ -164,6 +186,22 @@ update_module_list() {
done >> "$MODLIST_FILE"
}
+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"
+}
+
+update_module_list() {
+ if [ -f "$MODLIST_FILE" ]; then
+ update_module_list_debian "$@"
+ elif [ -f "$MODLIST_FILE_FEDORA" ]; then
+ update_module_list_fedora "$@"
+ else
+ die "Can't find a modules list to update. Tried: $MODLIST_FILE, $MODLIST_FILE_FEDORA. Aborting"
+ fi
+}
+
update_extensions_defs() {
if [ "$rapid_conf_mode" = 'yes' ]
then
@@ -489,23 +527,48 @@ wait_for_xpp() {
detect() {
unload_modules
+ temporary_zapconf save
load_modules
+ temporary_zapconf restore
modlist="$probed_modules"
- #for i in $ALL_MODULES
- #do
- # if lsmod | grep "^$i *" > /dev/null; then
- # modlist="$modlist $i"
- # fi
- #done
modlist="$(echo $modlist)" # clean spaces
if [ "$do_module_list" = yes ]
then
- say "Updating '${MODLIST_FILE}'"
update_module_list "$modlist"
fi
if echo $modlist | grep -q xpp_usb; then wait_for_xpp; fi
}
+# The module configuration generated by zaptel includes a totally useless
+# automatic run of ztcfg after modules loading. As a workaround for that,
+# we provide an empty zaptel.conf temporarily.
+#
+# At hardware detection time we shouldn't really touch zaptel.conf . So we
+# must keep a copy of it somewhere.
+#
+# I use ZAPCONF_FILE_SYSTEM rather than ZAPCONF_FILE, as the bogus modprobe
+# entries will not be initiated by us.
+#
+# ZAPCONF_FILE_TMP is a "global", as it needs to be preserved between the
+# call to 'save' and to 'restore'
+ZAPCONF_FILE_TMP=
+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"
+ cp -a $ZAPCONF_FILE_SYSTEM $ZAPCONF_FILE_TMP
+ echo -n >$ZAPCONF_FILE_SYSTEM
+ ;;
+ restore)
+ # restore original zaptel.conf:
+ if [ "$ZAPCONF_FILE_TMP" = '' ]; then return; fi
+ mv $ZAPCONF_FILE_TMP $ZAPCONF_FILE_SYSTEM
+ ZAPCONF_FILE_TMP=''
+ ;;
+ esac
+}
+
# TODO: kill this function. It is now unreferenced from anywhere.
check_tdm_sigtype() {
chan_num=$1