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