Delete Inbound Route from Command Line

Hi, I’m looking for a Bash code that allow delete some ‘Inbound Route’ from command line. I found this php code of ‘lgaetz’ that do the same, but for extensions. There is something similar but for ‘inbound routes’?

Thanks.

#!/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";
}

you can manage the trunks by: https://wiki.freepbx.org/pages/viewpage.action?pageId=37912685#fwconsolecommands(13+)-Trunks
but not delete the route.

Thanks James, but I need delete the ‘inbound route’ (DID) …

Thank you very much Lorne. That’s just what I need.

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.