2021-01-31 17:46:03 +01:00
|
|
|
#!/bin/sh
|
|
|
|
|
|
|
|
set -e
|
|
|
|
|
|
|
|
[ -z "${1}" ] && exit
|
|
|
|
|
|
|
|
PYSTAGIT_BASE="${PYSTAGIT_BASE:-/var/lib/git/pystagit}"
|
|
|
|
GL_REPO_BASE="${GL_REPO_BASE:-/var/lib/git/repositories}"
|
|
|
|
|
|
|
|
# shellcheck disable=SC1091
|
|
|
|
[ -f /etc/env ] && . /etc/env
|
|
|
|
|
|
|
|
run_pystagit () {
|
|
|
|
repo_dir="${GL_REPO_BASE}/${1}.git"
|
|
|
|
if [ -n "${2}" ]; then
|
|
|
|
out_dir="${PYSTAGIT_BASE}-${2}/${1}"
|
|
|
|
else
|
|
|
|
out_dir="${PYSTAGIT_BASE}/${1}"
|
|
|
|
fi
|
|
|
|
mkdir -p "${out_dir}" && \
|
2021-02-17 10:32:07 +01:00
|
|
|
chmod 755 "${out_dir}" && \
|
2021-01-31 17:46:03 +01:00
|
|
|
cd "${out_dir}" && \
|
2021-01-31 19:07:52 +01:00
|
|
|
/usr/bin/pystagit "${repo_dir}" && \
|
2021-02-06 19:55:28 +01:00
|
|
|
if [ -f about.html ]; then
|
2021-02-06 20:31:19 +01:00
|
|
|
ln -sf about.html index.html
|
2021-02-06 19:55:28 +01:00
|
|
|
else
|
|
|
|
ln -sf log.html index.html
|
|
|
|
fi
|
2021-01-31 17:46:03 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
}
|
|
|
|
|
|
|
|
echo "running pystagit for '${1}'"
|
|
|
|
|
|
|
|
if gitolite access "${1}" pystagit R any; then
|
|
|
|
|
|
|
|
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_pystagit "${1}" "${site}"
|
|
|
|
_i=$((_i+1))
|
|
|
|
done
|
|
|
|
|
|
|
|
else
|
|
|
|
url=$(printf "%s" "${URLS}" | cut -d " " -f 1)
|
|
|
|
set_url "${1}" "${url}"
|
|
|
|
run_pystagit "${1}" ""
|
|
|
|
fi
|
|
|
|
|
|
|
|
else
|
|
|
|
rm -rf "${PYSTAGIT_BASE}"*"/${1}.git"
|
|
|
|
fi
|