From d84bc9fb238e66c093649077053bfd1abc0d78cb Mon Sep 17 00:00:00 2001 From: Michael De Roover Date: Thu, 30 Apr 2020 13:00:52 +0200 Subject: [PATCH] Initial state of cv --- cv | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100755 cv diff --git a/cv b/cv new file mode 100755 index 0000000..4b704fb --- /dev/null +++ b/cv @@ -0,0 +1,39 @@ +#!/bin/bash + +. /usr/local/bin/vars + +country=$1 + +get(){ + if [ -f /tmp/cv/$date-$country ] + then + cat /tmp/cv/$date-$country + else + curl -sL corona.lmao.ninja/v2/$endpoint > /tmp/cv/$date-$country + cat /tmp/cv/$date-$country + fi +} +result(){ + echo "Total: $(get | jq -r '.cases')" + echo "Active: $(get | jq -r '.active')" + echo "Today: $(get | jq -r '.todayCases')" + echo "Tests: $(get | jq -r '.tests')" +} + +show "Queried at: $date" +if [ ! -z $country ] +then + if [ "$country" == "all" ] + then + endpoint=all + result + else + endpoint=countries/$country + result + fi +else + country=Belgium + show "Country has been set to $country." + endpoint=countries/$country + result +fi