2020-09-25 15:37:55 +02:00
|
|
|
apiVersion: v1
|
|
|
|
kind: Secret
|
|
|
|
metadata:
|
|
|
|
name: {{ include "gitea.fullname" . }}-init
|
|
|
|
labels:
|
|
|
|
{{- include "gitea.labels" . | nindent 4 }}
|
|
|
|
type: Opaque
|
|
|
|
stringData:
|
|
|
|
init_gitea.sh: |-
|
|
|
|
#!/bin/bash
|
2021-01-20 12:28:39 +01:00
|
|
|
{{- if .Values.initPreScript }}
|
|
|
|
# BEGIN: initPreScript
|
|
|
|
{{- with .Values.initPreScript -}}
|
|
|
|
{{ . | nindent 4}}
|
|
|
|
{{- end -}}
|
|
|
|
# END: initPreScript
|
|
|
|
{{- end }}
|
|
|
|
|
2021-06-09 13:42:49 +02:00
|
|
|
{{- if not .Values.image.rootless }}
|
2021-04-19 14:30:02 +02:00
|
|
|
chown 1000:1000 /data
|
2021-06-09 13:42:49 +02:00
|
|
|
{{- end }}
|
2020-09-25 15:37:55 +02:00
|
|
|
mkdir -p /data/git/.ssh
|
|
|
|
chmod -R 700 /data/git/.ssh
|
|
|
|
mkdir -p /data/gitea/conf
|
2021-04-29 11:12:48 +02:00
|
|
|
|
2021-06-09 16:35:50 +02:00
|
|
|
# prepare temp directory structure
|
|
|
|
mkdir -p "${GITEA_TEMP}"
|
|
|
|
chown 1000:1000 "${GITEA_TEMP}"
|
|
|
|
chmod ug+rwx "${GITEA_TEMP}"
|
|
|
|
|
2021-04-29 11:12:48 +02:00
|
|
|
# Copy config file to writable volume
|
2020-09-25 15:37:55 +02:00
|
|
|
cp /etc/gitea/conf/app.ini /data/gitea/conf/app.ini
|
|
|
|
chmod a+rwx /data/gitea/conf/app.ini
|
2021-03-04 09:43:52 +01:00
|
|
|
{{- if include "db.servicename" . }}
|
2021-04-29 11:12:48 +02:00
|
|
|
# Wait for database to become avialble
|
2020-09-25 15:37:55 +02:00
|
|
|
nc -v -w2 -z {{ include "db.servicename" . }} {{ include "db.port" . }} && \
|
2021-03-04 09:43:52 +01:00
|
|
|
{{- end }}
|
2021-04-29 11:12:48 +02:00
|
|
|
{{- if not .Values.image.rootless }}
|
2020-09-25 15:37:55 +02:00
|
|
|
su git -c ' \
|
2021-04-29 11:12:48 +02:00
|
|
|
{{- end }}
|
2020-09-25 15:37:55 +02:00
|
|
|
set -x; \
|
|
|
|
gitea migrate; \
|
|
|
|
{{- if and .Values.gitea.admin.username .Values.gitea.admin.password }}
|
2021-02-17 10:45:18 +01:00
|
|
|
gitea admin create-user --username {{ .Values.gitea.admin.username }} --password {{ .Values.gitea.admin.password | quote }} --email {{ .Values.gitea.admin.email }} --admin --must-change-password=false \
|
2020-09-25 15:37:55 +02:00
|
|
|
|| \
|
2021-04-29 11:12:48 +02:00
|
|
|
gitea admin change-password --username {{ .Values.gitea.admin.username }} --password {{ .Values.gitea.admin.password | quote }} \
|
|
|
|
|| \
|
|
|
|
gitea admin user create --username {{ .Values.gitea.admin.username }} --password {{ .Values.gitea.admin.password | quote }} --email {{ .Values.gitea.admin.email }} --admin --must-change-password=false \
|
|
|
|
|| \
|
|
|
|
gitea admin user change-password --username {{ .Values.gitea.admin.username }} --password {{ .Values.gitea.admin.password | quote }}; \
|
2020-09-25 15:37:55 +02:00
|
|
|
{{- end }}
|
|
|
|
{{- if .Values.gitea.ldap.enabled }}
|
|
|
|
gitea admin auth add-ldap \
|
2020-12-16 13:37:47 +01:00
|
|
|
{{- include "gitea.ldap_settings" . | nindent 6 }} \
|
2020-09-25 15:37:55 +02:00
|
|
|
|| \
|
|
|
|
( \
|
|
|
|
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} \
|
2020-12-16 13:37:47 +01:00
|
|
|
{{- include "gitea.ldap_settings" . | nindent 6 }} \
|
2020-09-25 15:37:55 +02:00
|
|
|
) \
|
|
|
|
{{- end }}
|
2021-03-01 13:24:11 +01:00
|
|
|
{{- 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 }}
|
2021-04-29 11:12:48 +02:00
|
|
|
{{- if not .Values.image.rootless }}
|
2021-01-20 12:28:39 +01:00
|
|
|
'
|
2021-04-29 11:12:48 +02:00
|
|
|
{{- end }}
|