d6eb50ca35
This fixes several flaws introduced by commits for #169 (see c49dc047a4
).
- Respect kebab-case ldap bind inline definition
- Prevent camelCase ldap bind inline definition from being overridden by empty string
- Create admin account when `existingSecret` is used
Reviewed-on: https://gitea.com/gitea/helm-chart/pulls/183
Reviewed-by: Andrew Thornton <art27@cantab.net>
Reviewed-by: luhahn <luhahn@noreply.gitea.io>
Co-authored-by: justusbunsi <justusbunsi@noreply.gitea.io>
Co-committed-by: justusbunsi <justusbunsi@noreply.gitea.io>
75 lines
2.7 KiB
YAML
75 lines
2.7 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
|
|
{{- if .Values.initPreScript }}
|
|
# BEGIN: initPreScript
|
|
{{- with .Values.initPreScript -}}
|
|
{{ . | nindent 4}}
|
|
{{- end -}}
|
|
# END: initPreScript
|
|
{{- end }}
|
|
|
|
{{- if not .Values.image.rootless }}
|
|
chown 1000:1000 /data
|
|
{{- end }}
|
|
mkdir -p /data/git/.ssh
|
|
chmod -R 700 /data/git/.ssh
|
|
mkdir -p /data/gitea/conf
|
|
|
|
# prepare temp directory structure
|
|
mkdir -p "${GITEA_TEMP}"
|
|
chown 1000:1000 "${GITEA_TEMP}"
|
|
chmod ug+rwx "${GITEA_TEMP}"
|
|
|
|
# Copy config file to writable volume
|
|
cp /etc/gitea/conf/app.ini /data/gitea/conf/app.ini
|
|
chmod a+rwx /data/gitea/conf/app.ini
|
|
{{- if include "db.servicename" . }}
|
|
# Wait for database to become avialble
|
|
nc -v -w2 -z {{ include "db.servicename" . }} {{ include "db.port" . }} && \
|
|
{{- end }}
|
|
{{- if not .Values.image.rootless }}
|
|
su git -c ' \
|
|
{{- end }}
|
|
set -x; \
|
|
gitea migrate; \
|
|
{{- if or .Values.gitea.admin.existingSecret (and .Values.gitea.admin.username .Values.gitea.admin.password) }}
|
|
gitea admin create-user --username "${GITEA_ADMIN_USERNAME}" --password "${GITEA_ADMIN_PASSWORD}" --email {{ .Values.gitea.admin.email }} --admin --must-change-password=false \
|
|
|| \
|
|
gitea admin change-password --username "${GITEA_ADMIN_USERNAME}" --password "${GITEA_ADMIN_PASSWORD}" \
|
|
|| \
|
|
gitea admin user create --username "${GITEA_ADMIN_USERNAME}" --password "${GITEA_ADMIN_PASSWORD}" --email {{ .Values.gitea.admin.email }} --admin --must-change-password=false \
|
|
|| \
|
|
gitea admin user change-password --username "${GITEA_ADMIN_USERNAME}" --password "${GITEA_ADMIN_PASSWORD}"; \
|
|
{{- end }}
|
|
{{- if .Values.gitea.ldap.enabled }}
|
|
gitea admin auth add-ldap \
|
|
{{- include "gitea.ldap_settings" . | nindent 6 }} \
|
|
|| \
|
|
( \
|
|
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} \
|
|
{{- include "gitea.ldap_settings" . | nindent 6 }} \
|
|
) \
|
|
{{- end }}
|
|
{{- if .Values.gitea.oauth.enabled }}
|
|
gitea admin auth add-oauth \
|
|
{{- include "gitea.oauth_settings" . | nindent 6 }} \
|
|
|| \
|
|
( \
|
|
export GITEA_AUTH_ID=$(gitea admin auth list | grep {{ .Values.gitea.oauth.name | quote }} | awk -F " " "{print \$1}"); \
|
|
gitea admin auth update-oauth --id ${GITEA_AUTH_ID} \
|
|
{{- include "gitea.oauth_settings" . | nindent 6 }} \
|
|
) \
|
|
{{- end }}
|
|
{{- if not .Values.image.rootless }}
|
|
'
|
|
{{- end }}
|