#!/bin/bash cd "$(dirname "$0")" line="$1" . config.txt ./ann_end.sh "$line" # and any existing calls to prevent our call ending up in "call waiting" state (and thus not autoanswered) sleep 0.5 ./autoanswer_line.sh "$line" 1 || { echo >&2 "failed to enable autoanswer, exiting."; exit 1; } fn=/var/spool/asterisk/tmp/ann_$line.call echo " Channel: PJSIP/emerg$line Context: emerg_listen Extension: 120 Priority: 1 " >$fn mv "$fn" /var/spool/asterisk/outgoing/ ./ann_volup.sh "$line" &