This commit is contained in:
poslop
2025-12-22 14:26:53 -06:00
parent dbdb3e0048
commit 8edbc53ffe

View File

@@ -19,21 +19,21 @@ require_once('/etc/freepbx.conf');
function main(): void {
$provision_dir = '/tftpboot';
$file = $provision_dir . '/482567bcdeff-features.cfg';
$argv = $_SERVER['argv'] ?? [];
$do_notify = in_array('--notify', $argv, true);
$mac_list = ['482567bcdeff', '482567bcd8f0']
$pbdb = pull_db();
$pbdb = trim_db($pbdb);
$xml = pull_xml_file($file);
foreach ($mac_list as $mac) {
$file = $provision_dir . '/' . $mac . '-features.cfg';
$attendant = remove_attendants($xml);
write_attendants($attendant, $pbdb);
write_to_file($provision_dir, $file, $xml);
$xml = pull_xml_file($file);
$attendant = remove_attendants($xml);
write_attendants($attendant, $pbdb);
write_to_file($provision_dir, $file, $xml);
}
if ($do_notify) {
notify($pbdb);
@@ -118,6 +118,24 @@ function trim_db($pbdb): array {
return $filtered;
}
function pull_mac_db(): array {
$db = FreePBX::Database();
$mac_db = [];
try {
$stmt = $db->prepare("
SELECT mac, ext
FROM endpoint_extensions
WHERE ext REGEXP '^[0-9]+$'
ORDER BY CAST(extension AS UNSIGNED)
");
$stmt->execute();
$mac_db = $stmt->fetchAll(PDO::FETCH_ASSOC);
} catch (Exception $e) {
}
return $mac_db;
}
function pull_xml_file($file): DOMDocument {
$xmlString = file_get_contents($file);
if ($xmlString === false) {