#!/usr/bin/env zsh # Copyright 2020 (c) all rights reserved by WAE; see LICENSE # https://wae.github.io/coronavirus hosted courtesy https://pages.github.com ################################################################################ set -eu RDR="$HOME/WAE/virus/coronavirus" _TERM_() { printf "\\n" printf "%s\\n" "Related Internet Searches:" printf "%s\\n" " coronavirus meter" printf "%s\\n" " \"egg yolk\" parvovirus" printf "%s\\n" " \"egg yolk\" virus" printf "%s\\n" " \"egg yolk\" virus site:.edu" printf "%s\\n" " \"egg yolk\" virus site:.gov" printf "%s\\n" " hydration virus" printf "\\n" unset ARR INDEX exit } trap '_TERM_ $LINENO $?' ERR EXIT HUP INT TERM QUIT _HELP_() { grep -h -e "^\\#\\ \\#" -e "^\\ \\#\\ \\#" "$1" | sed "s/^\\#\\ \\#\\ //g" | sed "s/^\\ \\#\\ \\#\\ //g" # # To install this script, copy and paste: # # ``` # # au git wget zsh || apt install git wget zsh # install git, wget and zsh with au (https://wae.github.io/au/) and apt (https://salsa.debian.org/apt-team/apt) # # # # mkdir -p ~/WAE/virus/coronavirus/ # create directories # # # # cd ~/WAE/virus/ # change working directory # # # # git clone https://github.com/WAE/coronavirus # clone git repository # # # # ``` # # # # ~/WAE/virus/coronavirus.statistics.zsh # list countries # # # # ~/WAE/virus/coronavirus.statistics.zsh new-zealand uk # list statistics # # } _INSTALLCOMS_() { IARR=(git wget zsh) [ ! -z "$(command -v "au")" ] && (au "$IARR") || (printf "\\e[1;38;5;117m%s\\e[0m\\n" "$STRING1") || [ ! -z "$(command -v apt)" ] && (apt install "$IARR") || (printf "\\e[1;38;5;117m%s\\e[0m\\n" "$STRING2") unset IARR } _INSTALL_() { printf "\\e[1;38;5;117m%s\\e[0m\\n" "Beginning $RDR setup:" STRING1="Command \` au \` enables rollback; Available at this https://wae.github.io/au/ website: Continuing..." STRING2="Cannot update $RDR prerequisites: Continuing..." STRING3="Cannot clone $RDR: Continuing..." [ ! -z "$(command -v "git")" ] || _INSTALLCOMS_ [ ! -z "$(command -v "wget")" ] || _INSTALLCOMS_ [ ! -z "$(command -v "zsh")" ] || _INSTALLCOMS_ mkdir -p "$RDR" # create directories cd "$HOME/WAE/virus/" # change working directory git clone "$SIAD" || printf "\\e[1;38;5;117m%s\\e[0m\\n" "$STRING3" cd "$RDR" printf "\\e[1;38;5;117m%s\\e[0m\\n" "$RDR setup: DONE" } DATE="$(date +%Y%m%d)" DATA="https://www.worldometers.info/coronavirus/" DATADIR="$RDR/www.worldometers.info/coronavirus/$DATE" SIAD="https://github.com/WAE/coronavirus" [ -d "$RDR" ] && cd "$RDR" || _INSTALL_ [ ! -f "$DATADIR/index.html" ] && [ ! -d "$DATADIR" ] && mkdir -p "$DATADIR" && cd "$DATADIR" && wget "$DATA" && cd "$RDR" [ ! -f "$DATADIR/index.html" ] && cd "$DATADIR" && wget "$DATA" && cd "$RDR" # # echo china > ~/WAE/virus/.conf/COUNTRYSTAT # change default country [ -f "$RDR/.conf/COUNTRYNAME" ] && COUNTRYNAME="$(cat "$RDR/.conf/COUNTRYNAME")" || COUNTRYNAME="us" _ARR_() { STATKEY=("Country" "Total Cases" "New Cases" "Total Deaths" "New Deaths" "Total Recovered" "Active Cases" "Serious, Critical" "Tot Cases/ 1M pop" "Deaths/ 1M pop" "Total Tests" "Tests/ 1M pop") INDEX="$(awk '{gsub("\">", "\">0", $0); print}' $DATADIR/index.html)" COUNTRYSTAT=($(grep -iA 12 "ref=\"country/$COUNTRYNAME/" <<< "$INDEX" | grep -oP '(?<=">).*(?=