tAdd script to alert about specific weather phenomena - nws-forecast-mailer - f… | |
git clone git://src.adamsgaard.dk/nws-forecast-mailer | |
Log | |
Files | |
Refs | |
README | |
LICENSE | |
--- | |
commit eb3057bbaf957254ff489bfd8c13094dcdc86f03 | |
parent fa398a89a0250426401c8328dc156691cb46cf61 | |
Author: Anders Damsgaard <[email protected]> | |
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(-) | |
--- | |
diff --git a/forecast_alert.sh b/forecast_alert.sh | |
t@@ -0,0 +1,42 @@ | |
+#!/bin/bash | |
+recipient=("[email protected]") | |
+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=s… | |
+ 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 | |
+ | |
+ | |
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 [email protected] |