52 lines
1.3 KiB
Plaintext
52 lines
1.3 KiB
Plaintext
|
#!/bin/sh
|
||
|
|
||
|
set -e
|
||
|
|
||
|
env | awk -F"=" '{ print $1"=\""$2"\"" }' > /etc/env
|
||
|
|
||
|
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" \
|
||
|
"${BASE_DIR}/stagit" \
|
||
|
"${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 set-urls
|
||
|
su-exec git set-owners
|
||
|
su-exec git build-stagit-repos
|
||
|
su-exec git build-stagit-index
|
||
|
|
||
|
echo "gitolite is ready,starting sshd"
|
||
|
exec "$@"
|