Disable a trunk once it's idle

Is there a command that allows you to set a trunk as disabled but wait until it is idle?

From bash, something like:-

while [ $(rasterisk -x 'core show channels verbose '|grep yourtrunkname|wc -l) -gt 0 ];do sleep 1 ;done;mysql asterisk -e " update trunks set disabled = 'on' where name = 'yourtrunkname' " ;fwconsole r

Thanks dicko. I also discovered the graceful shutdown of asterisk which will accomplish what Iā€™m trying to do in this particular scenario.

However, I will try this script when I have a chance since I will potentially need to disable an individual trunk.

Why do you need to script something that can be done via the GUI with a couple clicks?

There is native support for this with fwconsole:

[root@lorne14-pro ~]# fwconsole trunks
Choose an ID to enable/disable
+----+--------+-----------------------------+----------+
| ID | TECH   | Channel ID                  | Disabled |
+----+--------+-----------------------------+----------+
| 1  | pjsip  | fpbx-1-redacted             | off      |
| 2  | pjsip  | fpbx-2-redacted             | off      |
| 3  | custom | local/$OUTNUM$@custom-trunk | off      |
| 4  | custom | local/s@trunk-notification  | off      |
+----+--------+-----------------------------+----------+

[root@lorne14-pro ~]# fwconsole trunks --disable 1
Disabling Trunk 1

[root@lorne14-pro ~]# fwconsole trunks
Choose an ID to enable/disable
+----+--------+-----------------------------+----------+
| ID | TECH   | Channel ID                  | Disabled |
+----+--------+-----------------------------+----------+
| 1  | pjsip  | fpbx-1-redacted             | on       |
| 2  | pjsip  | fpbx-2-redacted             | off      |
| 3  | custom | local/$OUTNUM$@custom-trunk | off      |
| 4  | custom | local/s@trunk-notification  | off      |
+----+--------+-----------------------------+----------+

[root@lorne14-pro ~]# fwconsole trunks --enable 1
Enabling Trunk 1

https://wiki.freepbx.org/pages/viewpage.action?pageId=37912685#fwconsolecommands(13+)-Trunks

1 Like

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