diff options
-rwxr-xr-x | hooks/post-receive | 96 |
1 files changed, 50 insertions, 46 deletions
diff --git a/hooks/post-receive b/hooks/post-receive index 1d6437e..aea9b9b 100755 --- a/hooks/post-receive +++ b/hooks/post-receive @@ -1,49 +1,53 @@ #!/usr/bin/env bash -_web="${WEB}/oper.io" -recompile=0 - -# Deploy any pages that were changed -for i in ${FILES_E[*]} ${FILES_A[*]} ${FILES_M[*]}; do - _log "Processing and installing ${i}" - - if [ "${i##*.}" = 'adoc' ]; then - dest="${_web}/html/$(basename ${i%.*}).html" - make adoc SRC="${i}" DEST="${dest}" - - elif [ "${i##*.}" = 'rst' ]; then - dest="${_web}/html/$(basename ${i%.*}).html" - make rst SRC="${i}" DEST="${dest}" - - elif [ "${i##*.}" = 'md' ]; then - dest="${_web}/html/$(basename ${i%.*}).html" - make md SRC="${i}" DEST="${dest}" - - elif [ "$(dirname ${i})" = 'src' ]; then - recompile=1 - - else - # Don't want to use dest for this, as we don't want to change file - # extentions - install -v -D "${i}" "${_web}/${i}" +deploy() { + local path="${1}" + local recompile=0 + + # Deploy any pages that were changed + for i in ${FILES_E[*]} ${FILES_A[*]} ${FILES_M[*]}; do + _log "Processing and installing ${i}" + + if [ "${i##*.}" = 'adoc' ]; then + dest="${path}/html/$(basename ${i%.*}).html" + make adoc SRC="${i}" DEST="${dest}" + + elif [ "${i##*.}" = 'rst' ]; then + dest="${path}/html/$(basename ${i%.*}).html" + make rst SRC="${i}" DEST="${dest}" + + elif [ "${i##*.}" = 'md' ]; then + dest="${path}/html/$(basename ${i%.*}).html" + make md SRC="${i}" DEST="${dest}" + + elif [ "$(dirname ${i})" = 'src' ]; then + recompile=1 + + else + # Don't want to use dest for this, as we don't want to change file + # extentions + install -v -D "${i}" "${path}/${i}" + fi + done + + if [ "${recompile}" -eq 1 ]; then + make src + install -v -D index "${path}/index" fi -done - -if [ "${recompile}" -eq 1 ]; then - make src - install -v -D index "${_web}/index" -fi - -# Clean up any deleted files -for i in ${FILES_D[*]}; do - # Pre-determine path for processed files - out="${_web}/html/$(basename ${i%.*}).html" - - if [ -e "${_web}/${i}" ]; then - _log "Deleting file ${i}" - rm -f "${_web}/${i}" - elif [ -e "${out}" ]; then - _log "Deleting post ${out}" - rm -f "${out}" - fi -done + + # Clean up any deleted files + for i in ${FILES_D[*]}; do + # Pre-determine path for processed files + out="${path}/html/$(basename ${i%.*}).html" + + if [ -e "${path}/${i}" ]; then + _log "Deleting file ${i}" + rm -f "${path}/${i}" + elif [ -e "${out}" ]; then + _log "Deleting post ${out}" + rm -f "${out}" + fi + done +} + +deploy "${WEB}/oper.io" |