summaryrefslogtreecommitdiff
path: root/xpp/utils/genzaptelconf
diff options
context:
space:
mode:
Diffstat (limited to 'xpp/utils/genzaptelconf')
-rwxr-xr-xxpp/utils/genzaptelconf31
1 files changed, 17 insertions, 14 deletions
diff --git a/xpp/utils/genzaptelconf b/xpp/utils/genzaptelconf
index 93d7f6e..d5ce1b9 100755
--- a/xpp/utils/genzaptelconf
+++ b/xpp/utils/genzaptelconf
@@ -115,7 +115,7 @@ if [ ! -x "$ZTCFG" ]; then
ZTCFG=/usr/sbin/ztcfg
else
echo >&2 "ztcfg is not on found, do you have zaptel properly installed?"
- exit 1;
+ exit_cleanup 1
fi
fi
@@ -143,14 +143,13 @@ bri) ZAPBRI_NET=bri_net; ZAPBRI_CPE=bri_cpe ;;
pri) ZAPBRI_NET=pri_net; ZAPBRI_CPE=pri_cpe ;;
bri_ptmp) ZAPBRI_NET=bri_net_ptmp; ZAPBRI_CPE=bri_cpe_ptmp ;;
*)
- echo >&2 "Incorrect value for ZAPBRI_SIGNALLING ($ZAPBRI_SIGNALLING). Abortring"
- exit 1
+ die "Incorrect value for ZAPBRI_SIGNALLING ($ZAPBRI_SIGNALLING). Abortring"
;;
esac
die() {
echo "$@" >&2
- exit 1
+ exit_cleanup 1
}
say() {
@@ -160,6 +159,16 @@ say() {
echo "$@" >&2
}
+# exit (exit value is the optional $1), and clean up after us
+exit_cleanup() {
+ if [ -d "$tmp_dir" ]; then
+ # don't fail but don't hide error if directory is not
+ # empty
+ rmdir "$tmp_dir" || :
+ fi
+ exit $1
+}
+
# 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:
@@ -529,12 +538,6 @@ unload_module() {
}
unload_modules() {
- if
- pids="$(pgrep asterisk)"
- [ "$pids" != '' ]
- then
- die "Before unloading -- STOP asterisk (pids=$pids)."
- fi
say "Unloading zaptel modules:"
unload_module zaptel
say ''
@@ -1052,7 +1055,7 @@ do
c) lc_country=`echo $OPTARG | tr -d -c a-z` ;;
d) do_detect=yes ;;
F) fxsdisable=yes;;
- u) do_unload=yes ;;
+ u) do_unload=yes ; force_stop_ast=yes ;;
v) verbose=yes ;;
l) mode='list' ;;
M) do_module_list=yes; do_detect=yes ;;
@@ -1101,14 +1104,14 @@ else
echo >&2 "Asterisk is already running. Configuration left untouched"
echo >&2 "You can use the option -s to shut down Asterisk for the"
echo >&2 "duration of the detection."
- exit 1
+ exit_cleanup 1
fi
fi
if [ "$do_unload" = yes ]
then
unload_modules
- exit
+ exit_cleanup $?
fi
if [ "$do_detect" = yes ]
@@ -1144,7 +1147,7 @@ fi
if [ "$force_stop_ast" != 'yes' ] || [ "$do_restart" != 'yes' ]
then
- exit 0
+ exit_cleanup 0
fi
if [ -x /etc/init.d/asterisk ]