1 |
vip-ire |
1.1 |
diff -Nur -x '*.orig' -x '*.rej' smeserver-freepbx-0.1/createlinks mezzanine_patched_smeserver-freepbx-0.1/createlinks |
2 |
|
|
--- smeserver-freepbx-0.1/createlinks 2009-02-12 00:22:09.000000000 +0100 |
3 |
|
|
+++ mezzanine_patched_smeserver-freepbx-0.1/createlinks 2009-02-12 00:20:26.000000000 +0100 |
4 |
|
|
@@ -14,10 +14,10 @@ |
5 |
|
|
service_link_enhanced("httpd-fpbx", "K15", "0"); |
6 |
|
|
service_link_enhanced("httpd-fpbx", "K15", "1"); |
7 |
|
|
|
8 |
|
|
-service_link_enhanced("zaptel", "S09", "7"); |
9 |
|
|
-service_link_enhanced("zaptel", "K16", "6"); |
10 |
|
|
-service_link_enhanced("zaptel", "K16", "0"); |
11 |
|
|
-service_link_enhanced("zaptel", "K16", "1"); |
12 |
|
|
+service_link_enhanced("dahdi", "S09", "7"); |
13 |
|
|
+service_link_enhanced("dahdi", "K16", "6"); |
14 |
|
|
+service_link_enhanced("dahdi", "K16", "0"); |
15 |
|
|
+service_link_enhanced("dahdi", "K16", "1"); |
16 |
|
|
|
17 |
|
|
safe_symlink("../daemontools" , 'root/etc/rc.d/init.d/supervise/httpd-fpbx'); |
18 |
|
|
safe_symlink("/var/service/httpd-fpbx" , 'root/service/httpd-fpbx'); |
19 |
|
|
diff -Nur -x '*.orig' -x '*.rej' smeserver-freepbx-0.1/root/etc/e-smith/db/configuration/defaults/dahdi/status mezzanine_patched_smeserver-freepbx-0.1/root/etc/e-smith/db/configuration/defaults/dahdi/status |
20 |
|
|
--- smeserver-freepbx-0.1/root/etc/e-smith/db/configuration/defaults/dahdi/status 1970-01-01 01:00:00.000000000 +0100 |
21 |
|
|
+++ mezzanine_patched_smeserver-freepbx-0.1/root/etc/e-smith/db/configuration/defaults/dahdi/status 2008-09-20 14:06:51.000000000 +0200 |
22 |
|
|
@@ -0,0 +1 @@ |
23 |
|
|
+enabled |
24 |
|
|
diff -Nur -x '*.orig' -x '*.rej' smeserver-freepbx-0.1/root/etc/e-smith/db/configuration/defaults/dahdi/type mezzanine_patched_smeserver-freepbx-0.1/root/etc/e-smith/db/configuration/defaults/dahdi/type |
25 |
|
|
--- smeserver-freepbx-0.1/root/etc/e-smith/db/configuration/defaults/dahdi/type 1970-01-01 01:00:00.000000000 +0100 |
26 |
|
|
+++ mezzanine_patched_smeserver-freepbx-0.1/root/etc/e-smith/db/configuration/defaults/dahdi/type 2008-09-20 14:06:43.000000000 +0200 |
27 |
|
|
@@ -0,0 +1 @@ |
28 |
|
|
+service |
29 |
|
|
diff -Nur -x '*.orig' -x '*.rej' smeserver-freepbx-0.1/root/etc/e-smith/db/configuration/defaults/zaptel/status mezzanine_patched_smeserver-freepbx-0.1/root/etc/e-smith/db/configuration/defaults/zaptel/status |
30 |
|
|
--- smeserver-freepbx-0.1/root/etc/e-smith/db/configuration/defaults/zaptel/status 2008-09-20 14:06:51.000000000 +0200 |
31 |
|
|
+++ mezzanine_patched_smeserver-freepbx-0.1/root/etc/e-smith/db/configuration/defaults/zaptel/status 1970-01-01 01:00:00.000000000 +0100 |
32 |
|
|
@@ -1 +0,0 @@ |
33 |
|
|
-enabled |
34 |
|
|
diff -Nur -x '*.orig' -x '*.rej' smeserver-freepbx-0.1/root/etc/e-smith/db/configuration/defaults/zaptel/type mezzanine_patched_smeserver-freepbx-0.1/root/etc/e-smith/db/configuration/defaults/zaptel/type |
35 |
|
|
--- smeserver-freepbx-0.1/root/etc/e-smith/db/configuration/defaults/zaptel/type 2008-09-20 14:06:43.000000000 +0200 |
36 |
|
|
+++ mezzanine_patched_smeserver-freepbx-0.1/root/etc/e-smith/db/configuration/defaults/zaptel/type 1970-01-01 01:00:00.000000000 +0100 |
37 |
|
|
@@ -1 +0,0 @@ |
38 |
|
|
-service |
39 |
|
|
diff -Nur -x '*.orig' -x '*.rej' smeserver-freepbx-0.1/root/usr/share/freepbx/scripts/uninstall.sh mezzanine_patched_smeserver-freepbx-0.1/root/usr/share/freepbx/scripts/uninstall.sh |
40 |
|
|
--- smeserver-freepbx-0.1/root/usr/share/freepbx/scripts/uninstall.sh 2008-08-13 13:22:56.000000000 +0200 |
41 |
|
|
+++ mezzanine_patched_smeserver-freepbx-0.1/root/usr/share/freepbx/scripts/uninstall.sh 2009-02-12 00:19:52.000000000 +0100 |
42 |
|
|
@@ -8,7 +8,7 @@ |
43 |
|
|
echo "This script will remove from your server:" |
44 |
|
|
echo " - freepbx and asterisk cdr MySQL databases" |
45 |
|
|
echo " - freepbx MySQL User" |
46 |
|
|
-echo " - freepbx DB entries (freepbx, httpd-fpbx and zaptel)" |
47 |
|
|
+echo " - freepbx DB entries (freepbx, httpd-fpbx and dahdi)" |
48 |
|
|
echo " - /opt/freepbx" |
49 |
|
|
echo "" |
50 |
|
|
echo -n "Are you sure you want to remove FreePBX permanently ? (y/n) [n] " |
51 |
|
|
@@ -26,7 +26,7 @@ |
52 |
|
|
echo "Removing SME DB entries..." |
53 |
|
|
/sbin/e-smith/db configuration delete freepbx |
54 |
|
|
/sbin/e-smith/db configuration delete httpd-fpbx |
55 |
|
|
- /sbin/e-smith/db configuration delete zaptel |
56 |
|
|
+ /sbin/e-smith/db configuration delete dahdi |
57 |
|
|
echo "Removing /opt/freepbx ..." |
58 |
|
|
rm -rf /opt/freepbx |
59 |
|
|
echo "Removing this script ..." |
60 |
|
|
diff -Nur -x '*.orig' -x '*.rej' smeserver-freepbx-0.1/root/var/lib/asterisk/bin/genzaptelconf mezzanine_patched_smeserver-freepbx-0.1/root/var/lib/asterisk/bin/genzaptelconf |
61 |
|
|
--- smeserver-freepbx-0.1/root/var/lib/asterisk/bin/genzaptelconf 2009-02-12 00:22:09.000000000 +0100 |
62 |
|
|
+++ mezzanine_patched_smeserver-freepbx-0.1/root/var/lib/asterisk/bin/genzaptelconf 1970-01-01 01:00:00.000000000 +0100 |
63 |
|
|
@@ -1,570 +0,0 @@ |
64 |
|
|
-#! /bin/bash |
65 |
|
|
- |
66 |
|
|
-# genzaptelconf: generate as smartly as you can: |
67 |
|
|
-# /etc/zaptel.conf |
68 |
|
|
-# /etc/asterisk/zapata-channels.conf (to be #include-d into zapata.conf) |
69 |
|
|
-# update: |
70 |
|
|
-# /etc/default/zaptel (list of modules to load) |
71 |
|
|
-# |
72 |
|
|
-# $Id:$ |
73 |
|
|
-# |
74 |
|
|
- |
75 |
|
|
-# The script uses a number of bash-specific features |
76 |
|
|
-# TODO: either ditch them or convert to perl |
77 |
|
|
- |
78 |
|
|
-# /etc/default/zaptel may override the following variables |
79 |
|
|
-lc_country=us |
80 |
|
|
-#method=ls |
81 |
|
|
-#method=ks |
82 |
|
|
-base_exten=6000 |
83 |
|
|
- |
84 |
|
|
- |
85 |
|
|
-ZAPCONF_FILE=/etc/zaptel.conf |
86 |
|
|
-ZAPATA_FILE=/etc/asterisk/zapata-auto.conf |
87 |
|
|
-ZAPTEL_BOOT=/etc/sysconfig/zaptel |
88 |
|
|
-exten_base_dir=/etc/asterisk/extensions-phones.d |
89 |
|
|
-exten_defs_file=/etc/asterisk/extensions-defs.conf |
90 |
|
|
-ztcfg_cmd=ztcfg |
91 |
|
|
- |
92 |
|
|
-# a temporary directory. Created when the switch -r is parsed on getopts |
93 |
|
|
-# and deleted in the end on update_extensions_defs |
94 |
|
|
-tmp_dir= |
95 |
|
|
- |
96 |
|
|
-# read default configuration from /etc/default/zaptel |
97 |
|
|
-if [ -r $ZAPTEL_BOOT ]; then . $ZAPTEL_BOOT; fi |
98 |
|
|
- |
99 |
|
|
-# work around a bug (that was already fixed) in the installer: |
100 |
|
|
-if [ "$lc_country" = '' ]; then lc_country=us; fi |
101 |
|
|
- |
102 |
|
|
-ALL_MODULES="wctdm wcfxo wcfxs pciradio tor2 torisa wct1xxp wct4xxp wcte11xp wcusb ztd_eth ztdummy" |
103 |
|
|
-force_stop_ast=yes |
104 |
|
|
-do_detect=no |
105 |
|
|
-do_unload=no |
106 |
|
|
-verbose=no |
107 |
|
|
-rapid_extens='' |
108 |
|
|
-# global: current extension number in extensions list. Should only be |
109 |
|
|
-# changed in print_pattern: |
110 |
|
|
-rapid_cur_exten=1 |
111 |
|
|
-# set the TRUNK in extensidialplan dialplan defs file rapid_conf_mode=no |
112 |
|
|
- |
113 |
|
|
-die() { |
114 |
|
|
- echo "$@" >&2 |
115 |
|
|
- exit 1 |
116 |
|
|
-} |
117 |
|
|
- |
118 |
|
|
-say() { |
119 |
|
|
- if [ "$verbose" = no ]; then |
120 |
|
|
- return |
121 |
|
|
- fi |
122 |
|
|
- echo "$@" >&2 |
123 |
|
|
-} |
124 |
|
|
- |
125 |
|
|
-run_ztcfg() { |
126 |
|
|
- if [ "$verbose" = no ]; then |
127 |
|
|
- $ztcfg_cmd "$@" |
128 |
|
|
- else |
129 |
|
|
- say "Reconfiguring identified channels" |
130 |
|
|
- $ztcfg_cmd -vv "$@" |
131 |
|
|
- fi |
132 |
|
|
-} |
133 |
|
|
- |
134 |
|
|
-do_update() { |
135 |
|
|
- sed -i.bak "s/^$1=.*\$/$1=\"$2\"/" ${ZAPTEL_BOOT} |
136 |
|
|
- if ! grep -q "^$1=" ${ZAPTEL_BOOT}; then |
137 |
|
|
- echo "$1=\"$2\"" >> ${ZAPTEL_BOOT} |
138 |
|
|
- fi |
139 |
|
|
-} |
140 |
|
|
- |
141 |
|
|
-update_extensions_defs() { |
142 |
|
|
- if [ "$rapid_conf_mode" = 'yes' ] |
143 |
|
|
- then |
144 |
|
|
- say "DEBUG: Updating dialplan defs file $exten_defs_file" |
145 |
|
|
- if [ "`echo $tmp_dir/fxo_* | grep -v '*'`" != '' ] |
146 |
|
|
- then |
147 |
|
|
- trunk_nums=`cat $tmp_dir/fxo_* | sort -n | xargs` |
148 |
|
|
- say "Configuring TRUNK to be [first of] zaptel channels: $trunk_nums" |
149 |
|
|
- trunk_dev=`echo $trunk_nums| sed -e 's/ /\\\\\\&/g' -e 's/[0-9a-zA-Z]\+/Zap\\\\\\/&/g'` |
150 |
|
|
- echo >&2 sed -i "s/^TRUNK.*=>.*/TRUNK => $trunk_dev/" $exten_defs_file |
151 |
|
|
- sed -i "s/^TRUNK.*=>.*/TRUNK => $trunk_dev/" $exten_defs_file |
152 |
|
|
- if ! grep -q "^TRUNK =>" $exten_defs_file; then |
153 |
|
|
- trunk_dev=`echo $trunk_nums| sed -e 's/ /&/g' -e 's/[0-9a-zA-Z]*/Zap\\/&/g'` |
154 |
|
|
- echo "TRUNK => $trunk_dev" >> $exten_defs_file |
155 |
|
|
- fi |
156 |
|
|
- else |
157 |
|
|
- say "Warning: No FXO channel for trunk. Moving on." |
158 |
|
|
- fi |
159 |
|
|
- if [ "`echo $tmp_dir/fxs_* | grep -v '*'`" != '' ] |
160 |
|
|
- then |
161 |
|
|
- fxs_nums=`cat $tmp_dir/fxs_* | sort -n | xargs` |
162 |
|
|
- zap_nums=`grep '^[^;].*Zap/\${CHAN_ZAP_' $exten_base_dir/*.conf | \ |
163 |
|
|
- sed -e 's/.*Zap\/\${CHAN_ZAP_\([0-9]*\)}.*/\1/' | sort -u | xargs` |
164 |
|
|
- say "Configuring channels: $fxs_nums as channel placeholders: $zap_nums" |
165 |
|
|
- j=1 |
166 |
|
|
- for i in $zap_nums |
167 |
|
|
- do |
168 |
|
|
- chan=`echo $fxs_nums | awk "{print \\$$i}"` |
169 |
|
|
- if [ "$chan" = '' ] |
170 |
|
|
- then |
171 |
|
|
- # if the result is empty, we probably got past the last one. |
172 |
|
|
- # bail out. |
173 |
|
|
- say "Warning: No FXS channel for CHAN_ZAP_$i. Moving on" |
174 |
|
|
- break |
175 |
|
|
- fi |
176 |
|
|
- say "DEBUG: setting channel $chan to placeholder $i" |
177 |
|
|
- if grep -q "^CHAN_ZAP_$i " $exten_defs_file |
178 |
|
|
- then |
179 |
|
|
- sed -i -e "s/^CHAN_ZAP_$i .*/CHAN_ZAP_$i => Zap\/$chan/" $exten_defs_file |
180 |
|
|
- else |
181 |
|
|
- echo "CHAN_ZAP_$i => Zap/$chan" >> $exten_defs_file |
182 |
|
|
- fi |
183 |
|
|
- done |
184 |
|
|
- fi |
185 |
|
|
- # cleaning up the temp dir |
186 |
|
|
- if [ -d "$tmp_dir" ]; then rm -rf "$tmp_dir"; fi |
187 |
|
|
- fi |
188 |
|
|
-} |
189 |
|
|
- |
190 |
|
|
-usage() { |
191 |
|
|
- program=`basename $0` |
192 |
|
|
- |
193 |
|
|
- echo >&2 "$program: generate zaptel.conf" |
194 |
|
|
- echo >&2 "usage:" |
195 |
|
|
- echo >&2 " $program [-v] [-m k|l|g] [-c <country_code>] [-r |-e <base_exten>] " |
196 |
|
|
- echo >&2 " $program [-v] -l" |
197 |
|
|
- echo >&2 " $program -u" |
198 |
|
|
- echo >&2 " $program -h (this screen)" |
199 |
|
|
- echo >&2 "" |
200 |
|
|
- echo >&2 "Options:" |
201 |
|
|
- echo >&2 " -c CODE: set the country code (default: $lc_country)" |
202 |
|
|
- echo >&2 " -e NUM: set the base extension number (default: $base_exten)" |
203 |
|
|
- echo >&2 " -m: set signalling method (gs/ks/ls, default: $method)" |
204 |
|
|
- echo >&2 " -l: output a list of detected channels instead of zaptel.conf" |
205 |
|
|
- echo >&2 " -u: Unload zaptel modules" |
206 |
|
|
- echo >&2 " -v: verbose" |
207 |
|
|
- echo >&2 " -r: rapid configuration mode: configure Zaptel FXS channels from " |
208 |
|
|
- echo >&2 " existing Rapid extension files. FXOs will all be TRUNK " |
209 |
|
|
-} |
210 |
|
|
- |
211 |
|
|
-# $1: channel number |
212 |
|
|
-print_pattern() { |
213 |
|
|
- local chan=$1 |
214 |
|
|
- local sig=$2 #fxs/fxo |
215 |
|
|
- local mode=$3 |
216 |
|
|
- case "$mode" in |
217 |
|
|
- zaptel) echo "${sig}$method=$chan" ;; |
218 |
|
|
- list) echo $chan $sig;; |
219 |
|
|
- zapata) |
220 |
|
|
- echo "signalling=${sig}_$method" |
221 |
|
|
- if [ "$sig" = 'fxo' ] |
222 |
|
|
- then |
223 |
|
|
- echo "; Note: this is an extension. Create a ZAP extension in AMP for Channel $chan" |
224 |
|
|
- echo "context=from-internal" |
225 |
|
|
- echo "group=1" |
226 |
|
|
- # to preconfigure channel 1's extension to 550, set |
227 |
|
|
- # chan_1_exten=550 |
228 |
|
|
- # in, e.g, /etc/default/zaptel |
229 |
|
|
- var_name=`echo chan_${chan}_exten` |
230 |
|
|
- cfg_exten=`echo ${!var_name} | tr -d -c 0-9` |
231 |
|
|
- var_name=`echo chan_${chan}_vmbox` |
232 |
|
|
- cfg_vmbox=`echo ${!var_name} | tr -d -c 0-9` |
233 |
|
|
- var_name=`echo chan_${chan}_cntxt` |
234 |
|
|
- cfg_cntxt=`echo ${!var_name} | tr -d -c 0-9` |
235 |
|
|
- |
236 |
|
|
- # if option -E was given, get configuration from current extension |
237 |
|
|
- if [ "$rapid_conf_mode" = 'yes' ] |
238 |
|
|
- then |
239 |
|
|
- rap_exten=`echo $rapid_extens |awk "{print \\$$rapid_cur_exten}"` |
240 |
|
|
- if [ "$rap_exten" != '' ] |
241 |
|
|
- then |
242 |
|
|
- rap_cfgfile="$exten_base_dir/$rap_exten.conf" |
243 |
|
|
- if [ -r "$rap_exten" ] |
244 |
|
|
- then |
245 |
|
|
- cfg_exten=$rap_exten |
246 |
|
|
- # the vmbox is the third parameter to stdexten |
247 |
|
|
- rap_vmbox=`grep '^[^;].*Macro(stdexten' $rap_exten | cut -d, -f3 \ |
248 |
|
|
- | cut -d')' -f1 | tr -d -c '0-9@a-zA-Z'` |
249 |
|
|
- if [ "$rap_vmbox" ]!= '' ; then cfg_vmbox=$rap_vmbox; fi |
250 |
|
|
- fi |
251 |
|
|
- fi |
252 |
|
|
- rapid_cur_exten=$(($rapid_cur_exten + 1)) |
253 |
|
|
- fi |
254 |
|
|
- |
255 |
|
|
- if [ "$cfg_exten" = '' ] |
256 |
|
|
- then # No extension number set for this channel |
257 |
|
|
- exten=$(($chan+$base_exten)) |
258 |
|
|
- else # use the pre-configured extension number |
259 |
|
|
- exten=$cfg_exten |
260 |
|
|
- fi |
261 |
|
|
- # is there any real need to set 'mailbox=' ? |
262 |
|
|
- if [ "x$cfg_vmbox" = x ] |
263 |
|
|
- then # No extension number set for this channel |
264 |
|
|
- vmbox=$exten |
265 |
|
|
- else # use the pre-configured extension number |
266 |
|
|
- vmbox=$cfg_vmbox |
267 |
|
|
- fi |
268 |
|
|
- # echo "callerid=\"Channel $chan\" <$exten>" |
269 |
|
|
- # echo "mailbox=$exten" |
270 |
|
|
- else # we have may have set it. So reset it: |
271 |
|
|
- echo "; Note: this is a trunk. Create a ZAP trunk in AMP for Channel $chan" |
272 |
|
|
- echo "context=from-zaptel" |
273 |
|
|
- echo "group=0" |
274 |
|
|
- # echo "callerid=\"\" <0>" |
275 |
|
|
- # echo "mailbox=" |
276 |
|
|
- fi |
277 |
|
|
- |
278 |
|
|
- echo "channel => $chan" |
279 |
|
|
- echo "" |
280 |
|
|
- |
281 |
|
|
- # Keep a note of what channels we have identified |
282 |
|
|
- say "DEBUG: adding to channels list: channel: $chan, sig: $sig" |
283 |
|
|
- case "$sig" in |
284 |
|
|
- fxs) |
285 |
|
|
- echo $chan >$tmp_dir/fxo_$chan |
286 |
|
|
- say "DEBUG: FXO list now contains: `cat $tmp_dir/fxo_* |xargs`" |
287 |
|
|
- ;; |
288 |
|
|
- fxo) |
289 |
|
|
- echo $chan >$tmp_dir/fxs_$chan |
290 |
|
|
- say "DEBUG: FXS list now contains: `cat $tmp_dir/fxs_* |xargs`" |
291 |
|
|
- ;; |
292 |
|
|
- esac |
293 |
|
|
- ;; |
294 |
|
|
- esac |
295 |
|
|
- |
296 |
|
|
-} |
297 |
|
|
- |
298 |
|
|
-# the number of channels from /proc/zaptel |
299 |
|
|
-# must always print a number as its output. |
300 |
|
|
-count_proc_zap_lines() { |
301 |
|
|
- # if zaptel is not loaded there are 0 channels: |
302 |
|
|
- if [ ! -d /proc/zaptel ]; then echo '0'; return; fi |
303 |
|
|
- |
304 |
|
|
- ( |
305 |
|
|
- for file in `echo /proc/zaptel/* |grep -v '\*'` |
306 |
|
|
- do sed -e 1,2d $file # remove the two header lines |
307 |
|
|
- done |
308 |
|
|
- ) | wc -l # the total number of lines |
309 |
|
|
-} |
310 |
|
|
- |
311 |
|
|
-load_modules() { |
312 |
|
|
- say "Test Loading modules:" |
313 |
|
|
- for i in zaptel $ALL_MODULES |
314 |
|
|
- do |
315 |
|
|
- if [ "$i" = ztdummy ]; then |
316 |
|
|
- continue # No hardware to detect |
317 |
|
|
- fi |
318 |
|
|
- lines_before=`count_proc_zap_lines` |
319 |
|
|
- args="${i}_args" |
320 |
|
|
- eval "args=\$$args" |
321 |
|
|
- # a module is worth listing if it: |
322 |
|
|
- # a. loaded successfully, and |
323 |
|
|
- # b. added channels lines under /proc/zaptel/* |
324 |
|
|
- if /sbin/modprobe $i $args 2> /dev/null && \ |
325 |
|
|
- [ $lines_before -lt `count_proc_zap_lines` ] |
326 |
|
|
- then |
327 |
|
|
- probed_modules="$probed_modules $i" |
328 |
|
|
- say " ok $i $args" |
329 |
|
|
- else |
330 |
|
|
- say " - $i $args" |
331 |
|
|
- fi |
332 |
|
|
- done |
333 |
|
|
-} |
334 |
|
|
- |
335 |
|
|
- |
336 |
|
|
-unload_modules() { |
337 |
|
|
- if |
338 |
|
|
- pids="$(pgrep asterisk)" |
339 |
|
|
- [ "$pids" != '' ] |
340 |
|
|
- then |
341 |
|
|
- die "Before unloading -- STOP asterisk (pids=$pids)." |
342 |
|
|
- fi |
343 |
|
|
- say "Unloading zaptel modules:" |
344 |
|
|
- modlist='' |
345 |
|
|
- for i in $ALL_MODULES zaptel |
346 |
|
|
- do |
347 |
|
|
- if lsmod | grep "^$i *" > /dev/null; then |
348 |
|
|
- modlist="$modlist $i" |
349 |
|
|
- say -n "$i " |
350 |
|
|
- fi |
351 |
|
|
- done |
352 |
|
|
- /sbin/modprobe -r $modlist |
353 |
|
|
- say '' |
354 |
|
|
-} |
355 |
|
|
- |
356 |
|
|
-detect() { |
357 |
|
|
- unload_modules |
358 |
|
|
- load_modules |
359 |
|
|
- modlist="$probed_modules" |
360 |
|
|
- #for i in $ALL_MODULES |
361 |
|
|
- #do |
362 |
|
|
- # if lsmod | grep "^$i *" > /dev/null; then |
363 |
|
|
- # modlist="$modlist $i" |
364 |
|
|
- # fi |
365 |
|
|
- #done |
366 |
|
|
- modlist="$(echo $modlist)" # clean spaces |
367 |
|
|
- if [ "$modlist" = '' ]; then |
368 |
|
|
- modlist=ztdummy # Fallback |
369 |
|
|
- fi |
370 |
|
|
- say "Updating '${ZAPTEL_BOOT}'" |
371 |
|
|
- do_update ZAPTEL_MODS "$modlist" |
372 |
|
|
-} |
373 |
|
|
- |
374 |
|
|
-check_tdm_sigtype() { |
375 |
|
|
- chan_num=$1 |
376 |
|
|
- sig_type=$2 |
377 |
|
|
- mode=$3 |
378 |
|
|
- |
379 |
|
|
- case "$sig_type" in |
380 |
|
|
- fxs)chan_sig_type=fxo;; |
381 |
|
|
- fxo)chan_sig_type=fxs;; |
382 |
|
|
- esac |
383 |
|
|
- |
384 |
|
|
-# print_pattern $chan_num $chan_sig_type $mode |
385 |
|
|
- |
386 |
|
|
- $ztcfg_cmd -c <(print_pattern $chan_num $chan_sig_type zaptel) 2>/dev/null \ |
387 |
|
|
- || return 1 |
388 |
|
|
- if head -c1 /dev/zap/$chan_num >/dev/null 2>/dev/null |
389 |
|
|
- then |
390 |
|
|
- print_pattern $chan_num $chan_sig_type $mode |
391 |
|
|
- return 0 |
392 |
|
|
- else |
393 |
|
|
- return 1 |
394 |
|
|
- fi |
395 |
|
|
-} |
396 |
|
|
- |
397 |
|
|
-# output a list of extensions that need a channel |
398 |
|
|
-get_rapid_extens() { |
399 |
|
|
- if [ "$rapid_conf_mode" = 'yes' ] |
400 |
|
|
- then |
401 |
|
|
- rapid_extens=`grep -l '^[^;].*Zap/\${CHAN_ZAP_' $exten_base_dir/*.conf 2>/dev/null | \ |
402 |
|
|
- rev | cut -d/ -f1 | cut -d. -f2- | rev | xargs` |
403 |
|
|
- say "Need to configure extensions: $rapid_extens" |
404 |
|
|
- fi |
405 |
|
|
-} |
406 |
|
|
- |
407 |
|
|
-genconf() { |
408 |
|
|
- local mode=$1 |
409 |
|
|
- |
410 |
|
|
- # reset FXO list (global) |
411 |
|
|
- say "DEBUG: resetting channels lists" |
412 |
|
|
- rm -f $tmp_dir/fx{s,o}_* |
413 |
|
|
- |
414 |
|
|
- if [ "$mode" = 'zapata' ] |
415 |
|
|
- then |
416 |
|
|
- rem_char=';' |
417 |
|
|
- else |
418 |
|
|
- rem_char='#' |
419 |
|
|
- fi |
420 |
|
|
- |
421 |
|
|
- spanlist=`echo /proc/zaptel/* | grep -v '\*'` |
422 |
|
|
- |
423 |
|
|
- #if [ "$spanlist" == "" ]; then |
424 |
|
|
- # die "No zapata interfaces in /proc/zaptel" |
425 |
|
|
- #fi |
426 |
|
|
- |
427 |
|
|
- |
428 |
|
|
- case "$mode" in |
429 |
|
|
- zaptel) |
430 |
|
|
- cat <<EOF |
431 |
|
|
-# Autogenerated by $0 -- do not hand edit |
432 |
|
|
-# Zaptel Configuration File |
433 |
|
|
-# |
434 |
|
|
-# This file is parsed by the Zaptel Configurator, ztcfg |
435 |
|
|
-# |
436 |
|
|
- |
437 |
|
|
-# It must be in the module loading order |
438 |
|
|
- |
439 |
|
|
-EOF |
440 |
|
|
- ;; |
441 |
|
|
- zapata) |
442 |
|
|
- cat <<EOF |
443 |
|
|
-; Autogenerated by $0 -- do not hand edit |
444 |
|
|
-; Zaptel Channels Configurations (zapata.conf) |
445 |
|
|
-; |
446 |
|
|
-; This is not intended to be a complete zapata.conf. Rather, it is intended |
447 |
|
|
-; to be #include-d by /etc/zapata.conf that will include the global settings |
448 |
|
|
-; |
449 |
|
|
-callerid=asreceived |
450 |
|
|
-EOF |
451 |
|
|
- ;; |
452 |
|
|
- esac |
453 |
|
|
- |
454 |
|
|
- # For each line in the spanlist: see if it represents a channel. |
455 |
|
|
- # if it does, test that the channel is usable. |
456 |
|
|
- # we do that by configuring it (using ztcfg with a 1-line config file) |
457 |
|
|
- # and then trying to read 1 byte from the device file. |
458 |
|
|
- # |
459 |
|
|
- # The '<(command)' syntax creates a temporary file whose content is is the |
460 |
|
|
- # output of 'command'. |
461 |
|
|
- # |
462 |
|
|
- # This approach failed with the T1 card we have: the read operation simply |
463 |
|
|
- # hung. |
464 |
|
|
- # |
465 |
|
|
- # Another problem with such an approach is how to include an existing |
466 |
|
|
- # configuration file. For instance: how to include some default settings. |
467 |
|
|
- # |
468 |
|
|
- # Maybe an 'include' directive should be added to zaptel.conf ? |
469 |
|
|
- #cat $spanlist | |
470 |
|
|
- for procfile in $spanlist |
471 |
|
|
- do |
472 |
|
|
- # the first line is the title line. It states the model name |
473 |
|
|
- # the second line is empty |
474 |
|
|
- title=`head -n 1 $procfile` |
475 |
|
|
- echo "" |
476 |
|
|
- echo "$rem_char $title" |
477 |
|
|
- |
478 |
|
|
- # The rest of the lines are per-channel lines |
479 |
|
|
- sed -e 1,2d $procfile | \ |
480 |
|
|
- while read line |
481 |
|
|
- do |
482 |
|
|
- # in case this is a real channel. |
483 |
|
|
- chan_num=`echo $line |awk '{print $1}'` |
484 |
|
|
- case "$line" in |
485 |
|
|
- *WCT1/*) # we're yet to detect when a channel is active |
486 |
|
|
- echo "$rem_char channel $chan_num, WCT1, unhandled for now" |
487 |
|
|
- ;; |
488 |
|
|
- *WCTDM/*) |
489 |
|
|
- # this can be either FXS or FXO |
490 |
|
|
- check_tdm_sigtype $chan_num fxs $mode || \ |
491 |
|
|
- check_tdm_sigtype $chan_num fxo $mode || \ |
492 |
|
|
- echo "$rem_char channel $chan_num, WCTDM, inactive." |
493 |
|
|
- ;; |
494 |
|
|
- *WRTDM/*) |
495 |
|
|
- # this can be either FXS or FXO |
496 |
|
|
- check_tdm_sigtype $chan_num fxs $mode || \ |
497 |
|
|
- check_tdm_sigtype $chan_num fxo $mode || \ |
498 |
|
|
- echo "$rem_char channel $chan_num, WRTDM, inactive." |
499 |
|
|
- ;; |
500 |
|
|
- *WCFXO/*) |
501 |
|
|
- check_tdm_sigtype $chan_num fxo $mode || \ |
502 |
|
|
- echo "$rem_char channel $chan_num, WCFXO, inactive." |
503 |
|
|
- ;; |
504 |
|
|
- '') ;; # Empty line (after span header) |
505 |
|
|
- *) echo "$rem_char ??: $line";; |
506 |
|
|
- esac |
507 |
|
|
- done |
508 |
|
|
- done |
509 |
|
|
- |
510 |
|
|
- if [ "$mode" = 'zaptel' ] |
511 |
|
|
- then |
512 |
|
|
- cat <<EOF |
513 |
|
|
- |
514 |
|
|
-# Global data |
515 |
|
|
- |
516 |
|
|
-EOF |
517 |
|
|
- echo "loadzone = $loadzone" |
518 |
|
|
- echo "defaultzone = $defaultzone" |
519 |
|
|
- fi |
520 |
|
|
- |
521 |
|
|
- if [ "$mode" = 'zapata' ] |
522 |
|
|
- then |
523 |
|
|
- update_extensions_defs |
524 |
|
|
- fi |
525 |
|
|
-} |
526 |
|
|
- |
527 |
|
|
-while getopts 'c:de:E:hlm:rsuv' arg |
528 |
|
|
-do |
529 |
|
|
- case "$arg" in |
530 |
|
|
- e) # guarantee that it is a number: |
531 |
|
|
- new_base_exten=`echo $OPTARG | tr -d -c 0-9` |
532 |
|
|
- if [ "x$new_base_exten" != x ]; then base_exten=$new_base_exten; fi |
533 |
|
|
- ;; |
534 |
|
|
- c) lc_country=`echo $OPTARG | tr -d -c a-z` ;; |
535 |
|
|
- u) do_unload=yes ;; |
536 |
|
|
- v) verbose=yes ;; |
537 |
|
|
- l) mode='list' ;; |
538 |
|
|
- m) |
539 |
|
|
- case "$OPTARG" in |
540 |
|
|
- k|l|g)method=${OPTARG}s ;; |
541 |
|
|
- *) echo >&2 "unknown signalling method ${OPTARG}s, defaulting to \"$method\"";; |
542 |
|
|
- esac |
543 |
|
|
- ;; |
544 |
|
|
- r) |
545 |
|
|
- rapid_conf_mode=yes |
546 |
|
|
- tmp_dir=`mktemp -d` || die "$0: failed to create temporary directory. Aborting" |
547 |
|
|
- ;; |
548 |
|
|
- *) echo >&2 "unknown parameter -$arg, Aborting"; usage; exit 1;; |
549 |
|
|
- esac |
550 |
|
|
-done |
551 |
|
|
-shift $(( $OPTIND-1 )) |
552 |
|
|
-if [ $# != 0 ]; then |
553 |
|
|
- echo >&2 "$0: too many parameters" |
554 |
|
|
- usage |
555 |
|
|
- exit 1 |
556 |
|
|
-fi |
557 |
|
|
- |
558 |
|
|
-case "$lc_country" in |
559 |
|
|
- # the list was generated from the source of zaptel: |
560 |
|
|
- #grep '{.*[0-9]\+,.*"[a-z][a-z]"' zonedata.c | cut -d'"' -f 2 | xargs |tr ' ' '|' |
561 |
|
|
- us|au|fr|nl|uk|fi|es|jp|no|at|nz|it|gr|tw|cl|se|be|il) |
562 |
|
|
- :;; |
563 |
|
|
-*) |
564 |
|
|
- lc_country=us |
565 |
|
|
- echo >&2 "unknown country-code $lc_country, defaulting to \"us\"";; |
566 |
|
|
-esac |
567 |
|
|
-# any reason for loadzone and defaultzone to be different? If so, this is |
568 |
|
|
-# the place to make that difference |
569 |
|
|
-loadzone=$lc_country |
570 |
|
|
-defaultzone=$loadzone |
571 |
|
|
- |
572 |
|
|
-# Choose reasonable default for signaling method (by country) |
573 |
|
|
-if [ "" = "$method" ]; then |
574 |
|
|
- case "$lc_country" in |
575 |
|
|
- il) method=ls ;; |
576 |
|
|
- *) method=ks ;; |
577 |
|
|
- esac |
578 |
|
|
-fi |
579 |
|
|
- |
580 |
|
|
-# make sure asterisk is not in our way |
581 |
|
|
-if [ "$force_stop_ast" = 'yes' ] |
582 |
|
|
-then |
583 |
|
|
-# /etc/init.d/asterisk stop 1>&2 |
584 |
|
|
- /usr/sbin/amportal stop 1>&2 |
585 |
|
|
-else |
586 |
|
|
- if ps auxww |grep asterisk | grep -v -- -r | grep -q -v grep |
587 |
|
|
- then |
588 |
|
|
- echo >&2 "Asterisk is already running. Configuration left untouched" |
589 |
|
|
- echo >&2 "You can use the option -s to shut down Asterisk for the" |
590 |
|
|
- echo >&2 "duration of the detection." |
591 |
|
|
- exit 1 |
592 |
|
|
- fi |
593 |
|
|
-fi |
594 |
|
|
- |
595 |
|
|
-if [ "$do_unload" = yes ] |
596 |
|
|
-then |
597 |
|
|
- unload_modules |
598 |
|
|
- exit |
599 |
|
|
-fi |
600 |
|
|
- |
601 |
|
|
-if [ "$do_detect" = yes ] |
602 |
|
|
-then |
603 |
|
|
- detect |
604 |
|
|
-fi |
605 |
|
|
- |
606 |
|
|
-if [ "$mode" = list ]; then |
607 |
|
|
- genconf list |
608 |
|
|
-else |
609 |
|
|
- get_rapid_extens |
610 |
|
|
- echo "Generating '${ZAPCONF_FILE}'" |
611 |
|
|
- mv "${ZAPCONF_FILE}" "${ZAPCONF_FILE}.bak" |
612 |
|
|
- genconf zaptel > "${ZAPCONF_FILE}" |
613 |
|
|
- echo "Generating '${ZAPATA_FILE}'" |
614 |
|
|
- mv "${ZAPATA_FILE}" "${ZAPATA_FILE}.bak" |
615 |
|
|
- genconf zapata > "${ZAPATA_FILE}" |
616 |
|
|
- run_ztcfg |
617 |
|
|
-fi |
618 |
|
|
- |
619 |
|
|
-if [ "$force_stop_ast" = 'yes' ] |
620 |
|
|
-then |
621 |
|
|
-# /etc/init.d/asterisk start 1>&2 |
622 |
|
|
- /etc/init.d/zaptel stop |
623 |
|
|
- /etc/init.d/zaptel start |
624 |
|
|
- /usr/sbin/amportal start 1>&2 |
625 |
|
|
-fi |
626 |
|
|
- |
627 |
|
|
-# if in verbose mode: verify that asterisk is running |
628 |
|
|
-if [ "$verify" != 'no' ] |
629 |
|
|
- then |
630 |
|
|
- say "Checking channels configured in Asterisk:" |
631 |
|
|
- sleep 1 # give it some time. This is enough on our simple test server |
632 |
|
|
- /usr/local/sbin/ast-cmd cmd "zap show channels" |
633 |
|
|
-fi |