You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

23 lines
765 B

#!/usr/bin/env bash
# this file was used on my server when I selfhosted my personal
# Gitea instance. I've put this as post-receive-hook on the
# servers local Gitea repository.
GIT_REPO=/var/lib/gitea/data/gitea-repositories/dominic/oe7drt-website.git
WORKING_DIR=${HOME}/oe7drt-website-working
PUBLIC_WWW=/var/www/oe7drt
BACKUP_WWW=/var/www/oe7drt-backup
MY_DOMAIN=oe7drt.com
set -e
rm -rf ${WORKING_DIR}
rsync -aqz ${PUBLIC_WWW}/ ${BACKUP_WWW}
trap "echo 'A problem occured. Reverting to backup.'; rsync -aqz --del ${BACKUP_WWW}/ ${PUBLIC_WWW}; rm -rf ${WORKING_DIR}" EXIT
git clone ${GIT_REPO} ${WORKING_DIR}
rm -rf ${PUBLIC_WWW}/*
${HOME}/go/bin/hugo --gc --minify --cleanDestinationDir -s ${WORKING_DIR} -d ${PUBLIC_WWW}
rm -rf ${WORKING_DIR}
trap - EXIT