Home automation and FreePBX
Post ReplyHome automation and FreePBXPosted: Wednesday, April 24, 2019 [09:43:38] - 1
Since FreePBX (Incredible PBX in our case) allows to run a shell script from either extension or Custom Destination. Just add to /etc/asterisk/extensions_custom.conf exten => s,1,System(/home/asterisk/scripts/custom_script.sh) exten => s,n,Wait(1) exten => s,n,Congestion then add a Custom Destination in Admin -> Custom Destinations Description: CustomScript Save and Apply Config Make sure your /home/asterisk/scripts/custom_script.sh is executable and belongs to "asterisk" user and group chmod 755 /home/asterisk/scripts/custom_script.sh To test your script - login to your FreePBX box and: then run your script: If you have no permission errors and script performs as expected - add appropriate keys to be entered in new or existing IVR and test your script by calling your PBX. If there were errors, check asterisk log file: /var/log/asterisk/full In our case script just reports to the server VIA SSH and creates a trigger file on a server using passwordless login (authenticated by the key). PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin USER="user_to_log" SERVER="192.168.x.xx" ssh $USER@$SERVER touch /folder/trigger_file Script runs really fast and then procedure handled by server daemon when it finds a trigger file. This script works with our Remote Lights switch project: www.codemacs.com/raspberr.. |