Auto-execute dialplan extension on reload

Hi all,

For my hotdesking solution, using “standard” hints and device state is a bit tricky.

I think about using custom device state.

However to initialize properly those custom device state, I would need to execute a specific extension in my dialplan when asterisk reload or when the dialplan reload.

Is there a clean way to do that?

Thanks in advance !

Regards

How about a #exec in your extensions.conf that executes a script that creates a call file?

Hi Sedwards,

Thanks for your feedback. If I understand correcly #exec allows to call a script that will generate a portion of the extensions.conf. It’s an interesting feature but I don’t think it will fit my need.

Here is what I have put in place until now :

  1. Defined context [startup] in extensions.conf with :
[startup]
exten => 1,1,NoOp(startup)
same => n,Set(DEVICE_STATE(Custom:201)=BUSY)
same => n,Set(DEVICE_STATE(Custom:202)=INUSE)
same => n,Hangup()
  1. in cli.conf, add line : console dial 1@startup = yes

At least it works for asterisk restart.

For dialplan reload, I still need to think about it :wink:

"At least it works for asterisk restart.

For dialplan reload, I still need to think about it ;-)"

I would ask: “when does a dialplan reload occur?”

If it’s a manual process, or something scripted as part of a cron job etc,
then why not just append a command to place a call to your startup context
after the reload?

Are there any circumstances under which a dialplan reload occurs
“spontaneously” in the background, and a dial command couldn’t easily be added
to it?

Antony.

I think they are suggesting running it for side effects, only. However, its seems to me that it is run before the dialplan is fully loaded, so the call file will fail, if it runs too soon, and you could probably get the same effect by doing it from the system startup script for Asteirk.

Just an idea, but you can open your own programmatic connection to the Asterisk console socket. You might be able to use this to recognize the message displayed when a reload command is executed. Alternatively, you can send your own reload command, followed by submission of an Originate request or whatever else you want to do.

I think you’re perfectly right. Covering asterisk reload is probably enough…

I think you’re perfectly right. Covering asterisk reload is probably enough…

I think using this #exec directive to build dynamically the list of hints based on the table of extensions stored in MySQL.

Hi Ido,

Could be indeed a solution but I think that it could be a bit “overkill” (specially based on comment from Pooh). Thanks anyway for your answer !

Yes, ‘I*’ am. Now that you mention it, a test for if it is ‘startup’ or ‘reload’ is a good thing to incorporate in the script.

*) I am not a ‘they.’

I use “they” rather than “he/she”. See definition (2) in https://www.collinsdictionary.com/dictionary/english/they (also for the Google dictionary, but that might be locale sensitive).

I sadly have nothing to add, but I though I should say thanks for showing me how to do something I’ve wanted to do for many years. How to run a dialplan context at startup. When I forget to do it manually, I break the system and it annoys my wife, so thank you so much.

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