tAdd script to alert about specific weather phenomena - nws-forecast-mailer - fetch and deliver the NWS 48-hour forecast by email
HTML git clone git://src.adamsgaard.dk/nws-forecast-mailer
DIR Log
DIR Files
DIR Refs
DIR README
DIR LICENSE
---
DIR commit eb3057bbaf957254ff489bfd8c13094dcdc86f03
DIR parent fa398a89a0250426401c8328dc156691cb46cf61
HTML Author: Anders Damsgaard <andersd@riseup.net>
Date: Thu, 4 Jan 2018 15:06:44 -0500
Add script to alert about specific weather phenomena
Diffstat:
A forecast_alert.sh | 42 +++++++++++++++++++++++++++++++
M muttrc | 2 +-
2 files changed, 43 insertions(+), 1 deletion(-)
---
DIR diff --git a/forecast_alert.sh b/forecast_alert.sh
t@@ -0,0 +1,42 @@
+#!/bin/bash
+recipient=("andersd@riseup.net")
+latitude=40.330
+longitude=-74.5647
+
+function fetch {
+ curl --location --silent \
+ "http://f1.weather.gov/MapClick.php?w0=t&w1=td&w2=wc&w3=sfcwind&w3u=3&w4=sky&w5=pop&w6=rh&w7=rain&w8=thunder&w9=snow&w10=fzg&w11=sleet&w12=fog&w13u=0&w16u=1&w17u=1&AheadHour=0&Submit=Submit&FcstType=digital&textField1=${1}&textField2=${2}&site=all&unit=0&dd=&bw=&menu=1"|\
+ w3m -T text/html | cat -
+}
+
+out=$(fetch $latitude $longitude)
+
+# any fog in the next 48 hours?
+keyword="Fog"
+if echo "$out" | grep "^$keyword" | grep '[0-9]' >/dev/null; then
+
+
+ message=$(cat <<-END
+Next 24 hours:
+$(echo "$out" | grep "^Hour (EST)" | head -n 1)
+$(echo "$out" | grep "^$keyword" | head -n 1)
+
+Following 24 hours:
+$(echo "$out" | grep "^Hour (EST)" | tail -n 1)
+$(echo "$out" | grep "^$keyword" | tail -n 1)
+END
+ )
+
+
+ for i in "${recipient[@]}"; do
+ echo "$message" | \
+ mutt -F muttrc \
+ -s "$keyword at ($latitude,$longitude) within the next 48 hours" \
+ -- $i
+ done
+
+else
+ echo "No $keyword predicted within the next 48 hours"
+fi
+
+
DIR diff --git a/muttrc b/muttrc
t@@ -1,4 +1,4 @@
-set sendmail="/usr/bin/msmtp -a riseup"
+set sendmail="msmtp -a riseup"
set use_from=yes
set realname="Anders' Weather Service"
set from=andersd@riseup.net