dockerfiles/gitolite-stagit/bin/build-stagit-repo

71 lines
1.5 KiB
Plaintext
Raw Normal View History

2020-04-08 13:05:07 +02:00
#!/bin/sh
set -e
[ -z "${1}" ] && exit
2021-01-03 20:23:49 +01:00
STAGIT_BASE="${STAGIT_BASE:-/var/lib/git/stagit}"
2020-04-08 13:05:07 +02:00
GL_REPO_BASE="${GL_REPO_BASE:-/var/lib/git/repositories}"
2021-01-03 20:23:49 +01:00
# shellcheck disable=SC1091
[ -f /etc/env ] && . /etc/env
run_stagit () {
repo_dir="${GL_REPO_BASE}/${1}.git"
if [ -n "${2}" ]; then
out_dir="${STAGIT_BASE}-${2}/${1}.git"
else
out_dir="${STAGIT_BASE}/${1}/git"
fi
mkdir -p "${out_dir}" && \
cd "${out_dir}" && \
/usr/local/bin/stagit "${repo_dir}" && \
ln -sf files.html index.html
}
set_url () {
url_file="${GL_REPO_BASE}/${1}.git/url"
if [ -n "${2}" ]; then
echo "${2}/${1}" > "${url_file}"
else
echo "url not set"
rm -f "${url_file}"
fi
}
set_owner () {
owner_file="${GL_REPO_BASE}/${1}.git/owner"
if owner=$(gitolite git-config "${1}" gitweb.owner); then
echo "setting owner for '${1}'"
echo "${owner}" > "${owner_file}"
else
echo "usetting owner for '${1}'"
rm -f "${owner_file}"
fi
}
2020-04-08 13:05:07 +02:00
echo "running stagit for '${1}'"
if gitolite access "${1}" stagit R any; then
2021-01-03 20:23:49 +01:00
set_owner "${1}"
if [ -n "${SITES}" ]; then
_i=1
for site in ${SITES}; do
url=$(printf "%s" "${URLS}" | cut -d " " -f "$_i")
set_url "${1}" "${url}"
run_stagit "${1}" "${site}"
_i=$((_i+1))
done
else
url=$(printf "%s" "${URLS}" | cut -d " " -f 1)
set_url "${1}" "${url}"
run_stagit "${1}" ""
fi
2020-04-08 13:05:07 +02:00
else
2021-01-03 20:23:49 +01:00
rm -rf "${STAGIT_BASE}*/${1}.git"
2020-04-08 13:05:07 +02:00
fi