#!/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 $
########################################################################

# 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 Weather Underground _STN not an argument, then use what is defined in configure file.
if [ "$1" = "" ] ; then
    WX_UNDERGRND_STN=${WX_UNDERGRND_STN}
else
    WX_UNDERGRND_STN=$1
fi

UG_WX_DIR=custom/wx/report_ug/${WX_UNDERGRND_STN}

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

if [ -f ${CUSTOM}/custom_wavplay ] ; then
    ${CUSTOM}/custom_wavplay $UG_WX_DIR/current_wx  &> /dev/null 2>&1
else
    /usr/sbin/asterisk -rx "rpt localplay 27539 $UG_WX_DIR/current_wx"  &> /dev/null 2>&1
fi

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


