mac list
This commit is contained in:
@@ -19,21 +19,21 @@ require_once('/etc/freepbx.conf');
|
|||||||
function main(): void {
|
function main(): void {
|
||||||
|
|
||||||
$provision_dir = '/tftpboot';
|
$provision_dir = '/tftpboot';
|
||||||
$file = $provision_dir . '/482567bcdeff-features.cfg';
|
|
||||||
$argv = $_SERVER['argv'] ?? [];
|
$argv = $_SERVER['argv'] ?? [];
|
||||||
$do_notify = in_array('--notify', $argv, true);
|
$do_notify = in_array('--notify', $argv, true);
|
||||||
|
$mac_list = ['482567bcdeff', '482567bcd8f0']
|
||||||
|
|
||||||
$pbdb = pull_db();
|
$pbdb = pull_db();
|
||||||
|
|
||||||
$pbdb = trim_db($pbdb);
|
$pbdb = trim_db($pbdb);
|
||||||
|
|
||||||
$xml = pull_xml_file($file);
|
foreach ($mac_list as $mac) {
|
||||||
|
$file = $provision_dir . '/' . $mac . '-features.cfg';
|
||||||
|
|
||||||
$attendant = remove_attendants($xml);
|
$xml = pull_xml_file($file);
|
||||||
|
$attendant = remove_attendants($xml);
|
||||||
write_attendants($attendant, $pbdb);
|
write_attendants($attendant, $pbdb);
|
||||||
|
write_to_file($provision_dir, $file, $xml);
|
||||||
write_to_file($provision_dir, $file, $xml);
|
}
|
||||||
|
|
||||||
if ($do_notify) {
|
if ($do_notify) {
|
||||||
notify($pbdb);
|
notify($pbdb);
|
||||||
@@ -118,6 +118,24 @@ function trim_db($pbdb): array {
|
|||||||
return $filtered;
|
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 {
|
function pull_xml_file($file): DOMDocument {
|
||||||
$xmlString = file_get_contents($file);
|
$xmlString = file_get_contents($file);
|
||||||
if ($xmlString === false) {
|
if ($xmlString === false) {
|
||||||
|
|||||||
Reference in New Issue
Block a user