dockerfiles/gitolite-stagit/bin/entrypoint

50 lines
1.2 KiB
Plaintext
Raw Normal View History

2020-04-08 13:05:07 +02:00
#!/bin/sh
set -e
2021-01-03 21:07:21 +01:00
su-exec git env | awk -F"=" '{ print $1"=\""$2"\"" }' > /etc/env
2020-04-08 13:05:07 +02:00
for algorithm in rsa dsa ecdsa ed25519; do
keyfile="/etc/ssh/keys/ssh_host_${algorithm}_key"
[ -f "$keyfile" ] || \
ssh-keygen -q -N '' -f "$keyfile" -t "$algorithm"
done
BASE_DIR=/var/lib/git
echo "fixing permissions..."
mkdir -p \
"${BASE_DIR}/.gitolite/conf" \
"${BASE_DIR}/.gitolite/hooks" \
"${BASE_DIR}/.gitolite/keydir" \
"${BASE_DIR}/.gitolite/logs"
chown -R git:git \
"${BASE_DIR}/.gitolite" \
"${BASE_DIR}/.ssh" \
2021-01-03 21:07:21 +01:00
"${BASE_DIR}/stagit"* \
2020-04-08 13:05:07 +02:00
"${BASE_DIR}/repositories"
if [ ! -f "${BASE_DIR}/.ssh/authorized_keys" ]; then
if [ -z "$SSH_KEY" ]; then
echo "SSH_KEY needs to be set"
exit 1
fi
SSH_KEY_NAME=${SSH_KEY_NAME:-admin}
echo "$SSH_KEY" > "/tmp/${SSH_KEY_NAME}.pub"
echo "gitolite's initial setup"
su-exec git gitolite setup -pk "/tmp/${SSH_KEY_NAME}.pub"
rm "/tmp/${SSH_KEY_NAME}.pub"
else
# stuff is already set up, but check the setup anyway
echo "gitolite's sanity setup"
su-exec git gitolite setup
fi
echo "building static site"
su-exec git build-stagit-repos
su-exec git build-stagit-index
echo "gitolite is ready,starting sshd"
exec "$@"