#!/bin/bash # # Intercom - Script to control access to Asterisk Intercom, by K0KN 8/2015 # # Ext numbers in list below will be allowed to use intercom # # Extension numbers in text file should be one per line, no whitespaces or blank lines # Filename example, intercom.900 would be used to control access to intercom on ext 900 # # Asterisk extension.conf sample dialplan: #exten=> *75900,1,System(rm -f /dev/shm/intercom.${EXTEN:3}) #exten=> *75900,n,System(/home/kyle/intercom ${EXTEN:3} ${CALLERID(num)}) #exten=> *75900,n,Set(intercomok=${STAT(e,/dev/shm/intercom.${EXTEN:3})}) #exten=> *75900,n,NoOp(${intercomok}) #exten=> *75900,n,GotoIf($["${intercomok}" = "1"]?dialit:denied) #exten=> *75900,n(dialit),System(/home/kyle/logit Intercom ${CALLERID(num)} ${EXTEN:3} ) #exten=> *75900,n(dialit),SIPAddHeader(Alert-Info: info=alert-autoanswer) #exten=> *75900,n(dialit),Dial(SIP/${EXTEN}) #exten=> *75900,n(denied),System(/home/kyle/logit Intercom-ATTEMPT-FAILED ${CALLERID(num)} ${EXTEN:3} ) #exten=> *75900,n(denied),Playback(feature-not-avail-line) #exten=> *75900,n,Hangup INTERCOMLIST=/home/kyle/intercom.$1 INTERCOM=/dev/shm/intercom.$1 if [ "$1" == "" -o "$2" == "" ] ; then echo "Usage = intercom [called#] [calling#]" ; exit fi if [ -e "$INTERCOM" ] ; then rm -f "$INTERCOM" fi INTERCOMRESULTS=$(grep -i $2 $INTERCOMLIST) echo "Allowed: $INTERCOMRESULTS" if [ -n "$INTERCOMRESULTS" ] ; then touch "$INTERCOM" fi exit 0