helm-chart/templates/gitea/init.yaml
luhahn 1f95ae962c Move all password related data to secrets (#28)
Bump Chart version

Move all password related data to secrets

Co-authored-by: Lucas Hahn <lucas.hahn@novum-rgi.de>
Reviewed-on: https://gitea.com/gitea/helm-chart/pulls/28
Reviewed-by: techknowlogick <techknowlogick@gitea.io>
Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com>
2020-09-25 13:37:55 +00:00

57 lines
2.6 KiB
YAML

apiVersion: v1
kind: Secret
metadata:
name: {{ include "gitea.fullname" . }}-init
labels:
{{- include "gitea.labels" . | nindent 4 }}
type: Opaque
stringData:
init_gitea.sh: |-
#!/bin/bash
mkdir -p /data/git/.ssh
chmod -R 700 /data/git/.ssh
mkdir -p /data/gitea/conf
cp /etc/gitea/conf/app.ini /data/gitea/conf/app.ini
chmod a+rwx /data/gitea/conf/app.ini
nc -v -w2 -z {{ include "db.servicename" . }} {{ include "db.port" . }} && \
su git -c ' \
set -x; \
gitea migrate; \
{{- if and .Values.gitea.admin.username .Values.gitea.admin.password }}
gitea admin create-user --username {{ .Values.gitea.admin.username }} --password '{{ .Values.gitea.admin.password }}' --email {{ .Values.gitea.admin.email }} --admin \
|| \
gitea admin change-password --username {{ .Values.gitea.admin.username }} --password '{{ .Values.gitea.admin.password }}'; \
{{- end }}
{{- if .Values.gitea.ldap.enabled }}
gitea admin auth add-ldap \
--name {{ .Values.gitea.ldap.name | quote }} \
--security-protocol {{ .Values.gitea.ldap.securityProtocol | quote }} \
--host {{ .Values.gitea.ldap.host | quote }} \
--port {{ .Values.gitea.ldap.port | int}} \
--user-search-base {{ .Values.gitea.ldap.userSearchBase | quote }} \
--user-filter {{ .Values.gitea.ldap.userFilter | quote }} \
--admin-filter {{ .Values.gitea.ldap.adminFilter | quote }} \
--email-attribute {{ .Values.gitea.ldap.emailAttribute | quote }} \
--bind-dn {{ .Values.gitea.ldap.bindDn | quote }} \
--bind-password {{ .Values.gitea.ldap.bindPassword | quote }} \
--synchronize-users \
--username-attribute {{ .Values.gitea.ldap.usernameAttribute | quote }} \
|| \
( \
export GITEA_AUTH_ID=$(gitea admin auth list | grep {{ .Values.gitea.ldap.name | quote }} | awk -F " " "{print \$1}"); \
gitea admin auth update-ldap --id ${GITEA_AUTH_ID} \
--name {{ .Values.gitea.ldap.name | quote }} \
--security-protocol {{ .Values.gitea.ldap.securityProtocol | quote }} \
--host {{ .Values.gitea.ldap.host | quote }} \
--port {{ .Values.gitea.ldap.port | int}} \
--user-search-base {{ .Values.gitea.ldap.userSearchBase | quote }} \
--user-filter {{ .Values.gitea.ldap.userFilter | quote }} \
--admin-filter {{ .Values.gitea.ldap.adminFilter | quote }} \
--email-attribute {{ .Values.gitea.ldap.emailAttribute | quote }} \
--bind-dn {{ .Values.gitea.ldap.bindDn | quote }} \
--bind-password {{ .Values.gitea.ldap.bindPassword | quote }} \
--synchronize-users \
--username-attribute {{ .Values.gitea.ldap.usernameAttribute | quote }} \
) \
{{- end }}
'