How to use Variables and Global Variables using Asterisk Dialplan Context on Rocky Linux 9.4
To Use Variables And Global Variables Using Asterisk Dialplan Context On Rocky Linux 9.4
Introduction:
Asterisk offers the ability to create customized call flow patterns to effectively manage unexpected changes and improve the efficiency of your communication system. It allows for the utilization of global, shared, and channel-specific variables for command arguments. Additionally, Asterisk includes predefined variables to enhance functionality.
Procedure:
Step 1: Check the OS version by using the below command.
[root@Linuxhelp ~]# cat /etc/os-release
NAME="Rocky Linux"
VERSION="9.4 (Blue Onyx)"
ID="rocky"
ID_LIKE="rhel centos fedora"
VERSION_ID="9.4"
PLATFORM_ID="platform:el9"
PRETTY_NAME="Rocky Linux 9.4 (Blue Onyx)"
ANSI_COLOR="0;32"
LOGO="fedora-logo-icon"
CPE_NAME="cpe:/o:rocky:rocky:9::baseos"
HOME_URL="https://rockylinux.org/"
BUG_REPORT_URL="https://bugs.rockylinux.org/"
SUPPORT_END="2032-05-31"
ROCKY_SUPPORT_PRODUCT="Rocky-Linux-9"
ROCKY_SUPPORT_PRODUCT_VERSION="9.4"
REDHAT_SUPPORT_PRODUCT="Rocky Linux"
REDHAT_SUPPORT_PRODUCT_VERSION="9.4"
Step 2: Check the status of the Asterisk services by using the below command.
[root@Linuxhelp ~]# systemctl status asterisk
● asterisk.service - LSB: Asterisk PBX
Loaded: loaded (/etc/rc.d/init.d/asterisk; generated)
Active: active (running) since Sun 2024-06-23 23:24:59 IST; 2 weeks 0 days ago
Docs: man:systemd-sysv-generator(8)
Main PID: 1224
Tasks: 39 (limit: 48597)
Memory: 63.1M
CPU: 36.087s
CGroup: /system.slice/asterisk.service
├─1221 /bin/sh /usr/sbin/safe_asterisk
└─5288 /usr/sbin/asterisk -f -vvvg -c
Jun 23 23:24:59 Linuxhelp systemd[1]: Starting LSB: Asterisk PBX...
Jun 23 23:24:59 Linuxhelp asterisk[1140]: Starting asterisk:
Jun 23 23:24:59 Linuxhelp systemd[1]: asterisk.service: Can't open PID file /run/asterisk/asterisk.pid (yet>
Jun 23 23:24:59 Linuxhelp systemd[1]: asterisk.service: Supervising process 1224 which is not our child. We>
Jun 23 23:24:59 Linuxhelp systemd[1]: Started LSB: Asterisk PBX.
Jun 23 23:25:54 Linuxhelp systemd[1]: /run/systemd/generator.late/asterisk.service:30: PIDFile= references >
Jun 23 23:26:17 Linuxhelp systemd[1]: /run/systemd/generator.late/asterisk.service:30: PIDFile= references >
Jul 08 00:33:58 Linuxhelp systemd[1]: /run/systemd/generator.late/asterisk.service:30: PIDFile= references >
Step 3: Move to the Asterisk directory by using the below command.
[root@Linuxhelp ~]# cd /etc/asterisk/
Step 4: Show the endpoints in the pjsip.conf file by using the below command.
[root@Linuxhelp asterisk]# vim pjsip.conf
Step 5: Open extensions.conf file to edit the dialplan using variables by using the below command.
[root@Linuxhelp asterisk]# vim extensions.conf
Step 6: Login to the Asterisk CLI console by using the below command.
[root@Linuxhelp asterisk]# asterisk -rvvvvvvvvvvvvvvv
Asterisk 20.8.1, Copyright (C) 1999 - 2022, Sangoma Technologies Corporation and others.
Created by Mark Spencer <markster@digium.com>
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
Connected to Asterisk 20.8.1 currently running on Linuxhelp (pid = 5288)
Step 7: Reload the dialplan by using the below command.
Linuxhelp*CLI> dialplan reload
Dialplan reloaded.
[Jul 8 00:57:58] WARNING[6903]: pbx_config.c:1955 pbx_load_config: ==!!== Unknown directive: ringtime at line 3 of extensions.conf -- IGNORING!!!
> Time to scan old dialplan and merge leftovers back into the new: 0.000002 sec
> Time to restore hints and swap in new dialplan: 0.000003 sec
> Time to delete the old dialplan: 0.000002 sec
> Total time merge_contexts_delete: 0.000007 sec
> pbx_config successfully loaded 1 contexts (enable debug for details).
Step 8: Exit from the Asterisk CLI by using the below command.
Linuxhelp*CLI> exit
Asterisk cleanly ending (0).
Executing last minute cleanups
Step 9: Again, open the extension.conf to use channel variable by using the below command.
[root@Linuxhelp asterisk]# vim extensions.conf
[internal]
ringtime=20
exten => 167,1,Set(ring=30)
exten => 167,2,Dial(PJSIP/167,${ring})
exten => 167,3,playback()
exten => 167,4,Hangup()
exten => 168,1,Dial(PJSIP/168,${ringtime})
Step 10: Login to the Asterisk CLI Console and reload the dialplan by using the below command.
[root@Linuxhelp asterisk]# asterisk -rvvvvvvvvvvv
Asterisk 20.8.1, Copyright (C) 1999 - 2022, Sangoma Technologies Corporation and others.
Created by Mark Spencer <markster@digium.com>
Asterisk comes with ABSOLUTELY NO WARRANTY; type 'core show warranty' for details.
This is free software, with components licensed under the GNU General Public
License version 2 and other licenses; you are welcome to redistribute it under
certain conditions. Type 'core show license' for details.
=========================================================================
Connected to Asterisk 20.8.1 currently running on Linuxhelp (pid = 5288)
Linuxhelp*CLI> dialplan reload
Dialplan reloaded.
[Jul 8 01:01:22] WARNING[6969]: pbx_config.c:1955 pbx_load_config: ==!!== Unknown directive: ringtime at line 3 of extensions.conf -- IGNORING!!!
> Time to scan old dialplan and merge leftovers back into the new: 0.000003 sec
> Time to restore hints and swap in new dialplan: 0.000003 sec
> Time to delete the old dialplan: 0.000002 sec
> Total time merge_contexts_delete: 0.000008 sec
> pbx_config successfully loaded 1 contexts (enable debug for details).
Conclusion:
We have reached the end of this article. In this guide, we have walked you through the steps how to use Variables and Global Variables using Asterisk Dialplan Context on Rocky Linux 9.4. Your feedback is much welcome.
Comments ( 0 )
No comments available