How Too Peripherals Python Tutorials

Home automation and FreePBX

Post Reply
raspberrypi / howtoo     Views: 675Prev .. Next
Home automation and FreePBXPosted: Wednesday, April 24, 2019 [09:43:38] - 1
rootPosted by:rootMember Since:
June 16 2010
Posts: 357
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
View Code[custom-script]
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
View CodeTarget: custom-script,s,1
Description: CustomScript

Save and Apply Config

Make sure your /home/asterisk/scripts/custom_script.sh is executable and belongs to "asterisk" user and group
View Codechown asterisk:asterisk /home/asterisk/scripts/custom_script.sh
chmod 755 /home/asterisk/scripts/custom_script.sh


To test your script - login to your FreePBX box and:
View Codesu asterisk

then run your script:
View Code/home/asterisk/scripts/custom_script.sh
or from the same folder
./custom_script.sh


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
View Codetail -n 50 /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).
View Code#!/bin/sh
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..There's no place like ~
raspberrypi / howtooPrev .. Next
 
Post Reply
Home - Raspberrypi: How Too Peripherals Python Tutorials
Our Telegram Group