#!/bin/sh

MODULES="codec_opus_open_source format_ogg_opus_open_source format_vp8"

setup() {
        service asterisk start
        sleep 1
        asterisk -rx 'core waitfullybooted'
}


run() {
	for MODULE in $MODULES; do
		# Check whether module is loaded ("Running")
		echo -n "$MODULE loaded and running: "
		asterisk -rx "module show like $MODULE" | grep -q Running
		if [ $? -eq 0 ]; then
			echo "PASS"
		else
			echo "FAIL"
			exit 1
		fi
	done
}

teardown() {
        asterisk -rx 'core stop now'
}

setup
run
teardown

