PABX da Simples IP
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

60 lines
900 B

#!/bin/bash
cria_callback()
{
ORIGEM=$1
CONTEXTO=$2
DESTINO=$3
RAMALDESTINO=$4
CALLERIDNAME=$5
PRIORIDADE=1
if [ "$CONTEXTO" = "ext-voicemail" ]; then
PRIORIDADE=$(echo $DESTINO | cut -d '|' -f2)
#1 = ocupado
#4 = ausente
#7 = silencio
case $PRIORIDADE in
ocupado)
PRIORIDADE=1
;;
ausente)
PRIORIDADE=4
;;
silencio)
PRIORIDADE=7
;;
esac
DESTINO=$(echo $DESTINO | cut -d '|' -f1)
fi
CALLFILE=$(cat <<-EOF1
Channel: Local/$ORIGEM@saida-pstn/n
MaxRetries: 20
RetryTime: 15
WaitTime: 45
Context: $CONTEXTO
Extension: $DESTINO
Priority: $PRIORIDADE
Callerid: "$CALLERIDNAME" <$ORIGEM>
Set: RAMAL=$RAMALDESTINO
Set: CALLBACK=SIM
EOF1
)
FILE_NAME=$(date +%F-%H-%M-%S)-$DESTINO.call
echo "$CALLFILE" >> $FILE_NAME
chown pbx:pbx $FILE_NAME
chmod --recursive u=rwX,g=rX,o= $FILE_NAME
mv $FILE_NAME /var/spool/asterisk/outgoing
}
sleep 10
cria_callback "$1" "$2" "$3" "$4" "$5"
exit