Skip to content

Instantly share code, notes, and snippets.

@jfinstrom
Created January 19, 2022 00:39
Show Gist options
  • Save jfinstrom/6fd423e5258d837a4e893183f4b25c37 to your computer and use it in GitHub Desktop.
Save jfinstrom/6fd423e5258d837a4e893183f4b25c37 to your computer and use it in GitHub Desktop.
Update all sip passwords
#!/usr/bin/env php
<?php
/**
Copyright (C) 2022 James Finstrom <github@g3p0.xyz>
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <http://www.gnu.org/licenses/>.
**/
/**
* Use at own risk, will reset ALL sip and pjsip secrets.
* If you are using automated provisioning you will need to regenerate your files
**/
include '/etc/freepbx.conf';
$freepbx = FreePBX::Create();
$devices = $freepbx->Core->getAllDevicesByType();
foreach ($devices as $device) {
$current = $freepbx->Core->getDevice($device['id']);
if($current['tech'] !== 'sip' || $current['tech'] !== 'pjsip') {
continue;
}
$current['secret'] = $freepbx->Core->generateSecret();
$freepbx->Core->addDevice($current['tech'], $device['id'], $current, true);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment