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