Skip to content

Instantly share code, notes, and snippets.

@stevenmirabito
Created April 21, 2016 00:18
Show Gist options
  • Save stevenmirabito/a2d3fc0b4ea830c8e76e6a5b1d976222 to your computer and use it in GitHub Desktop.
Save stevenmirabito/a2d3fc0b4ea830c8e76e6a5b1d976222 to your computer and use it in GitHub Desktop.
#!/bin/bash
# Asterisk System Recording Tester
# Author: Steven Mirabito (smirabito@csh.rit.edu)
# Usage
usage () {
echo "Calls the desired extension and plays an Asterisk system recording."
echo "Usage: record-test -e <extension> -r <recording> [-e language]"
exit
}
# Process arguments
while [[ $# > 1 ]]; do
key="$1"
case $key in
-e|--extension)
EXTENSION="$2"
shift # past argument
;;
-l|--language)
RECORD_LANG="$2"
shift # past argument
;;
-r|--recording)
RECORDING="$2"
shift # past argument
;;
*)
# unknown option
;;
esac
shift # past argument or value
done
if [ -z ${EXTENSION+x} ]; then
usage
fi
if [ -z ${RECORD_LANG+x} ]; then
RECORD_LANG="en"
fi
if [ -z ${RECORDING+x} ]; then
usage
fi
# Place the call
echo -e "🛠 \e[1m\e[96mConfiguring call with recording \"${RECORD_LANG}/${RECORDING}\"..."
echo "Channel: Local/${EXTENSION}@from-internal/n" > /var/spool/asterisk/tmp/recording-test.call
echo "Application: Playback" >> /var/spool/asterisk/tmp/recording-test.call
echo "Data: ${RECORD_LANG}/${RECORDING}" >> /var/spool/asterisk/tmp/recording-test.call
echo "📲 Placing call to extension ${EXTENSION}..."
mv /var/spool/asterisk/tmp/recording-test.call /var/spool/asterisk/outgoing/
echo -e "✅ Done!\e[0m"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment