fix(voicemail): automate modules.conf and voicemail includes in install.sh and fix.sh (v1.4.6)
This commit is contained in:
1 parent
9b2533695e
commit
bda4cb18a6
7 files changed
+128
-22
No files matched your search
+45
-7
@@ -70,17 +70,22 @@ class SystemChecker
|
||||
: 'Accès refusé en écriture dans /etc/asterisk pour PHP-FPM',
|
||||
];
|
||||
|
||||
// 5. Directives #tryinclude dans pjsip.conf et extensions.conf
|
||||
// 5. Directives #tryinclude dans pjsip.conf, extensions.conf, voicemail.conf et modules.conf
|
||||
$pjsipMain = @file_get_contents('/etc/asterisk/pjsip.conf') ?: '';
|
||||
$extMain = @file_get_contents('/etc/asterisk/extensions.conf') ?: '';
|
||||
$incOk = str_contains($pjsipMain, 'pjsip.custom.conf') && str_contains($extMain, 'extensions.custom.conf');
|
||||
$vmMain = @file_get_contents('/etc/asterisk/voicemail.conf') ?: '';
|
||||
$modMain = @file_get_contents('/etc/asterisk/modules.conf') ?: '';
|
||||
$incOk = str_contains($pjsipMain, 'pjsip.custom.conf')
|
||||
&& str_contains($extMain, 'extensions.custom.conf')
|
||||
&& str_contains($vmMain, 'voicemail.custom.conf')
|
||||
&& str_contains($modMain, 'app_voicemail_odbc.so');
|
||||
$checks[] = [
|
||||
'id' => 'asterisk_includes',
|
||||
'label' => 'Inclusions natives (#tryinclude *.custom.conf)',
|
||||
'label' => 'Inclusions Asterisk & Voicemail (#tryinclude & modules.conf)',
|
||||
'ok' => $incOk,
|
||||
'detail' => $incOk
|
||||
? 'pjsip.conf et extensions.conf incluent bien les fichiers .custom.conf'
|
||||
: 'Directive #tryinclude manquante dans pjsip.conf ou extensions.conf',
|
||||
? 'pjsip.conf, extensions.conf, voicemail.conf et modules.conf configurés'
|
||||
: 'Directive #tryinclude manquante ou conflit modules.conf détecté',
|
||||
];
|
||||
|
||||
// 6. Certificats TLS (Let's Encrypt ou Certificat local Debian)
|
||||
@@ -142,6 +147,25 @@ class SystemChecker
|
||||
|
||||
public static function ensureAsteriskIncludes(): void
|
||||
{
|
||||
// 1. modules.conf: Désactiver les modules voicemail ODBC/IMAP incompatibles sur Debian (évite collision bloquante avec app_voicemail.so)
|
||||
$modConf = '/etc/asterisk/modules.conf';
|
||||
if (is_file($modConf) && is_writable($modConf)) {
|
||||
$content = (string)file_get_contents($modConf);
|
||||
$changed = false;
|
||||
if (!str_contains($content, 'app_voicemail_odbc.so')) {
|
||||
if (preg_match('/\[modules\]/i', $content)) {
|
||||
$content = preg_replace('/\[modules\]/i', "[modules]\nnoload => app_voicemail_odbc.so\nnoload => app_voicemail_imap.so", $content, 1);
|
||||
$changed = true;
|
||||
} else {
|
||||
$content = "[modules]\nautoload=yes\nnoload => app_voicemail_odbc.so\nnoload => app_voicemail_imap.so\n\n" . $content;
|
||||
$changed = true;
|
||||
}
|
||||
}
|
||||
if ($changed) {
|
||||
file_put_contents($modConf, $content);
|
||||
}
|
||||
}
|
||||
|
||||
$pjsipConf = '/etc/asterisk/pjsip.conf';
|
||||
if (is_file($pjsipConf) && is_writable($pjsipConf)) {
|
||||
$content = (string)file_get_contents($pjsipConf);
|
||||
@@ -177,8 +201,20 @@ class SystemChecker
|
||||
if (is_file($vmConf) && is_writable($vmConf)) {
|
||||
$content = (string)file_get_contents($vmConf);
|
||||
$cleaned = preg_replace('/^1234 => 4242.*/m', ';1234 => 4242,Example Mailbox,root@localhost', $content);
|
||||
$cleaned = preg_replace('/^;\s*passwordlocation\s*=\s*spooldir/m', 'passwordlocation=spooldir', $cleaned);
|
||||
$cleaned = preg_replace('/^;\s*externpassnotify\s*=.*/m', 'externpassnotify=/usr/bin/php /var/www/nexus-pbx/scripts/voicemail_pass_sync.php', $cleaned);
|
||||
if (preg_match('/^;\s*passwordlocation\s*=\s*spooldir/m', $cleaned)) {
|
||||
$cleaned = preg_replace('/^;\s*passwordlocation\s*=\s*spooldir/m', 'passwordlocation=spooldir', $cleaned);
|
||||
} elseif (!str_contains($cleaned, 'passwordlocation=spooldir') && !str_contains($cleaned, 'passwordlocation = spooldir')) {
|
||||
if (preg_match('/\[general\]/i', $cleaned)) {
|
||||
$cleaned = preg_replace('/\[general\]/i', "[general]\npasswordlocation=spooldir", $cleaned, 1);
|
||||
}
|
||||
}
|
||||
if (preg_match('/^;\s*externpassnotify\s*=.*/m', $cleaned)) {
|
||||
$cleaned = preg_replace('/^;\s*externpassnotify\s*=.*/m', 'externpassnotify=/usr/bin/php /var/www/nexus-pbx/scripts/voicemail_pass_sync.php', $cleaned);
|
||||
} elseif (!str_contains($cleaned, 'externpassnotify=')) {
|
||||
if (preg_match('/\[general\]/i', $cleaned)) {
|
||||
$cleaned = preg_replace('/\[general\]/i', "[general]\nexternpassnotify=/usr/bin/php /var/www/nexus-pbx/scripts/voicemail_pass_sync.php", $cleaned, 1);
|
||||
}
|
||||
}
|
||||
if (!str_contains($cleaned, 'voicemail.custom.conf')) {
|
||||
$cleaned = rtrim($cleaned) . "\n\n#tryinclude \"voicemail.custom.conf\"\n";
|
||||
}
|
||||
@@ -187,6 +223,8 @@ class SystemChecker
|
||||
}
|
||||
}
|
||||
|
||||
@mkdir('/var/spool/asterisk/voicemail/default', 0775, true);
|
||||
|
||||
$astConf = '/etc/asterisk/asterisk.conf';
|
||||
if (is_file($astConf) && is_writable($astConf)) {
|
||||
$content = (string)file_get_contents($astConf);
|
||||
|
||||
Reference in new issue
Block a user