#!/bin/bash

# Which asterisk version am I running?
ASTVER=$(/usr/bin/dpkg -S /usr/sbin/asterisk 2>/dev/null| cut -d- -f1)

if [ ! "$ASTVER" ]; then
	echo "Unable to determine asterisk version."
	exit 9
fi

# If the g729 deb package isn't installed, tell them how to install it
dpkg-query -l ${ASTVER}-g729 > /dev/null 2>&1
RPM=$?

if [ $RPM -eq 0 ]; then
	echo "Open Source G729 codec is installed."
	exit 0
else
	echo "The Open Source G729 codec is not installed."
	echo "You can install it with the following command:"
	echo -e "\t sudo apt-get install -y ${ASTVER}-g729"
	exit 1
fi




