From cc785e8c61596cdf57cd46e647de12cf1017d2fa Mon Sep 17 00:00:00 2001 From: Valentin Brandl Date: Mon, 16 Jul 2018 12:23:00 +0200 Subject: [PATCH] Update post-receive hook to use make for ahead of time compression --- hooks/post-receive | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) mode change 100644 => 100755 hooks/post-receive diff --git a/hooks/post-receive b/hooks/post-receive old mode 100644 new mode 100755 index d53ee21..24ca2d8 --- a/hooks/post-receive +++ b/hooks/post-receive @@ -9,14 +9,22 @@ MY_DOMAIN=www.vbrandl.net set -e +echo Deleting old working directory... rm -rf $WORKING_DIRECTORY +echo Creating backup... rsync -aqz ${PUBLIC_WWW}/ $BACKUP_WWW -trap "echo 'A problem occurred. Reverting to backup.'; rsync -aqz --del $BACKUP_WWW/ $PUBLIC_WWW; rm -rf $WORKING_DIRECTORY" EXIT +trap "echo 'A problem occurred. Reverting to backup.'; rsync -aqz --del $BACKUP_WWW/ $PUBLIC_WWW; rm -rf +$WORKING_DIRECTORY" EXIT +echo Cloning into working directory... git clone --recursive $GIT_REPO $WORKING_DIRECTORY +echo Deleting old version... rm -rf $PUBLIC_WWW/* +echo Generating HTML... $HOME/.local/bin/hugo -s $WORKING_DIRECTORY -d ${PUBLIC_WWW} -b "https://${MY_DOMAIN}" # ahead of time compression -find $PUBLIC_WWW -type f \( -name '*.html' -o -name '*.js' -o -name '*.css' -o -name '*.xml' -o -name '*.svg' \) -exec gzip -v -k -f --best {} \; -exec touch -r {} "{}.gz" \; +echo Compressing files ahead of time... +make -C $PUBLIC_WWW -f $WORKING_DIRECTORY/Makefile +echo Deleting working directory... rm -rf $WORKING_DIRECTORY trap - EXIT