From ddeadcf7232d0b43d599ab26c10adff2e4ecc1b2 Mon Sep 17 00:00:00 2001 From: Hyperling Date: Sun, 17 Aug 2025 09:12:23 -0700 Subject: [PATCH] Add safeguards to cron job so that website does not get deleted without having replacement files. --- Config/HugoExample/files/hugo.cronjob.sh | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/Config/HugoExample/files/hugo.cronjob.sh b/Config/HugoExample/files/hugo.cronjob.sh index 8bb86b7..0e215bc 100644 --- a/Config/HugoExample/files/hugo.cronjob.sh +++ b/Config/HugoExample/files/hugo.cronjob.sh @@ -2,9 +2,10 @@ cd /var/www/hugo/site -git pull +git pull && hugo --gc --minify +status="$?" -hugo --gc --minify - -rm -rfv /var/www/html/* -cp -rfv public/* /var/www/html/ +if [[ $status == 0 && -e public/* ]]; then + rm -rfv /var/www/html/* + mv -rfv public/* /var/www/html/ +fi