fixed syntax
This commit is contained in:
@@ -125,14 +125,43 @@ echo "Wrote $out_file with " . $root->childNodes->length . " contacts\n";
|
||||
|
||||
/** Optional: push check-sync to re-download directory without reboot */
|
||||
if ($do_notify) {
|
||||
asterisk_bin=/usr/sbin/asterisk
|
||||
endpoints=$($asterisk_bin -rx "pjsip show endpoints" \
|
||||
| sed -n 's/^[[:space:]]*Endpoint:[[:space:]]\+\([^[:space:]/]\+\).*/\1/p' \
|
||||
| grep -vE '^(anonymous|system)$' \
|
||||
| sort -u)
|
||||
$asteriskBin = '/usr/sbin/asterisk';
|
||||
|
||||
for ep in $endpoints; do
|
||||
echo "Sending check-sync to $ep"
|
||||
$asterisk_bin -rx "pjsip send notify polycom-check-cfg endpoint $ep"
|
||||
done
|
||||
$excludedEndpoints = [
|
||||
'101', '102', '103', '104', '105', '106', '107', '108', '109', '110', '111', '112', '113', '114', '900', 'Voyant', '<Endpoint dpma_endpoint'
|
||||
];
|
||||
|
||||
// Get all endpoints from Asterisk CLI
|
||||
$cmd = escapeshellcmd($asteriskBin) . ' -rx "pjsip show endpoints"';
|
||||
exec($cmd, $output, $returnCode);
|
||||
|
||||
if ($returnCode !== 0) {
|
||||
die("Failed to connect to Asterisk CLI.\n");
|
||||
}
|
||||
|
||||
// Parse endpoint names (mirror sed: capture until space or slash)
|
||||
$endpoints = [];
|
||||
foreach ($output as $line) {
|
||||
if (preg_match('/^\s*Endpoint:\s+([^\/\s]+)/', $line, $matches)) {
|
||||
$ep = trim($matches[1]);
|
||||
if (!in_array($ep, ['anonymous', 'system']) && !in_array($ep, $excludedEndpoints)) {
|
||||
$endpoints[] = $ep;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
$endpoints = array_unique($endpoints);
|
||||
|
||||
// Send check-sync NOTIFY to each endpoint
|
||||
foreach ($endpoints as $ep) {
|
||||
echo "Sending check-sync to $ep\n";
|
||||
$notifyCmd = sprintf(
|
||||
'%s -rx "pjsip send notify polycom-check-cfg endpoint %s"',
|
||||
escapeshellarg($asteriskBin),
|
||||
escapeshellarg($ep)
|
||||
);
|
||||
exec($notifyCmd);
|
||||
}
|
||||
|
||||
echo "Done.\n";
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user