[zaptel-commits] tzafrir: trunk r1294 -
/trunk/xpp/utils/genzaptelconf
zaptel-commits at lists.digium.com
zaptel-commits at lists.digium.com
Sat Aug 12 08:03:09 MST 2006
Author: tzafrir
Date: Sat Aug 12 10:03:08 2006
New Revision: 1294
URL: http://svn.digium.com/view/zaptel?rev=1294&view=rev
Log:
* Wait for /dev/zap/ctl to appear if udev takes its time creating it.
* Try looking for ztcfg in /usr/sbin as well.
* Also allow setting the location of ztcfg from environment.
Modified:
trunk/xpp/utils/genzaptelconf
Modified: trunk/xpp/utils/genzaptelconf
URL: http://svn.digium.com/view/zaptel/trunk/xpp/utils/genzaptelconf?rev=1294&r1=1293&r2=1294&view=diff
==============================================================================
--- trunk/xpp/utils/genzaptelconf (original)
+++ trunk/xpp/utils/genzaptelconf Sat Aug 12 10:03:08 2006
@@ -95,7 +95,20 @@
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
+# how long to wait for /dev/zap/ctl to appear? (seconds)
+DEVZAP_TIMEOUT=${DEVZAP_TIMEOUT:-20}
+ZTCFG=${ZTCFG:-/sbin/ztcfg}
+
+if [ -x /sbin/ztcfg ]; then
+ ZTCFG=/sbin/ztcfg
+else
+ if [ -x /usr/sbin/ztcfg ]; then
+ ZTCFG=/usr/sbin/ztcfg
+ else
+ echo "ztcfg is not on found, do you have zaptel properly installed?"
+ exit 1;
+ fi
+fi
# a temporary directory. Created when the switch -r is parsed on getopts
# and deleted in the end on update_extensions_defs
@@ -109,6 +122,17 @@
# read default configuration from /etc/default/zaptel
if [ -r $ZAPTEL_BOOT_DEBIAN ]; then . $ZAPTEL_BOOT_DEBIAN; fi
if [ -r $ZAPTEL_BOOT_FEDORA ]; then . $ZAPTEL_BOOT_FEDORA; fi
+
+if [ ! -x "$ZTCFG" ]; then
+ # Work around a bug in the rpm package: ztcfg should be in
+ # /sbin as it may be required for starting a network interface
+ if [ -x /usr/sbin/ztcfg ]; then
+ ZTCFG=/usr/sbin/ztcfg
+ else
+ echo "ztcfg is not on found, do you have zaptel properly installed?"
+ exit 1;
+ fi
+fi
# it is safe to use -c twice: the last one will be used.
ztcfg_cmd="$ZTCFG -c $ZAPCONF_FILE"
@@ -140,25 +164,29 @@
echo "$@" >&2
}
+# Wait for udev to generate /dev/zap/ctl, if needed:
+wait_for_zapctl() {
+ # if device file already exists, or if zaptel has failed to load:
+ # no point waiting.
+ if [ -c /dev/zap/ctl ] || ! grep -q zaptel /proc/modules ; then
+ return
+ fi
+ say "Waiting for /dev/zap/ctl to be generated"
+ devzap_found=0
+ 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
+}
+
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 "$@"
@@ -607,7 +635,6 @@
genconf() {
local mode=$1
-
# reset FXO list (global)
#say "DEBUG: resetting channels lists"
rm -f $tmp_dir/fx{s,o}_*
@@ -963,6 +990,7 @@
get_rapid_extens
say "Generating '${ZAPCONF_FILE}'"
mv "${ZAPCONF_FILE}" "${ZAPCONF_FILE}.bak"
+ wait_for_zapctl
genconf zaptel > "${ZAPCONF_FILE}"
say "Generating '${ZAPATA_FILE}'"
mv "${ZAPATA_FILE}" "${ZAPATA_FILE}.bak"
More information about the zaptel-commits
mailing list