#!/bin/bash
########################################################################
#
#
# filename:	playWxRpt
#
# description:	This script will play the weather report audio files
#		that get created by the getWxRpt script.
#
# history:
# 20030818	kc6hur	Origial release
#
# Modified by W0ANM
# $Id: playWxRpt 18 2008-04-02 21:17:04Z kovacs $
########################################################################
CUSTOM="/scripts/wx"
# Load config file

if [ -f ${CUSTOM}/wx_scripts.conf ] ; then
    source ${CUSTOM}/wx_scripts.conf
else
    echo "Missing ${CUSTOM}/wx_scripts.conf file, aborting..."
    exit 1
fi

# if ICAO_STN not an argument, then use what is defined in configure file.
if [ "$1" = "" ] ; then
    ICAO_LIST=$ICAO_STN
else
    ICAO_LIST=$1
fi

if [ $ACTIVE_PLAY = "FALSE" ] ; then
    if [ -f ${LOCAL}/active ] ; then
       echo "${0##*/}: ERROR - Node is busy, must be idle to run."
       exit 1
    fi
fi

if [ $ACTIVE_PLAY = "FALSE" ] ; then
    touch ${LOCAL}/active
fi

sudo /usr/sbin/asterisk -rx "rpt localplay 2090 /audio/wx/report/$ICAO_LIST" 

if [ $ACTIVE_PLAY = "FALSE" ] ; then
    rm ${LOCAL}/active
fi

exit 0
