-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathinstall.php
236 lines (211 loc) · 7.76 KB
/
install.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
<?php
if (!defined('FREEPBX_IS_AUTH')) { die('No direct script access allowed'); }
global $db;
global $amp_conf;
global $asterisk_conf;
if (! function_exists('out')) {
function out ($text) {
echo $text."<br />";
}
}
if (! function_exists('outn')) {
function outn ($text) {
echo $text;
}
}
$entries = array(
'module_name'=>'wctdm24xxp',
'tone_region'=>'us',
'opermode_checkbox'=>0,
'opermode'=>'USA',
'alawoverride_checkbox'=>0,
'alawoverride'=>0,
'fxs_honor_mode_checkbox'=>0,
'fxs_honor_mode'=>0,
'boostringer_checkbox'=>0,
'boostringer'=>0,
'lowpower_checkbox'=>0,
'lowpower'=>0,
'fastringer_checkbox'=>0,
'fastringer'=>0,
'ringdetect_checkbox'=>0,
'ringdetect'=>0,
'mwi_checkbox'=>0,
'mwi'=>'none',
'neon_voltage'=>'',
'neon_offlimit'=>'',
'echocan_nlp_type'=>0,
'echocan_nlp_threshold'=>'',
'echocan_nlp_max_supp'=>''
);
foreach ($entries as $entry=>$default_val) {
$sql = "INSERT INTO dahdi_advanced (keyword, default_val) VALUES ('{$entry}', '{$default_val}')";
$result = $db->query($sql);
if (DB::IsError($result)) {
unset($result);
continue;
}
unset($result);
}
$freepbx_conf =& freepbx_conf::create();
// DAHDISHOWDIGITALCHANS in Advanced Settings of FreePBX
//
$set['value'] = false;
$set['defaultval'] =& $set['value'];
$set['readonly'] = 0;
$set['hidden'] = 0;
$set['level'] = 1;
$set['module'] = 'dahdiconfig'; //This will help delete the settings when module is uninstalled
$set['category'] = 'DAHDi Configuration Module';
$set['emptyok'] = 0;
$set['name'] = 'Allow PRI Discrete Channels';
$set['description'] = 'DAHDi trunk configuration is normally done using groups for PRI configuration. If there is a need to configure trunks to specific channels, setting this to true will allow each channel to be configured. This can be useful when troubleshooting a PRI and trying to isolate a bad B Channel.';
$set['type'] = CONF_TYPE_BOOL;
$freepbx_conf->define_conf_setting('DAHDISHOWDIGITALCHANS',$set,true);
// DAHDISHOWDIGITALCHANS in Advanced Settings of FreePBX
//
$set['value'] = false;
$set['defaultval'] =& $set['value'];
$set['readonly'] = 1;
$set['hidden'] = 0;
$set['level'] = 1;
$set['module'] = 'dahdiconfig'; //This will help delete the settings when module is uninstalled
$set['category'] = 'DAHDi Configuration Module';
$set['emptyok'] = 0;
$set['name'] = 'Use mock hardware instead of real hardware';
$set['description'] = 'Some development environments can not host DAHDI hardware so this mode uses mock files to acomplish the tasks.';
$set['type'] = CONF_TYPE_BOOL;
$freepbx_conf->define_conf_setting('DAHDIMOCKHW',$set,true);
$set['value'] = true;
$set['defaultval'] =& $set['value'];
$set['readonly'] = 0;
$set['hidden'] = 0;
$set['level'] = 1;
$set['module'] = 'dahdiconfig'; //This will help delete the settings when module is uninstalled
$set['category'] = 'DAHDi Configuration Module';
$set['emptyok'] = 0;
$set['name'] = 'Disable DAHDi Configuration Writes';
$set['description'] = 'By default the DAHDi configuration module will NOT write out any data to protect any current configuration settings';
$set['type'] = CONF_TYPE_BOOL;
$freepbx_conf->define_conf_setting('DAHDIDISABLEWRITE',$set,true);
$set['value'] = '/etc/init.d/dahdi';
$set['defaultval'] =& $set['value'];
$set['readonly'] = 0;
$set['hidden'] = 0;
$set['level'] = 0;
$set['module'] = 'dahdiconfig'; //This will help delete the settings when module is uninstalled
$set['category'] = 'DAHDi Configuration Module';
$set['emptyok'] = 0;
$set['name'] = 'DAHDi Executable Location';
$set['description'] = 'Location of the DAHDi Executable';
$set['type'] = CONF_TYPE_TEXT;
$freepbx_conf->define_conf_setting('DAHDIEXEC',$set,true);
$set['value'] = '/etc/modprobe.d/dahdi.conf';
$set['defaultval'] =& $set['value'];
$set['readonly'] = 0;
$set['hidden'] = 0;
$set['level'] = 0;
$set['module'] = 'dahdiconfig'; //This will help delete the settings when module is uninstalled
$set['category'] = 'DAHDi Configuration Module';
$set['emptyok'] = 0;
$set['name'] = 'ModProbe.d Configuration File Location';
$set['description'] = 'DAHDi ModProbe.d Configuration File Location (modprobe.d/dahdi.conf)';
$set['type'] = CONF_TYPE_TEXT;
$freepbx_conf->define_conf_setting('DAHDIMODPROBELOC',$set,true);
$set['value'] = '/etc/dahdi/system.conf';
$set['defaultval'] =& $set['value'];
$set['readonly'] = 0;
$set['hidden'] = 0;
$set['level'] = 0;
$set['module'] = 'dahdiconfig'; //This will help delete the settings when module is uninstalled
$set['category'] = 'DAHDi Configuration Module';
$set['emptyok'] = 0;
$set['name'] = 'System Configuration File Location';
$set['description'] = 'DAHDi System Configuration File Location (dahdi/system.conf)';
$set['type'] = CONF_TYPE_TEXT;
$freepbx_conf->define_conf_setting('DAHDISYSTEMLOC',$set,true);
$set['value'] = '/etc/dahdi/modules';
$set['defaultval'] =& $set['value'];
$set['readonly'] = 0;
$set['hidden'] = 0;
$set['level'] = 0;
$set['module'] = 'dahdiconfig'; //This will help delete the settings when module is uninstalled
$set['category'] = 'DAHDi Configuration Module';
$set['emptyok'] = 0;
$set['name'] = 'DAHDi Modules Location';
$set['description'] = 'DAHDi Modules Location (/etc/dahdi/modules)';
$set['type'] = CONF_TYPE_TEXT;
$freepbx_conf->define_conf_setting('DAHDIMODULESLOC',$set,true);
//echocan
//echo cancel
$set['value'] = 'oslec';
$set['defaultval'] =& $set['value'];
$set['readonly'] = 0;
$set['hidden'] = 0;
$set['level'] = 0;
$set['module'] = 'dahdiconfig'; //This will help delete the settings when module is uninstalled
$set['category'] = 'DAHDi Configuration Module';
$set['emptyok'] = 0;
$set['name'] = 'Software EC';
$set['description'] = 'software EC to use in system.conf';
$set['type'] = CONF_TYPE_TEXT;
$freepbx_conf->define_conf_setting('DAHDIECHOCAN',$set,true);
$sql = "SELECT * FROM dahdi_advanced";
$sth = \FreePBX::Database()->prepare($sql);
$sth->execute();
$advanced = $sth->fetchAll();
if(empty($advanced)) {
$globalsettings = array( // global array of values
'tone_region'=>'us',
'language'=>'en',
'busydetect'=>'yes',
'busycount'=>'10',
'usecallerid'=>'yes',
'callwaiting'=>'yes',
'usecallingpres'=>'yes',
'threewaycalling'=>'yes',
'transfer'=>'yes',
'cancallforward'=>'yes',
'callreturn'=>'yes',
'echocancel'=>'yes',
'echocancelwhenbridged'=>'no',
'echotraining'=>'no',
'immediate'=>'no',
'faxdetect'=>'no',
'rxgain'=>'0.0',
'txgain'=>'0.0'
);
outn(_('Replacing..'));
$sql = "REPLACE INTO dahdi_advanced (default_val, keyword) VALUES (:key, :value)";
$sth = \FreePBX::Database()->prepare($sql);
foreach($globalsettings as $k => $v) {
outn('..'.$k.'..');
$sth->execute([
":key" => $k,
":value" => $v
]);
}
out(_('..Done'));
}
$mod_loc = $freepbx_conf->get_conf_setting('DAHDIMODULESLOC');
if(file_exists($mod_loc)) {
$contents = file_get_contents($mod_loc);
if((!preg_match('/^wcte43x/im',$contents) && !preg_match('/^#wcte43x/im',$contents))) {
out(sprintf(_("Detected new Dahdi Module: wcte43x, Appending to %s"),basename($mod_loc)));
$data = "\n# Digium TE435\n# Digium TE235\n#wcte43x\n";
file_put_contents($mod_loc,$data,FILE_APPEND);
}
if((!preg_match('/^wcaxx/im',$contents) && !preg_match('/^#wcaxx/im',$contents))) {
out(sprintf(_("Detected new Dahdi Module: wcaxx, Appending to %s"),basename($mod_loc)));
$data = "\n# Digium A4A/A4B/A8A/A8B\n#wcaxx\n";
file_put_contents($mod_loc,$data,FILE_APPEND);
}
}
if(file_exists($amp_conf['AMPBIN']."/freepbx_engine_hook_dahdiconfig") && is_writable($amp_conf['AMPBIN']."/freepbx_engine_hook_dahdiconfig")) {
unlink($amp_conf['AMPBIN']."/freepbx_engine_hook_dahdiconfig");
}
if(!function_exists("dahdi_config2array")) {
include __DIR__."/functions.inc.php";
$dahdi_cards = new \dahdi_cards();
$dahdi_cards->checkHardware();
}