A question regarding 'Apply configuration changes' bar

According to my understanding, when we update information in the GUI and click ‘Submit’, it updates certain tables in its database named ‘asterisk’. Then we press ‘Apply configuration changes’ bar on top which re-writes necessary config files in /etc/asterisk directory and adds/modifies information in /var/lib/asterisk/astdb database followed by reloading of asterisk.

My question is when we press ‘Apply configuration changes’, is there only one standard script which runs each time, or for each section of the GUI there is a different script? A brief description of how things work after pressing this bar would be highly appreciated.

It executes /var/lib/asterisk/bin/retrieve_conf which, in turn, recursively calls things out of each module’s functions.inc.php file. For the simplest module demonstration of the ability to write out specific config files, you should look at the pinsets module. It’s what helped get me up to speed.

is there any command to do same from cli
or
i want script to implement “apply configuration changes” from another html page

/var/lib/asterisk/bin/module_admin reload

or whatever the path is on your system.

or

amportal a r

which is shorter.

lgaeta

Running just /var/lib/asterisk/bin/module_admin reload is not correct. That only reloads it does not re-write configs based on what is in the DB.

The correct script is amportal a r and that runs a retrieve_conf and a reload.

I am sure you are correct, that the proper way to do this is with ‘amportal a r’, but I just ran a test and confirmed that at least some .conf are rewritten when the ‘/var/lib/asterisk/bin/module_admin reload’ command is issued.

hello im new in this area, so i will try to explain in the best way what im trying to do…
i would like to restart de module of amportal from a php invoked from an agi,i tried
exec("/usr/sbin/asterisk -rx ‘config reload’");
so it work for reload that module in asterisk, but for the amportal doesnt work, can anyone help me in this one?.
The question then is how i can restart the amportal from a script in phpagi? can i use the “amportal a r”? in the phpagi? i just wanna reload the module not bring down all the system
i tried this:
exec("/usr/sbin/amportal -rx ‘amportal a r’", $result1);
but this returned me" Sorry, you must be root to run this script."
So if you guys can help me out, i will be greatful =D
jeje sorry for my bad english in any part of the text

The user that runs amportal must be root. There is no way around this. You can add whatever user is running this script to the sudo groups. But thats a high security risk.

One possible work around might be to write to an intermediary logfile perhaps that the user has access to, and then have incron setup to run amportal a r with elevated permissions on a file change of that file.

how can i do that? i’m trying to do a phone lock, when the user wants to go out and keep the phone useless and unlock and make it work again when he/she come back, but the only way that i figured it out was reloading those modules, the amportal (to simulated the button orange in the freepbx web)and the asterisk config (to change the permission of the users in the custom contex).
I tried those commands in the console and this works because like you said tm1000 ‘i’m the root’ …
Any ideas to make work the phone lock in another way?, i hope you guys can help with this :slight_smile:

you really just need to make sure inncron is installed on your system and then run and read

man incrond
man incron.conf
man incron.tab

to understand, it is like cron but works on files that change.

add a line to /etc/incron.d/yourfile.conf which will have the file you have unprivileged write access to, the change to the file you want to monitor and then the script/program you want to run.

The action matching item two on item one will trigger item three.

(Stupid forum site with no edit)

If you missed it in the man pages, /etc/incron.allow will need to have an entry for you un-privileged user.

If all you want to do is lock the phone you could write a short Asterisk script to do that with a feature code and a pin.

All this reloading FreePBX is an extremely convoluted. Just put the phone in a custom context that checks the status of the lock variable before passing the call to an outbound round. Create the lock variable in the astdb. All the feature code does is validate the PIN and set the variable.

Do you have programming skills?

i dont think i have that installed : ( …
i do have programming skill in C++, Data base and little PHP, but can you explaining me a little more please…an example could you give me

i was trying to do the PIN Set in the freePBX but if i have several extensions and several contexts, lets say:
T1 -> for internal calling
T2 -> for outside calls
Ext -> 55789
Ext -> 77678
when i dial some number, the system ask me the PIN but the phone isnt blocked, just ask me for the password, and let out the call even if the PIN is correct.

I would like a change of context because in that way if some one else pick up the phone, no number that can be dialed until the owner unlock the phone

is this possible?