#!/bin/sh
LOGFILE="/usr/ns/log/report1min.log"
(
echo "$(nstime) report1min started..."
set -x

# Generate Hays County battery reports
reportgen -h -Fg lst/haysbatt.lst -Ft tpt/haysbatt.tpt -Fo/www/WETMapV3/HaysCounty/haysbatt.xml
cp /www/WETMapV3/HaysCounty/haysbatt.xml /www/WETMapV3/HaysCounty/public/haysbatt.xml
cp /www/WETMapV3/HaysCounty/haysbatt.xml /www/WETMap/HaysCounty/public/haysbatt.xml
cp /www/WETMapV3/HaysCounty/haysbatt.xml /www/WETMapV3/HaysCounty/restricted/haysbatt.xml
cp /www/WETMapV3/HaysCounty/haysbatt.xml /www/WETMap/HaysCounty/restricted/haysbatt.xml

# Generate Hays County precip reports
reportgen -h -Fs tim/haysrain.tim -Fg lst/haysrain.lst -Ft tpt/haysrain.tpt -Fo/www/WETMapV3/HaysCounty/haysrain.xml
cp /www/WETMapV3/HaysCounty/haysrain.xml /www/WETMapV3/HaysCounty/public/haysrain.xml
cp /www/WETMapV3/HaysCounty/haysrain.xml /www/WETMap/HaysCounty/public/haysrain.xml
cp /www/WETMapV3/HaysCounty/haysrain.xml /www/WETMapV3/HaysCounty/restricted/haysrain.xml
cp /www/WETMapV3/HaysCounty/haysrain.xml /www/WETMap/HaysCounty/restricted/haysrain.xml
reportgen -h -Fs tim/today.tim -Fg lst/haysrain.lst -Ft tpt/haystodayrain.tpt -Fo/www/WETMapV3/HaysCounty/haystodayrain.xml
cp /www/WETMapV3/HaysCounty/haystodayrain.xml /www/WETMapV3/HaysCounty/public/haystodayrain.xml
cp /www/WETMapV3/HaysCounty/haystodayrain.xml /www/WETMap/HaysCounty/public/haystodayrain.xml
cp /www/WETMapV3/HaysCounty/haystodayrain.xml /www/WETMapV3/HaysCounty/restricted/haystodayrain.xml
cp /www/WETMapV3/HaysCounty/haystodayrain.xml /www/WETMap/HaysCounty/restricted/haystodayrain.xml

# Generate Hays County Water Level reports
reportgen -h -Fg lst/hayswl.lst -Ft tpt/hayswl.tpt -Fo/www/WETMapV3/HaysCounty/hayswl.xml
reportgen -h -Fg lst/hayswlpublic.lst -Ft tpt/hayswl.tpt -Fo/www/WETMapV3/HaysCounty/public/hayswlpublic.xml
cp /www/WETMapV3/HaysCounty/public/hayswlpublic.xml /www/WETMap/HaysCounty/public/hayswlpublic.xml
cp /www/WETMapV3/HaysCounty/hayswl.xml /www/WETMapV3/HaysCounty/restricted/hayswl.xml
cp /www/WETMapV3/HaysCounty/hayswl.xml /www/WETMap/HaysCounty/restricted/hayswl.xml

# Generate Hays County Wx reports
reportgen -h -Fg lst/hayswx.lst -Ft tpt/hayswx.tpt -Fo/www/WETMapV3/HaysCounty/hayswx.xml
cp /www/WETMapV3/HaysCounty/hayswx.xml /www/WETMapV3/HaysCounty/public/hayswx.xml
cp /www/WETMapV3/HaysCounty/hayswx.xml /www/WETMap/HaysCounty/public/hayswx.xml
cp /www/WETMapV3/HaysCounty/hayswx.xml /www/WETMapV3/HaysCounty/restricted/hayswx.xml
cp /www/WETMapV3/HaysCounty/hayswx.xml /www/WETMap/HaysCounty/restricted/hayswx.xml

# generate flasher status reports for restricted site
reportgen -h -Fg lst/haysflasher.lst -Ft tpt/haysflashers.tpt -Fo/www/WETMapV3/HaysCounty/haysflasher.xml
cp /www/WETMapV3/HaysCounty/haysflasher.xml /www/WETMapV3/HaysCounty/public/haysflasher.xml
cp /www/WETMapV3/HaysCounty/haysflasher.xml /www/WETMapV3/HaysCounty/restricted/haysflasher.xml
cp /www/WETMapV3/HaysCounty/haysflasher.xml /www/WETMap/HaysCounty/restricted/haysflasher.xml

# generate flasher status reports for public site
reportgen -h -Fg lst/haysflasherpublic.lst -Ft tpt/haysstageflashers.tpt -Fo/www/WETMapV3/HaysCounty/haysflasherpublic.xml
cp /www/WETMapV3/HaysCounty/haysflasherpublic.xml /www/WETMapV3/HaysCounty/public/haysflasherpublic.xml
cp /www/WETMapV3/HaysCounty/haysflasherpublic.xml /www/WETMap/HaysCounty/public/haysflasherpublic.xml
cp /www/WETMapV3/HaysCounty/haysflasherpublic.xml /www/WETMapV3/HaysCounty/restricted/haysflasherpublic.xml
cp /www/WETMapV3/HaysCounty/haysflasherpublic.xml /www/WETMap/HaysCounty/restricted/haysflasherpublic.xml

# generate alarm report
/usr/ns/cus/xml_alarm >/www/WETMapV3/HaysCounty/alert_alarms.xml
cp /www/WETMapV3/HaysCounty/alert_alarms.xml /www/WETMapV3/HaysCounty/public/alert_alarms.xml
cp /www/WETMapV3/HaysCounty/alert_alarms.xml /www/WETMap/HaysCounty/public/alert_alarms.xml
cp /www/WETMapV3/HaysCounty/alert_alarms.xml /www/WETMapV3/HaysCounty/restricted/alert_alarms.xml
cp /www/WETMapV3/HaysCounty/alert_alarms.xml /www/WETMap/HaysCounty/restricted/alert_alarms.xml

# generate GPS status report
reportgen -h -Fg lst/haysgps.lst -Ft tpt/haysgps.tpt -Fo/www/WETMapV3/HaysCounty/haysgps.xml
cp /www/WETMapV3/HaysCounty/haysgps.xml /www/WETMapV3/HaysCounty/public/haysgps.xml
cp /www/WETMapV3/HaysCounty/haysgps.xml /www/WETMap/HaysCounty/public/haysgps.xml
cp /www/WETMapV3/HaysCounty/haysgps.xml /www/WETMapV3/HaysCounty/restricted/haysgps.xml
cp /www/WETMapV3/HaysCounty/haysgps.xml /www/WETMap/HaysCounty/restricted/haysgps.xml

# Bee Cave reports 
reportgen -h -Fs tim/haysrain.tim -Fg lst/beecaverain.lst -Ft tpt/haysrain.tpt -Fo/www/WETMapV3/BeeCave/beecaverain.xml
reportgen -h -Fs tim/today.tim -Fg lst/beecaverain.lst -Ft tpt/haystodayrain.tpt -Fo/www/WETMapV3/BeeCave/beecavetodayrain.xml
reportgen -h -Fg lst/beecavewl.lst -Ft tpt/hayswl.tpt -Fo/www/WETMapV3/BeeCave/beecavewl.xml
reportgen -h -Fg lst/beecavebatt.lst -Ft tpt/haysbatt.tpt -Fo/www/WETMapV3/BeeCave/beecavebatt.xml
reportgen -h -Fg lst/beecaveflasher.lst -Ft tpt/haysflashers.tpt -Fo/www/WETMapV3/BeeCave/beecaveflasher.xml
reportgen -h -Fg lst/beecavegps.lst -Ft tpt/haysgps.tpt -Fo/www/WETMapV3/BeeCave/beecavegps.xml

#copy NWS warnings
#cp /var/www/WETMapV3/HaysCounty/public/nws_warnings.geojson /var/www/WETMap/json/nws_warnings.geojson

set +x
echo "$(nstime) report1min finished"
) 2>&1 | tee -a $LOGFILE
