#!/bin/sh
#
# pressure trending, called by cron, every 6 hours.
#
# "saved_pressure.var" is created by getWxRpt_ug

# 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

# report/working dirs
UG_WX_WRKING_DIR=${CUSTOM}/WxRpt_ug/${WX_UNDERGRND_STN}

if [ ! -d $UG_WX_WRKING_DIR ] ; then
    echo "Directory $UG_WX_WRKING_DIR not found!"
    echo
    exit
fi

if [ ! -f $UG_WX_WRKING_DIR/trend_pressure.var ] ; then
    cp $UG_WX_WRKING_DIR/saved_pressure.var $UG_WX_WRKING_DIR/trend_pressure.var
    exit 0
else
    cp $UG_WX_WRKING_DIR/trend_pressure.var $UG_WX_WRKING_DIR/old_pressure.var
    rm $UG_WX_WRKING_DIR/trend_pressure.var
fi

