Developing module and bash script

Hello, i am developing a module for FreePBX, i have made my module and upload it throught the module admin but i need to install a crontab in my system and make a folder in var directory that a bash script will reside there and make all the actual work.

I want during the installation to install the crontab, make the folder and echo there the script or copy it and the removing it from the module folder. Is something like that possible?

Put your bash script in mymodule/bin/… then it will get Symlinked to /usr/local/bin I believe.

Freepbx has it’s own cron processer you can use to set a cron job. I’m not in front of a system right now so I can’t point you at where to look but probably grep through framework

Yep got it after a while. Pretty sweet function. Well i actually i need two more things.

My module needs incrond package to work properly, can i check during installation if this package is installed and if not exit the installation? I can set dependencies on the module.xml file but can it be a system package?

Also i need to execute a command, well basically set the incrotab, i saw that some modules use the exec function but it seems that i can do specific stuff, can i add incrotab to this list?

You can only do things the “asterisk” (or whatever Apache is running as) user has permissions to do.

Files put in mymodule/bin would be symlinked to $amp_conf[‘ASTVARLIBDIR’]/bin, which in most cases is /var/lib/asterisk/bin.

Also, another good resource for FreePBX development is our Developer Corner located on the wiki.

1 Like

Ok thank you guys you have been very helpful i will check the wiki.