From 0a038ff5bbf93d4c4f946529f020185d86490bd3 Mon Sep 17 00:00:00 2001
From: Arie Peterson <arie@greenhost.nl>
Date: Wed, 21 Aug 2024 15:17:46 +0200
Subject: [PATCH] Allow setting instance name

---
 templates/setup-apps-configmap.yaml | 11 +++++++++++
 values-local.yaml.example           |  3 +++
 values.yaml                         |  2 ++
 3 files changed, 16 insertions(+)

diff --git a/templates/setup-apps-configmap.yaml b/templates/setup-apps-configmap.yaml
index 557f1372..229f573b 100644
--- a/templates/setup-apps-configmap.yaml
+++ b/templates/setup-apps-configmap.yaml
@@ -163,6 +163,17 @@ data:
     # Config settings from the configmap above
     run_as "php $occ config:import /var/local/config.json"
 
+    {{- if .Values.theming.name }}
+    current=$(run_as "php $occ theming:config name")
+    if [ "$current" == "name is currently not set" ]
+    then
+      echo "Setting instance name."
+      run_as "php $occ theming:config name "{{ printf "%q" (printf "%q" .Values.theming.name) }}
+    else
+      echo "Instance name is already set, not changing."
+    fi
+    {{- end }}
+
     echo "Updating database indices, columns, keys, etc."
     run_as "php $occ db:add-missing-indices --no-interaction"
     run_as "php $occ db:add-missing-columns --no-interaction"
diff --git a/values-local.yaml.example b/values-local.yaml.example
index 0897bc97..0b9a0c4a 100644
--- a/values-local.yaml.example
+++ b/values-local.yaml.example
@@ -92,3 +92,6 @@ rabbitmq:
 scim:
   url: "https://files.example.com/index.php/apps/scimserviceprovider/"
   token: JWT token
+
+theming:
+  name: "Our file server"
diff --git a/values.yaml b/values.yaml
index 659bd194..f46de10d 100644
--- a/values.yaml
+++ b/values.yaml
@@ -254,3 +254,5 @@ tests:
       suspicious_login:
       twofactor_totp:
       user_ldap:
+
+theming: {}
-- 
GitLab