Last active
March 5, 2025 07:10
-
-
Save lgaetz/f2d3d717520f8adf2018643473d1f748 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env php | |
<?php | |
if (!isset($argv[1])){ | |
echo " | |
***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** | |
* | |
* Script: extension-del.php | |
* | |
* Latest version: https://gist.github.com/lgaetz/f2d3d717520f8adf2018643473d1f748 | |
* | |
* Usage: Run at bash prompt of FreePBX system running FreePBX 13+ with single argument | |
* of extension to be deleted. Follow with fwconsole reload for changes to be applied | |
* | |
* # extension-del.php 3002 | |
* | |
* License: GNU/GPL3+ | |
* | |
* History: | |
* 2017-09-24 First commit by lgaetz | |
* 2017-09-25 Update for virtual extensions | |
* 2017-09-26 General polish | |
***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** ***** | |
"; | |
exit; | |
} | |
include '/etc/freepbx.conf'; | |
$FreePBX = FreePBX::Create(); | |
$device=$FreePBX->Core->getDevice($argv[1]); | |
$user=$FreePBX->Core->getUser($argv[1]); | |
if($device["user"]){ | |
// normal extensions tested with sip, pjsip and dahdi | |
echo "Found device ".$argv[1].", deleting...\n"; | |
echo "Found user ".$device["user"].", deleting...\n"; | |
$foo=$FreePBX->Core->delDevice($argv[1]); | |
$foo=$FreePBX->Core->delUser($device["user"]); | |
} elseif ($user) { | |
// for extensions with users but no device i.e. virtual | |
echo "Found user ".$user['extension'].", deleting...\n"; | |
$foo=$FreePBX->Core->delUser($argv[1]); | |
} else { | |
echo "Neither user nor device ".$argv[1]." exists, exiting...\n"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Is there one only
with pearlescent buttonsto add an extension (range of extensions)?