Skip to content

Commit 1ed68bb

Browse files
committed
Use 'which' to find the location of the asterisk binary, before checking for the app_swift application. On some systems, it doesn't seem to be in the default PATH. If not found in the default PATH, the AMPBIN directory is checked.
1 parent d8cc19e commit 1ed68bb

File tree

1 file changed

+22
-12
lines changed

1 file changed

+22
-12
lines changed

engines/swift.engine.php

+22-12
Original file line numberDiff line numberDiff line change
@@ -71,21 +71,31 @@ function setup_defaults() {
7171
}
7272
}
7373

74-
// Check to see if we have the swift() app, and if so, enable dynamic support.
75-
$last = exec('asterisk -rx "core show application swift" | egrep "not registered"', $eoutput, $ret);
74+
/*** Check to see if app_swift is available for dynamic support ***/
75+
// Find the asterisk command first
76+
$lastone = exec("which asterisk 2>/dev/null", $iout, $rval);
77+
if ($rval != 0 && isset($amp_conf['AMPBIN']) && !empty($amp_conf['AMPBIN'])) {
78+
$lastone = exec("which ".trim($amp_conf['AMPBIN'])."/asterisk 2>/dev/null", $iout, $rval);
79+
}
80+
81+
if ($rval == 0) {
82+
$astcmd = $lastone;
83+
84+
$last = exec($astcmd . ' -rx "core show application swift" | egrep "not registered"', $eoutput, $ret);
7685

77-
if ($ret == 0) {
78-
// Try to load it
79-
exec('asterisk -rx "module load app_swift"', $eoutput, $ret);
86+
if ($ret == 0) {
87+
// Try to load it
88+
exec($astcmd . ' -rx "module load app_swift"', $eoutput, $ret);
8089

81-
// Check again
82-
$last = exec('asterisk -rx "core show application swift" | egrep "not registered"', $eoutput, $ret);
83-
}
90+
// Check again
91+
$last = exec($astcmd . ' -rx "core show application swift" | egrep "not registered"', $eoutput, $ret);
92+
}
8493

85-
if ($ret == 1) {
86-
// App was found, enable dynamic support...
87-
$this->info['can_be_dynamic'] = 1;
88-
$this->defaults['dynamic'] = '';
94+
if ($ret == 1) {
95+
// App was found, enable dynamic support...
96+
$this->info['can_be_dynamic'] = 1;
97+
$this->defaults['dynamic'] = '';
98+
}
8999
}
90100
}
91101

0 commit comments

Comments
 (0)