X-Git-Url: https://plomlompom.com/repos/?p=berlin-corona-table;a=blobdiff_plain;f=update.sh;h=fee5ef593c4b4f2ea1e6fb6e77a8d7b41f917a53;hp=1a84c8ba9fa70208f7c7693d151b52c03be487ca;hb=HEAD;hpb=74f4868304347258087e64ad210d5e8a0902b092;ds=sidebyside diff --git a/update.sh b/update.sh index 1a84c8b..fee5ef5 100755 --- a/update.sh +++ b/update.sh @@ -1,11 +1,17 @@ #!/bin/sh +set -e -# Parse Lageso day table of new infections by district into new line for history table. -today="$(date +%Y-%m-%d)" -curl https://www.berlin.de/lageso/_assets/gesundheit/publikationen/corona/bezirkstabelle.csv \ -| awk 'BEGIN { FS=";"; ORS=""; print "'${today}'" }; '\ -'!/^Bezirk/ { printf "%4d", $3 }; '\ -'END { printf "\n" }' "${filename}" >> /home/plom/berlin-corona-table/daily_infections_table.txt +table_path=daily_infections_table.txt + +# Re-build infections table. +./scrape.py > "${table_path}" # Write enhanced table output to directory served by web server. -./enhance_table.py > /var/www/html/berlin_corona.txt +# +# Use intermediate /tmp/ step so we don't overwrite a valid previous output with +# the emptiness delivered to stdout on any error, before such an error would +# kill this script due to "set -e". +./enhance_table.py "${table_path}" html > /tmp/berlin_corona.html +./enhance_table.py "${table_path}" txt > /tmp/berlin_corona.txt +mv /tmp/berlin_corona.html /var/www/html/ +mv /tmp/berlin_corona.txt /var/www/html/