From 1fe10417db91c243a5698a617ff16da752eda345 Mon Sep 17 00:00:00 2001 From: Christian Heller Date: Mon, 6 Jul 2020 20:57:19 +0200 Subject: [PATCH] Use intermediate /tmp/ step in /var/www/html writing. --- update.sh | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/update.sh b/update.sh index 57ecf89..6e45271 100755 --- a/update.sh +++ b/update.sh @@ -18,5 +18,11 @@ curl "${CSV_URL}" \ '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/ -- 2.30.2