-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathget-sunset-sunrise_and_schedule-jobs.sh
More file actions
executable file
·18 lines (13 loc) · 1.18 KB
/
Copy pathget-sunset-sunrise_and_schedule-jobs.sh
File metadata and controls
executable file
·18 lines (13 loc) · 1.18 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#!/bin/bash
location="LOXX0001"
# Obtain sunrise and sunset raw data from weather.com
sun_times=$( lynx --dump https://weather.com/weather/today/l/$location | grep "\* Sun" | sed "s/[[:alpha:]]//g;s/*//" )
# Alternative curl/wget solution. In case you wish to use curl or wget instead of lynx comment the above line and uncomment one of the lines below:
#sun_times=$( curl -s https://weather.com/weather/today/l/$location | sed 's/<span/\n/g' | sed 's/<\/span>/\n/g' | grep -E "dp0-details-sunrise|dp0-details-sunset" | tr -d '\n' | sed 's/>/ /g' | cut -d " " -f 4,8 )
#sun_times=$( wget -qO- https://weather.com/weather/today/l/$location | sed 's/<span/\n/g' | sed 's/<\/span>/\n/g' | grep -E "dp0-details-sunrise|dp0-details-sunset" | tr -d '\n' | sed 's/>/ /g' | cut -d " " -f 4,8 )
# Extract sunrise and sunset times and convert to 24 hour format
sunrise=$(date --date="`echo $sun_times | awk '{ print $1}'` AM" +%R)
sunset =$(date --date="`echo $sun_times | awk '{ print $2}'` PM" +%R)
# Shedule ATD job to switch themes for today...
at "$sunset" <<< "/home/maniac/cron/kibana-theme-switch.sh sunset" > /dev/null
at "$sunrise" <<< "/home/maniac/cron/kibana-theme-switch.sh sunrise" > /dev/null