Editing trunk configuration via CLI

Hello all,

I have multiple FreePBX 16.0.17 instances running, all of which have trunks to our phone provider. We are losing service with this provider and as such, they have requested that all of our trunks be shut down.

Given the scale of our deployment (~80 instances across different physical locations) i am looking to create a script that can remove a specific trunk from the freePBX configuration that can just be run via CLI so we don’t need to worry about logging into every single instance and removing it via the gui.

Is there a way to do this?

Not baked in. The way I do it is running remote commands through ssh and making changes to the correct tables in the database.

Could you elaborate on this? where is the location of the information in the database and/or filesystem? i was able to find /etc/asterisk/pjsip.registration.conf which contains the trunk, but i tested editing this file on a test environment and was served an error page after logging back into the gui

I guess i should also tack onto this that i am very unfamiliar with the back-end of FreePBX, so any extra information would be greatly appreciated.

The ‘backend’ of FreePBX is that it mostly defines it’s state in mysql tables in the ‘asterisk’ database, these are re-written to /etc/asterisk/*.conf files by the php code in FreePBX and asterisk is then
‘reloaded’ to effect these, there are lots of ‘relationships’ between trunks and routes, both inbound and outbound, that need ‘normalization’ were you to venture down that path.

There’s an fwconole commnd to enabe/disabe trunks

# fwconsole trunk  --list
+----+-------+----------------------------------------+----------+
| ID | TECH  | Channel ID                             | Disabled |
+----+-------+----------------------------------------+----------+
| 5  | pjsip | voipInn-1-db8VlbED6EYMPyBr9Vsb         | off      |
| 6  | pjsip | voipInn-2-db8VlbED6EYMPyBr9Vsb         | on       |
| 7  | pjsip | voipInn-3-db8VlbED6EYMPyBr9Vsb-Inbound |          |
| 8  | pjsip | voipInn-4-db8VlbED6EYMPyBr9Vsb-Inbound |          |
| 9  | pjsip | voipInn-5-db8VlbED6EYMPyBr9Vsb-Inbound |          |
| 10 | pjsip | voipInn-6-db8VlbED6EYMPyBr9Vsb-Inbound |          |
+----+-------+----------------------------------------+----------+
# fwconsole trunk  --enable 5
Enabling Trunk 5 Run fwconsole reload

# fwconsole trunk  --help
______                   ______ ______ __   __
|  ___|                  | ___ \| ___ \\ \ / /
| |_    _ __   ___   ___ | |_/ /| |_/ / \ V /
|  _|  | '__| / _ \ / _ \|  __/ | ___ \ /   \
| |    | |   |  __/|  __/| |    | |_/ // /^\ \
\_|    |_|    \___| \___|\_|    \____/ \/   \/

Usage:
  trunks [options] [--] [<args>]...

Arguments:
  args

Options:
      --enable=ENABLE    Enable given trunk
      --disable=DISABLE  Disable given trunk
      --list             list trunks
      --xml              format list as json
      --json             format list as xml
  -h, --help             Display this help message
  -q, --quiet            Do not output any message
  -V, --version          Display this application version
      --ansi             Force ANSI output
      --no-ansi          Disable ANSI output
  -n, --no-interaction   Do not ask any interactive question
  -v|vv|vvv, --verbose   Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug

Help:
  Enable and disable trunks from the command line

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