71 lines
1.5 KiB
Bash
71 lines
1.5 KiB
Bash
#!/bin/sh
|
|
|
|
set -e
|
|
|
|
[ -z "${1}" ] && exit
|
|
|
|
STAGIT_BASE="${STAGIT_BASE:-/var/lib/git/stagit}"
|
|
GL_REPO_BASE="${GL_REPO_BASE:-/var/lib/git/repositories}"
|
|
|
|
# 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}"
|
|
else
|
|
out_dir="${STAGIT_BASE}/${1}"
|
|
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
|
|
}
|
|
|
|
echo "running stagit for '${1}'"
|
|
|
|
if gitolite access "${1}" stagit 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_stagit "${1}" "${site}"
|
|
_i=$((_i+1))
|
|
done
|
|
|
|
else
|
|
url=$(printf "%s" "${URLS}" | cut -d " " -f 1)
|
|
set_url "${1}" "${url}"
|
|
run_stagit "${1}" ""
|
|
fi
|
|
|
|
else
|
|
rm -rf "${STAGIT_BASE}"*"/${1}.git"
|
|
fi
|