Update post-receive hook to use make for ahead of time compression

This commit is contained in:
Valentin Brandl 2018-07-16 12:23:00 +02:00
parent 763c2e2343
commit cc785e8c61
Signed by: vbrandl
GPG Key ID: CAD4DA1A789125F9

12
hooks/post-receive Normal file → Executable file
View File

@ -9,14 +9,22 @@ MY_DOMAIN=www.vbrandl.net
set -e set -e
echo Deleting old working directory...
rm -rf $WORKING_DIRECTORY rm -rf $WORKING_DIRECTORY
echo Creating backup...
rsync -aqz ${PUBLIC_WWW}/ $BACKUP_WWW 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 git clone --recursive $GIT_REPO $WORKING_DIRECTORY
echo Deleting old version...
rm -rf $PUBLIC_WWW/* rm -rf $PUBLIC_WWW/*
echo Generating HTML...
$HOME/.local/bin/hugo -s $WORKING_DIRECTORY -d ${PUBLIC_WWW} -b "https://${MY_DOMAIN}" $HOME/.local/bin/hugo -s $WORKING_DIRECTORY -d ${PUBLIC_WWW} -b "https://${MY_DOMAIN}"
# ahead of time compression # 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 rm -rf $WORKING_DIRECTORY
trap - EXIT trap - EXIT