TIPS How to use tonezone in dialplan

Rrrr

Tink
Joined
May 28, 2009
Messages
343
Reaction score
25
Hi,

I would like to set the tonezone for various international DIDs.
=> indications.conf is auto-generated and contains one country entry [uk] (selected in the GIU as United Kingdom)
=> There is no indications_custom.conf

When I use this command in the dialplan, it does not find the [nl] entry:

Code:
exten => _31XXXXX.,n,Set(CHANNEL(tonezone)=nl)                ; ring tone uk de nl us

Where should I place the [nl] entry?


[nl]
description = Netherlands
ringcadence = 1000,4000
dial = 425
busy = 425/500,0/500
ring = 425/1000,0/4000
congestion = 425/250,0/250
callwaiting = 425/500,0/9500
dialrecall = 425/500,0/50
record = 1400/500,0/15000
info = 950/330,1400/330,1800/330,0/1000
stutter = 425/500,0/50
 

billsimon

Well-Known Member
Joined
Jan 2, 2011
Messages
1,540
Reaction score
729
That file is generated by the setting in FreePBX - Settings - Advanced Settings - (Dialplan and Operational) Country Indication Tones. It only lets you choose one as the overall tone set for the PBX.

I think your only option here is to add your [nl] block to the indications.conf file and be aware that FreePBX may revert it.
 

Rrrr

Tink
Joined
May 28, 2009
Messages
343
Reaction score
25
I was afraid for that.
It works only until one single setting in Advanced Settings is changed and then forgets my tonezone customisation in indications.conf.
Anybody knows a solution?
 

Rrrr

Tink
Joined
May 28, 2009
Messages
343
Reaction score
25
For the time being I found a solution: I changed the file properties of indications.conf to 555.
I hope it won't get me into trouble :)
 

billsimon

Well-Known Member
Joined
Jan 2, 2011
Messages
1,540
Reaction score
729
That is as good a solution as any. There is no need for FreePBX to change that file once you have set your default zone.
 

Rrrr

Tink
Joined
May 28, 2009
Messages
343
Reaction score
25
Back into trouble again:
In the dial plan:
Code:
Set(CHANNEL(tonezone)=nl)

Error:
func_channel.c:530 func_channel_write_real: Unknown country code 'nl' for tonezone. Check indications.conf for available country codes.

This used to work on another, (but not comparable) server (asterisk 11).

Note: After changing indications.conf as per below I did just a dialplan reload.
If I reload fwconsole, then my changes in indications.conf are overwritten.


1. indications.conf:
Code:
[general]
country=uk

#include indications_custom.conf

[uk]
description = United Kingdom
ringcadence = 400,200,400,2000
dial = 350+440
specialdial = 350+440/750,440/750
busy = 400/375,0/375
congestion = 400/400,0/350,400/225,0/525
specialcongestion = 400/200,1004/300
unobtainable = 400
ring = 400+450/400,0/200,400+450/400,0/2000
callwaiting = 400/100,0/4000
specialcallwaiting = 400/250,0/250,400/250,0/250,400/250,0/5000
creditexpired = 400/125,0/125
confirm = 1400
switching = 400/200,0/400,400/2000,0/400
info = 950/330,0/15,1400/330,0/15,1800/330,0/1000
record = 1400/500,0/60000
stutter = 350+440/750,440/750

2. indications_custom.conf
Code:
[nl]
description = Netherlands
ringcadence = 1000,4000
dial = 425
busy = 425/500,0/500
ring = 425/1000,0/4000
congestion = 425/250,0/250
callwaiting = 425/500,0/9500
dialrecall = 425/500,0/50
record = 1400/500,0/15000
info = 950/330,1400/330,1800/330,0/1000
stutter = 425/500,0/50

[us]
description = United States / North America
ringcadence = 2000,4000
dial = 350+440
busy = 480+620/500,0/500
ring = 440+480/2000,0/4000
congestion = 480+620/250,0/250
callwaiting = 440/300,0/10000
dialrecall = !350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,350+440
record = 1400/500,0/15000
info = !950/330,!1400/330,!1800/330,0
stutter = !350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,!350+440/100,!0/100,350+440

Any smart tips?


Incredible PBX 13-13.3 for Centos 6(.9)
Asterisk 13.18.5 Incredible 13.0.120.10
 
Last edited:

dicko

Still learning but earning
Joined
Oct 30, 2015
Messages
1,633
Reaction score
842
User root can make a file ''immutable'" with

chattr +i filename

from then on NOTHING can change it until root does

chattr -i filename
 

Rrrr

Tink
Joined
May 28, 2009
Messages
343
Reaction score
25
Thanks, good idea. Once the tonezone works I can use your tip. But for now, I get the error, despite the additions in indications.conf and indications_custom.conf.

PS. By the way, I tried to reload fwconsole, but then root takes over and overwrites indications.conf, even after using the chattr command
 

dicko

Still learning but earning
Joined
Oct 30, 2015
Messages
1,633
Reaction score
842
That should not be, as root try both before and after fwconsole X :-

chattr +i /etc/asterisk/indications.conf

echo >> /etc/asterisk/indications.conf ; echo " returned $? , - md5sum $(md5sum /etc/asterisk/indications.conf)"
-bash: /etc/asterisk/indications.conf: Permission denied
returned 1 - md5sum .......something..............................

chattr -i /etc/asterisk/indications.conf

echo >> /etc/asterisk/indications.conf ; echo " returned $? , - md5sum $(md5sum /etc/asterisk/indications.conf)"
returned 0 - md5sum ..somethng else....
 

Rrrr

Tink
Joined
May 28, 2009
Messages
343
Reaction score
25
By using chattr +i, it looks like this:
root@vultr:~ $ chattr +i /etc/asterisk/indications.conf
WARNING: Always run Incredible PBX behind a secure hardware-based firewall.
root@vultr:~ $ echo >> /etc/asterisk/indications.conf ; echo " returned $? , - md5sum $(md5sum /etc/asterisk/indications.conf)"
-bash: /etc/asterisk/indications.conf: Permission denied
returned 1 , - md5sum 3a9a9dad7eaa5d1097195fb0f4fbd363 /etc/asterisk/indications.conf
WARNING: Always run Incredible PBX behind a secure hardware-based firewall.
root@vultr:~ $ fwconsole reload
Reloading FreePBX
Error(s) have occured, the following is the retrieve_conf output:
exit: 255
Unable to continue. fopen(/etc/asterisk/indications.conf): failed to open stream: Permission denied in /var/www/html/admin/modules/core/functions.inc.php on line 5701
#0 [internal function]: Whoops\Run->handleError(2, 'fopen(/etc/aste...', '/var/www/html/a...', 5701, Array)
#1 /var/www/html/admin/modules/core/functions.inc.php(5701): fopen('/etc/asterisk/i...', 'w')
#2 /var/www/html/admin/modules/core/functions.inc.php(2175): general_generate_indications()
#3 /var/www/html/admin/libraries/BMO/DialplanHooks.class.php(95): core_do_get_config('asterisk')
#4 /var/lib/asterisk/bin/retrieve_conf(864): FreePBX\DialplanHooks->processHooks('asterisk', Array)
#5 {main}
WARNING: Always run Incredible PBX behind a secure hardware-based firewall.

Still, I get the same error as I described above in message #6.
tonezone does not seem to work...
 

dicko

Still learning but earning
Joined
Oct 30, 2015
Messages
1,633
Reaction score
842
That's truly unfortunate, all I can think of is a cronjob or preferably an incron entry(ies) that restore any changed files to what worked previous to FreePBX "fixing" them for you

incrontab -l
/etc/asterisk/indications.conf IN_CLOSE_WRITE /usr/bin/cp /var/lib/asterisk/scripts/indications.conf /etc/asterisk


should work

( configs/indications.conf.sample in the source tree would be a good template to use)
 
Last edited:

Rrrr

Tink
Joined
May 28, 2009
Messages
343
Reaction score
25
We got side-tracked on my remark in message #6 (now crossed out).

@dicko
This is a new installation and I cannot get additional tonezones to work at all in either indications.conf or indications_custom.conf.

Error:
func_channel.c:530 func_channel_write_real: Unknown country code 'nl' for tonezone. Check indications.conf for available country codes.

Can anyone confirm additional tonezones is working ?

Thanks.

Incredible PBX 13-13.3 for Centos 6(.9)
Asterisk 13.18.5 Incredible 13.0.120.10
 

dicko

Still learning but earning
Joined
Oct 30, 2015
Messages
1,633
Reaction score
842
As I just posted

configs/indications.conf.sample is a good template, it has a [general] section in your case


[general]
country=nl

and any number of
[nl]
.
.
.

[us]
.
.
.


without a relevant entry you can't


Set(CHANNEL(tonezone)=[yourcountry]) ; i.e., uk, de, etc.

ref: -

http://www.asteriskdocs.org/en/3rd_Edition/asterisk-book-html-chunk/InitialConfig_id291715.html

the incrontab entry I posted will immediately replace whatever FreePBX has changed indications.conf to to your preferred content, this will happen so fast that by the time fwconsole 'reloads' it will actually be reloading the values you want

All the above I tested and verified working briefly today on both a debian and a RH based system
 

Rrrr

Tink
Joined
May 28, 2009
Messages
343
Reaction score
25
@dicko Thank you! Now I understand better your post #11.

Good news: tonezone is working now.
fwconsole restart after changing indications.conf made the difference.

Note however:
fwconsole reload is changing indications.conf to the original version and thereby removing my additions.

To ensure that after fwconsole reload my version of indications.conf will be restored, I followed your instructions:

1. I installed incron and set it up
Code:
yum install incron
chkconfig incrond on
service incrond start
incrontab -e

2. I created /var/lib/asterisk/scripts/indications.conf with the contents of the sample file at
./usr/src/asterisk-13.18.5/configs/samples/indications.conf.sample
3. I set properties of /var/lib/asterisk/scripts/indications.conf to asterisk/asterisk and 0644
4. Below the results of fwconsole reload

root@vultr:/ $ incrontab -l
/etc/asterisk/indications.conf IN_CLOSE_WRITE /usr/bin/cp /var/lib/asterisk/scripts/indications.conf /etc/asterisk

root@vultr:/ $ fwconsole reload
Reloading FreePBX
Successfully reloaded

root@vultr:/ $ ls -l /etc/asterisk/indi*
-rw-rw-r-- 1 asterisk asterisk 918 Mar 28 11:14 /etc/asterisk/indications.conf

root@vultr:/ $ ls -l /var/lib/asterisk/scripts/indications.conf
-rw-r--r-- 1 asterisk asterisk 25367 Mar 28 10:45 /var/lib/asterisk/scripts/indications.conf

How can I get incrontab to work?
Did I do something wrong?
 

wardmundy

Nerd Uno
Joined
Oct 12, 2007
Messages
19,201
Reaction score
5,221
@Rrrr: Just curious what the platform is where this was happening? If I understand correctly, FreePBX on this platform was using root permissions to make changes to your server. Is that correct?? If so, that is a very disappointing development from a security standpoint.
 

Rrrr

Tink
Joined
May 28, 2009
Messages
343
Reaction score
25
@Rrrr: Just curious what the platform is where this was happening? If I understand correctly, FreePBX on this platform was using root permissions to make changes to your server. Is that correct?? If so, that is a very disappointing development from a security standpoint.

I am on:
Incredible PBX 13-13.3 for Centos 6(.9)
Asterisk 13.18.5 Incredible 13.0.120.10

What test do I need to do to prove your understanding?
1. I have changed the ownership of /etc/asterisk/indications.conf so often, I am not sure what it was originally. Currently, it's asterisk/asterisk 0664.
2. When I made indications.conf immutable, fwconsole reload did not run properly (see post #10)
 

dicko

Still learning but earning
Joined
Oct 30, 2015
Messages
1,633
Reaction score
842
@Rrrr: Just curious what the platform is where this was happening? If I understand correctly, FreePBX on this platform was using root permissions to make changes to your server. Is that correct?? If so, that is a very disappointing development from a security standpoint.

The privilege escalation is also done by FreePBX using the system tables in incrond.d/* which can just run arbitrary code whenever unrelated file operations are performed, insecure, I believe so, thats why my first recipe used the 'user' format like cron, but there are hidden complications as incrond.allow (deny) files, their existence and content vary by os/version. So i suggested the fight fire with fire alternate truth' :)
 

Rrrr

Tink
Joined
May 28, 2009
Messages
343
Reaction score
25
Who said something about pioneering?

I am in trouble.
incrontab did not seem to work, so I created a script tonezone.cron to test with:
Code:
#!/bin/bash

# activate indications.conf with additional tonezones
/bin/cp /var/lib/asterisk/scripts/indications.conf /etc/asterisk
/var/lib/asterisk/bin/fwconsole restart

The idea was to put the script in cron.hourly...

When I tested it, I must have broken something.
I do not know how to repair this.

$ ./tonezone.cron
Running Incredible PBX shutdown...

Shutting down Asterisk Gracefully. Will forcefully kill after 30 seconds.
Press C to Cancel
Press N to shut down NOW
[============================] 2 secs
Asterisk already running
Running Incredible PBX startup...
Unable to connect to remote asterisk (does /var/run/asterisk/asterisk.ctl exist?)
Unable to run Pre-Asterisk hooks, because Asterisk is already running on PID 22582 and has been running for ERROR
^C
WARNING: Always run Incredible PBX behind a secure hardware-based firewall.
root@vultr:/etc/cron.hourly $ fwconsole reload
Exception: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2)::SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (2) in file /var/www/html/admin/libraries/utility.functions.php on line 204
Stack trace:
1. Exception->() /var/www/html/admin/libraries/utility.functions.php:204
2. die_freepbx() /var/www/html/admin/libraries/BMO/Database.class.php:136
3. PDOException->() /var/www/html/admin/libraries/BMO/Database.class.php:131
4. PDO->__construct() /var/www/html/admin/libraries/BMO/Database.class.php:131
5. FreePBX\Database->__construct() /var/www/html/admin/libraries/BMO/FreePBX.class.php:69
6. FreePBX->__construct() /var/www/html/admin/bootstrap.php:139
7. require_once() /etc/freepbx.conf:9
8. include_once() /var/lib/asterisk/bin/fwconsole:12
WARNING: Always run Incredible PBX behind a secure hardware-based firewall.

I rebooted, but still no luck.
Any suggestions?
$ fwconsole stop
Exception: SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111)::SQLSTATE[HY000] [2002] Can't connect to local MySQL server through socket '/var/lib/mysql/mysql.sock' (111) in file /var/www/html/admin/libraries/utility.functions.php on line 204
Stack trace:
1. Exception->() /var/www/html/admin/libraries/utility.functions.php:204
2. die_freepbx() /var/www/html/admin/libraries/BMO/Database.class.php:136
3. PDOException->() /var/www/html/admin/libraries/BMO/Database.class.php:131
4. PDO->__construct() /var/www/html/admin/libraries/BMO/Database.class.php:131
5. FreePBX\Database->__construct() /var/www/html/admin/libraries/BMO/FreePBX.class.php:69
6. FreePBX->__construct() /var/www/html/admin/bootstrap.php:139
7. require_once() /etc/freepbx.conf:9
8. include_once() /var/lib/asterisk/bin/fwconsole:12
WARNING: Always run Incredible PBX behind a secure hardware-based firewall.
 

dicko

Still learning but earning
Joined
Oct 30, 2015
Messages
1,633
Reaction score
842
Looks like you should go back to your known good backup Image
 

Members online

Forum statistics

Threads
25,812
Messages
167,763
Members
19,240
Latest member
nikko
Get 3CX - Absolutely Free!

Link up your team and customers Phone System Live Chat Video Conferencing

Hosted or Self-managed. Up to 10 users free forever. No credit card. Try risk free.

3CX
A 3CX Account with that email already exists. You will be redirected to the Customer Portal to sign in or reset your password if you've forgotten it.
Top