2017-06-05 15:31:47 +02:00
|
|
|
#!/usr/bin/env bash
|
|
|
|
|
|
|
|
GIT_REPO=$HOME/vbrandl.git
|
|
|
|
WORKING_DIRECTORY=$HOME/vbrandl-working
|
|
|
|
PUBLIC_WWW="/var/www/vbrandl.net"
|
|
|
|
BACKUP_WWW=$HOME/blog_backup
|
|
|
|
MY_DOMAIN=www.vbrandl.net
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
rm -rf $WORKING_DIRECTORY
|
|
|
|
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
|
|
|
|
|
2017-06-05 15:35:26 +02:00
|
|
|
git clone --recursive $GIT_REPO $WORKING_DIRECTORY
|
2017-06-05 15:31:47 +02:00
|
|
|
rm -rf $PUBLIC_WWW/*
|
2017-06-05 15:36:28 +02:00
|
|
|
$HOME/.local/bin/hugo -s $WORKING_DIRECTORY -d ${PUBLIC_WWW} -b "https://${MY_DOMAIN}"
|
2017-06-05 18:49:57 +02:00
|
|
|
# minify files
|
|
|
|
./bin/minify_x86-64 -r -o $PUBLIC_WWW $PUBLIC_WWW
|
|
|
|
# ahead of time compression
|
2017-06-05 15:31:47 +02:00
|
|
|
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" \;
|
|
|
|
rm -rf $WORKING_DIRECTORY
|
|
|
|
trap - EXIT
|