csb-git
Raw
#!/bin/bash
set -euo pipefail
HELP="Builds csb sites for git repositories
Usage:
$(basename ${0}) [options] <name> <source>
$(basename ${0}) -h|--help
Options:
-h, --help Show this message and exit
-o DIR, --out DIR Set output directory [default: .]
-t DIR, --templates DIR Set template directory [default: ./templates]"
ARGS=$(echo "$HELP" | csb-optparse "$@")
trap "rm -rf $ARGS" EXIT
[[ $(< "${ARGS}/--help") == "true" ]] && echo "$HELP" && exit 0
NAME="$(<${ARGS}/NAME)"
REPO="${NAME}.git"
OUTDIR="$(<${ARGS}/--out)"
REMOTEREPO="$(<${ARGS}/SOURCE)"
TEMPLATEDIR="$(<${ARGS}/--templates)"
OUTREPO="${OUTDIR}/${REPO}"
OUTRAW="${OUTDIR}/${NAME}/raw"
OUTRENDERED="${OUTDIR}/${NAME}/tree"
if [[ ! -e "${OUTREPO}" ]]; then
git --work-tree="${OUTRAW}" clone "${REMOTEREPO}" "${OUTREPO}"
fi
pushd "${OUTREPO}" >/dev/null
git update-server-info
popd >/dev/null
csb-tree "${NAME}" -i "${OUTRAW}" -o "${OUTRENDERED}" -t "tree.tmpl" --include "${TEMPLATEDIR}"