summaryrefslogtreecommitdiff
path: root/xpp/utils
diff options
context:
space:
mode:
authortzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2006-08-12 15:03:08 +0000
committertzafrir <tzafrir@5390a7c7-147a-4af0-8ec9-7488f05a26cb>2006-08-12 15:03:08 +0000
commitbaf9f8091588bff0edefce4d94b923b8c0e3abf5 (patch)
tree70d508d0c4dd66ef9925145a69cf05a85a84d6b5 /xpp/utils
parentb3d8734dd193a728dc0344c6cf20cbdcec170dfe (diff)
* 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. git-svn-id: http://svn.digium.com/svn/zaptel/trunk@1294 5390a7c7-147a-4af0-8ec9-7488f05a26cb
Diffstat (limited to 'xpp/utils')
-rwxr-xr-xxpp/utils/genzaptelconf66
1 files changed, 47 insertions, 19 deletions
diff --git a/xpp/utils/genzaptelconf b/xpp/utils/genzaptelconf
index 7dce37d..52d42bc 100755
--- a/xpp/utils/genzaptelconf
+++ b/xpp/utils/genzaptelconf
@@ -95,7 +95,20 @@ 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
+# 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
@@ -110,6 +123,17 @@ ALL_MODULES="zaphfc qozap ztgsm wctdm wctdm24xxp wcfxo wcfxs pciradio tor2 toris
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 @@ say() {
echo "$@" >&2
}
-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."
+# 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() {
# Run ztcfg itself
if [ "$verbose" = no ]; then
$ztcfg_cmd "$@"
@@ -607,7 +635,6 @@ get_rapid_extens() {
genconf() {
local mode=$1
-
# reset FXO list (global)
#say "DEBUG: resetting channels lists"
rm -f $tmp_dir/fx{s,o}_*
@@ -963,6 +990,7 @@ else
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"