separate sites

main
Ricard Illa 2021-01-03 20:23:49 +01:00
parent 934fb947a1
commit 5fe69c4e58
13 changed files with 64 additions and 91 deletions

View File

@ -30,17 +30,10 @@ RUN chown -R git:git /var/lib/git && \
/usr/local/bin/build-stagit-index \
/usr/local/bin/build-stagit-repo \
/usr/local/bin/build-stagit-repos \
/usr/local/bin/set-url \
/usr/local/bin/set-urls \
/usr/local/bin/set-owner \
/usr/local/bin/set-owners \
/opt/gitolite-local/hooks/common/post-receive \
/opt/gitolite-local/triggers/build-stagit-index \
/opt/gitolite-local/triggers/build-stagit-repos \
/opt/gitolite-local/triggers/set-url \
/opt/gitolite-local/triggers/set-urls \
/opt/gitolite-local/triggers/set-owners \
/opt/gitolite-local/triggers/set-owner
/opt/gitolite-local/triggers/build-stagit-repo \
/opt/gitolite-local/triggers/build-stagit-repos
ENTRYPOINT ["/usr/local/bin/entrypoint"]
CMD ["/usr/sbin/sshd", "-D", "-e"]

View File

@ -4,19 +4,67 @@ set -e
[ -z "${1}" ] && exit
STAGIT_DIR="${STAGIT_DIR:-/var/lib/git/stagit}"
STAGIT_BASE="${STAGIT_BASE:-/var/lib/git/stagit}"
GL_REPO_BASE="${GL_REPO_BASE:-/var/lib/git/repositories}"
out_dir="${STAGIT_DIR}/${1}"
# 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
}
echo "running stagit for '${1}'"
if gitolite access "${1}" stagit R any; then
mkdir -p "${out_dir}" && \
cd "${out_dir}" && \
/usr/local/bin/stagit "${repo_dir}" &&
ln -sf files.html index.html
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
rm -rf "${out_dir}"
url=$(printf "%s" "${URLS}" | cut -d " " -f 1)
set_url "${1}" "${url}"
run_stagit "${1}" ""
fi
else
rm -rf "${STAGIT_BASE}*/${1}.git"
fi

View File

@ -1,16 +0,0 @@
#!/bin/sh
set -e
[ -z "$1" ] && exit 0
GL_REPO_BASE="${GL_REPO_BASE:-/var/lib/git/repositories}"
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

View File

@ -1,7 +0,0 @@
#!/bin/sh
set -e
for repo in $(gitolite list-phy-repos); do
/usr/local/bin/set-owner "${repo}"
done

View File

@ -1,18 +0,0 @@
#!/bin/sh
set -e
[ -z "$1" ] && exit 0
GL_REPO_BASE="${GL_REPO_BASE:-/var/lib/git/repositories}"
repo_dir="${GL_REPO_BASE}/${1}.git"
# shellcheck disable=SC1091
[ -z "${REPOS_URL}" ] && [ -f /etc/env ] && . /etc/env
echo "setting url for '${1}'"
if [ -z "$REPOS_URL" ]; then
echo "REPOS_URL not set"
exit 0
fi
[ -d "$repo_dir" ] && echo "${REPOS_URL}/${1}" > "${repo_dir}/url"

View File

@ -1,7 +0,0 @@
#!/bin/sh
set -e
for repo in $(gitolite list-phy-repos); do
/usr/local/bin/set-url "${repo}"
done

View File

@ -86,15 +86,12 @@
#POST_COMPILE => [],
POST_COMPILE => [
'set-urls',
'set-owners',
'build-stagit-repos',
'build-stagit-index'
],
POST_CREATE => [
'set-url',
'set-owner'
'build-stagit-repo'
],
# List of commands and features to enable

View File

@ -3,6 +3,4 @@
set -e
[ -n "${GL_REPO}" ] && \
/usr/local/bin/set-url "${GL_REPO}" && \
/usr/local/bin/set-owner "${GL_REPO}" && \
/usr/local/bin/build-stagit-repo "${GL_REPO}"

View File

@ -0,0 +1,5 @@
#!/bin/sh
set -e
[ -n "$2" ] && /usr/local/bin/build-stagit-repo "$2"

View File

@ -1,5 +0,0 @@
#!/bin/sh
set -e
[ -n "$2" ] && /usr/local/bin/set-owner "$2"

View File

@ -1,5 +0,0 @@
#!/bin/sh
set -e
/usr/local/bin/set-owners

View File

@ -1,5 +0,0 @@
#!/bin/sh
set -e
[ -n "$2" ] && /usr/local/bin/set-url "$2"

View File

@ -1,5 +0,0 @@
#!/bin/sh
set -e
/usr/local/bin/set-urls