Run bash command during reload config


(Joe Toon) #1

Is it possible to have a bash script run when the fwconsole reload or “apply config” button is pressed?

I currently have a daily cron job that pulls user data out of the database for a phone directory and while this works, if I could have it hooked to a config reload it would be preferred.

I saw some threads about doing a custom module (which would then be called during a config reload) but that seems like a lot of overhead for what amounts to a simple mysql CSV export.


(TheJames) #2

A custom module doesn’t have to be overly involved

Example:


#3

You could also just monitor files in /etc/asterisk for changes (such as extensions_additional.conf) and use that to trigger your job.
Or use a log monitoring tool like SEC to monitor the asterisk log for a reload and trigger the job.


(Joe Toon) #4

Thanks for the ideas. I’ll give them a shot!


#5

Try adding an incron job incrontab -e

/etc/asterisk/voicemail.conf IN_CLOSE_WRITE /your/script/name.sh

#6

There are PRE and POST reload script hooks in advanced settings.

Update to the edge framework first.


#7

I had been doing similar, because the post-reload script broke somewhere along the way and I was too lazy to file a bug report.

This post prompted me to post a report(and planned to post a PR), only to find out it was fixed in the newest edge version of Framework 15.0.17.27.

Timing is everything.