coreos-home-server/service/gitea/container/run-gitea
Alex Palaistras 096d51ecb4 gitea: Use LDAP authentication by default
New Gitea installations will now use LDAP authentication, typically
provided by the included `lldap` service, over SMTP authentication, as
this is is more flexible.
2022-09-19 15:07:53 +01:00

33 lines
1.6 KiB
Bash
Executable File

#!/bin/sh
set -eu
# Export shared variables.
export GITEA_WORK_DIR=/var/lib/gitea
# Create configuration file from collected templates.
envsubst < /etc/gitea/config.ini.template > /etc/gitea/config.ini
# Create data directories and correct permissions for data files.
install --owner git --group git --mode 700 --directory /var/lib/gitea
chown -R git:git /etc/gitea
# Initialize default condiguration if needed.
if ! test -f /var/lib/gitea/gitea.db; then
# Set up database.
gosu git /usr/bin/gitea -c /etc/gitea/config.ini migrate
# Set up LDAP authentication via local service.
gosu git /usr/bin/gitea -c /etc/gitea/config.ini admin auth add-ldap --name "LDAP" \
--host "${GITEA_AUTH_LDAP_HOST}" --port "${GITEA_AUTH_LDAP_PORT}" \
--synchronize-users --security-protocol unencrypted \
--bind-dn "uid=${GITEA_AUTH_LDAP_BIND_UID},ou=people,dc=ldap,dc=local" --bind-password "${GITEA_AUTH_LDAP_BIND_PASSWORD}" \
--user-search-base "ou=people,dc=ldap,dc=local" --user-filter "(&(memberof=cn=gitea_user,ou=groups,dc=ldap,dc=local)(|(uid=%[1]s)(mail=%[1]s)))" \
--admin-filter "(memberof=cn=gitea_admin,ou=groups,dc=ldap,dc=local)" \
--username-attribute "uid" --email-attribute "mail" \
--firstname-attribute "givenName" --surname-attribute "sn" --avatar-attribute "jpegPhoto"
fi
# Run entrypoint under specific user.
gosu git /usr/bin/gitea -c /etc/gitea/config.ini web "$@"