-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·41 lines (39 loc) · 1.72 KB
/
configure
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/bin/bash
FC=`curl -X GET "https://api.weather.gov/points/$1,$2" -H "accept:application/geo+json" 2>/dev/null | grep hourly | awk 'match($0, /https:[^\"]+/){print substr($0, RSTART+23, RLENGTH-23)}'`
RA=`curl -X GET "https://api.weather.gov/points/$1,$2" -H "accept:application/geo+json" 2>/dev/null | grep radar | awk 'match($0, /: \"..../){print substr($0, RSTART+4, 3)}'`
ZONE=`curl -X GET "https://api.weather.gov/points/$1,$2" -H "accept:application/geo+json" 2>/dev/null | grep county | awk 'match($0, /county\/....../){print substr($0, RSTART+7, 6)}'`
TIMEZONE=`curl -X GET "https://api.weather.gov/points/$1,$2" -H "accept:application/geo+json" 2>/dev/null | grep time | awk 'match($0, /timeZone\": \"[^\"]+/){print substr($0, RSTART+12, RLENGTH-12)}'`
if [ "$FC" == "" ]; then
echo "Could not determine forecast information URL"
exit 1
fi
if [ "$RA" == "" ]; then
echo "Could not determine radar station"
exit 1
fi
if [ "$ZONE" == "" ]; then
echo "Could not determine alert zone"
exit 1
fi
if [ "$TIMEZONE" == "" ]; then
echo "Could not determine time zone"
exit 1
fi
if [ "$3" == "" ]; then
LO="Local"
else
LO=$3
fi
echo "var config = {" > config.js
echo " protocol : \"https:\"," >> config.js
echo " port : 443," >> config.js
echo " forecastURL : \"api.weather.gov\"," >> config.js
echo " forecastPath : \"$FC\"," >> config.js
echo " radarStation : \"$RA\"," >> config.js
echo " zone : \"$ZONE\"," >> config.js
echo " timeZone : \"$TIMEZONE\"" >> config.js
echo "};" >> config.js
echo "module.exports=config;" >> config.js
sed s/XXX/$RA/ indexTemplate.html > index.html
sed s/Local/$LO/ -i index.html
echo "config.js succussfully built for location $1, $2"