forked from sayan01/scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
COVID-19
executable file
·36 lines (30 loc) · 1022 Bytes
/
COVID-19
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
#!/bin/bash
updated=0
get(){
notify-send -a "Corona Virus COVID-19 Cases" "Updating Database"
curl https://api.covid19india.org/data.json > ~/.cache/coronadata
[ "$(grep -c "statewise" ~/.cache/coronadata)" != 0 ] && updated=1
}
write(){
echo -e "$(date "+%a %d %b %Y %r")\t$confirmed" >> ~/coronalog
cd ~/docs/projects/CoronaData/ || exit 1
git pull &>/dev/null
rm coronalog &>/dev/null
cp ~/coronalog . &>/dev/null
git add . &>/dev/null
git commit -m "Update" &>/dev/null
git push -u origin master &>/dev/null &
}
[ ! -e ~/.cache/coronadata ] && get
[ "$(grep -c "statewise" ~/.cache/coronadata)" = 0 ] && get
date1=$(date +%H)
date2=$(date -r ~/.cache/coronadata +%H)
[ "$date1" != "$date2" ] && get
confirmed=$(grep "\"confirmed\":" ~/.cache/coronadata | head -n 1 | awk -F'["]' '{print $4}')
deaths=$(grep "\"deaths\":" ~/.cache/coronadata | head -n 1 | awk -F'["]' '{print $4}')
echo "| 😷 $confirmed 💀 $deaths |"
if [ "$updated" = 1 ] && [ "$1" == "-w" ]
then
write
fi
exit 0