X-Git-Url: https://plomlompom.com/repos/?p=berlin-corona-table;a=blobdiff_plain;f=update.sh;h=ace8592a60902c614e510a2b6020621981b734f2;hp=11bfb0f997b323ff876ea1d968e3fd04622eaa53;hb=25ddf4a9271680eba1c1280e331cbfd4f35519c6;hpb=2843d6502fecf9164ae69bcc8000b70ac6376c8f diff --git a/update.sh b/update.sh index 11bfb0f..ace8592 100755 --- a/update.sh +++ b/update.sh @@ -15,8 +15,14 @@ today="$(date +%Y-%m-%d)" curl "${CSV_URL}" \ | awk 'BEGIN { FS=";"; ORS=""; print "'${today}'" }; '\ '!/^Bezirk/ { printf "%4d", $3 }; '\ -'END { printf "\n" }' "${filename}" >> "${table_path}" +'END { printf "\n" }' "${filename}" >> "${table_path}" # Write enhanced table output to directory served by web server. -./enhance_table.py "${table_path}" txt > /var/www/html/berlin_corona.txt -./enhance_table.py "${table_path}" html > /var/www/html/berlin_corona.html +# +# 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/