c49dc047a4
Allow admin user and password to be configured via existing secrets Allow LDAP bindDn and bindPassword to be configured via existing secrets Update Readme Fixes: #169 Co-authored-by: Lucas Hahn <lucas.hahn@novum-rgi.de> Reviewed-on: https://gitea.com/gitea/helm-chart/pulls/170 Reviewed-by: techknowlogick <techknowlogick@gitea.io> Reviewed-by: Lunny Xiao <xiaolunwen@gmail.com> Co-authored-by: luhahn <luhahn@noreply.gitea.io> Co-committed-by: luhahn <luhahn@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 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 }}
|