From a0dd9d6605977a2af63f22e2e87622f72a8dbb57 Mon Sep 17 00:00:00 2001 From: Simon L Date: Thu, 16 Nov 2023 13:58:06 +0100 Subject: [PATCH] helm chart - allow to configure additional values Signed-off-by: Simon L --- Containers/nextcloud/config/apps.config.php | 1 + Containers/nextcloud/config/smtp.config.php | 20 +++++++++ Containers/nextcloud/entrypoint.sh | 4 ++ .../nextcloud-aio-nextcloud-deployment.yaml | 22 ++++++++++ nextcloud-aio-helm-chart/update-helm.sh | 44 +++++++++++++++++++ nextcloud-aio-helm-chart/values.yaml | 11 +++++ 6 files changed, 102 insertions(+) create mode 100644 Containers/nextcloud/config/smtp.config.php diff --git a/Containers/nextcloud/config/apps.config.php b/Containers/nextcloud/config/apps.config.php index 4c37f72a933..c68a925a85f 100644 --- a/Containers/nextcloud/config/apps.config.php +++ b/Containers/nextcloud/config/apps.config.php @@ -12,4 +12,5 @@ 'writable' => true, ), ), + 'appsallowlist' => getenv('APPS_ALLOWLIST') ? explode(" ", getenv('APPS_ALLOWLIST')) : [], ); diff --git a/Containers/nextcloud/config/smtp.config.php b/Containers/nextcloud/config/smtp.config.php new file mode 100644 index 00000000000..40cfdf94289 --- /dev/null +++ b/Containers/nextcloud/config/smtp.config.php @@ -0,0 +1,20 @@ + 'smtp', + 'mail_smtphost' => getenv('SMTP_HOST'), + 'mail_smtpport' => getenv('SMTP_PORT') ?: (getenv('SMTP_SECURE') ? 465 : 25), + 'mail_smtpsecure' => getenv('SMTP_SECURE') ?: '', + 'mail_smtpauth' => getenv('SMTP_NAME') && getenv('SMTP_PASSWORD'), + 'mail_smtpauthtype' => getenv('SMTP_AUTHTYPE') ?: 'LOGIN', + 'mail_smtpname' => getenv('SMTP_NAME') ?: '', + 'mail_from_address' => getenv('MAIL_FROM_ADDRESS'), + 'mail_domain' => getenv('MAIL_DOMAIN'), + ); + + if (getenv('SMTP_PASSWORD')) { + $CONFIG['mail_smtppassword'] = getenv('SMTP_PASSWORD'); + } else { + $CONFIG['mail_smtppassword'] = ''; + } +} diff --git a/Containers/nextcloud/entrypoint.sh b/Containers/nextcloud/entrypoint.sh index 534ccada4c0..a6a56e6c9a2 100644 --- a/Containers/nextcloud/entrypoint.sh +++ b/Containers/nextcloud/entrypoint.sh @@ -464,6 +464,10 @@ php /var/www/html/occ config:system:set one-click-instance --value=true --type=b php /var/www/html/occ config:system:set one-click-instance.user-limit --value=100 --type=int php /var/www/html/occ config:system:set one-click-instance.link --value="https://nextcloud.com/all-in-one/" php /var/www/html/occ app:enable support +if [ -n "$SUBSCRIPTION_KEY" ] && [ -z "$(php /var/www/html/occ config:app:get support potential_subscription_key)" ]; then + php /var/www/html/occ config:app:set support potential_subscription_key --value="$SUBSCRIPTION_KEY" + php /var/www/html/occ config:app:delete support last_check +fi # Adjusting log files to be stored on a volume echo "Adjusting log files..." diff --git a/nextcloud-aio-helm-chart/templates/nextcloud-aio-nextcloud-deployment.yaml b/nextcloud-aio-helm-chart/templates/nextcloud-aio-nextcloud-deployment.yaml index bd83c1e5bd6..e7d24775b96 100755 --- a/nextcloud-aio-helm-chart/templates/nextcloud-aio-nextcloud-deployment.yaml +++ b/nextcloud-aio-helm-chart/templates/nextcloud-aio-nextcloud-deployment.yaml @@ -37,6 +37,28 @@ spec: mountPath: /nextcloud-aio-nextcloud containers: - env: + - name: SMTP_HOST + value: "{{ .Values.SMTP_HOST }}" + - name: SMTP_HOST + value: "{{ .Values.SMTP_HOST }}" + - name: SMTP_SECURE + value: "{{ .Values.SMTP_SECURE }}" + - name: SMTP_PORT + value: "{{ .Values.SMTP_PORT }}" + - name: SMTP_AUTHTYPE + value: "{{ .Values.SMTP_AUTHTYPE }}" + - name: SMTP_NAME + value: "{{ .Values.SMTP_NAME }}" + - name: SMTP_PASSWORD + value: "{{ .Values.SMTP_PASSWORD }}" + - name: MAIL_FROM_ADDRESS + value: "{{ .Values.MAIL_FROM_ADDRESS }}" + - name: MAIL_DOMAIN + value: "{{ .Values.MAIL_DOMAIN }}" + - name: SUBSCRIPTION_KEY + value: "{{ .Values.SUBSCRIPTION_KEY }}" + - name: APPS_ALLOWLIST + value: "{{ .Values.APPS_ALLOWLIST }}" - name: ADDITIONAL_APKS value: "{{ .Values.NEXTCLOUD_ADDITIONAL_APKS }}" - name: ADDITIONAL_PHP_EXTENSIONS diff --git a/nextcloud-aio-helm-chart/update-helm.sh b/nextcloud-aio-helm-chart/update-helm.sh index a5b67a3cda0..2cab0d18720 100755 --- a/nextcloud-aio-helm-chart/update-helm.sh +++ b/nextcloud-aio-helm-chart/update-helm.sh @@ -190,6 +190,34 @@ for variable in "${VOLUMES[@]}"; do find ./ -name "*nextcloud-aio-$variable-persistentvolumeclaim.yaml" -exec sed -i "s|storage: 100Mi|storage: {{ .Values.$name }}|" \{} \; done +# Additional config +cat << EOL > /tmp/additional.config + - name: SMTP_HOST + value: "{{ .Values.SMTP_HOST }}" + - name: SMTP_HOST + value: "{{ .Values.SMTP_HOST }}" + - name: SMTP_SECURE + value: "{{ .Values.SMTP_SECURE }}" + - name: SMTP_PORT + value: "{{ .Values.SMTP_PORT }}" + - name: SMTP_AUTHTYPE + value: "{{ .Values.SMTP_AUTHTYPE }}" + - name: SMTP_NAME + value: "{{ .Values.SMTP_NAME }}" + - name: SMTP_PASSWORD + value: "{{ .Values.SMTP_PASSWORD }}" + - name: MAIL_FROM_ADDRESS + value: "{{ .Values.MAIL_FROM_ADDRESS }}" + - name: MAIL_DOMAIN + value: "{{ .Values.MAIL_DOMAIN }}" + - name: SUBSCRIPTION_KEY + value: "{{ .Values.SUBSCRIPTION_KEY }}" + - name: APPS_ALLOWLIST + value: "{{ .Values.APPS_ALLOWLIST }}" +EOL +# shellcheck disable=SC1083 +find ./ -name '*nextcloud-deployment.yaml' -exec sed -i "/^.*\- env:/r /tmp/additional.config" \{} \; + cd ../ mkdir -p ../helm-chart/ rm latest/Chart.yaml @@ -227,6 +255,22 @@ for variable in "${VOLUME_VARIABLE[@]}"; do done sed -i "s|NEXTCLOUD_STORAGE_SIZE: 1Gi|NEXTCLOUD_STORAGE_SIZE: 5Gi|" /tmp/sample.conf sed -i "s|NEXTCLOUD_DATA_STORAGE_SIZE: 1Gi|NEXTCLOUD_DATA_STORAGE_SIZE: 5Gi|" /tmp/sample.conf + +# Additional config +cat << ADDITIONAL_CONFIG >> /tmp/sample.conf + +SUBSCRIPTION_KEY: # This allows to set the Nextcloud Enterprise key via ENV +APPS_ALLOWLIST: # This allows to configure allowed apps that will be shown in Nextcloud's Appstore. You need to enter the app-IDs of the apps here and separate them with spaces. E.g. 'files richdocuments' +SMTP_HOST: # (empty by default): The hostname of the SMTP server. +SMTP_SECURE: # (empty by default): Set to 'ssl' to use SSL, or 'tls' to use STARTTLS. +SMTP_PORT: # (default: '465' for SSL and '25' for non-secure connections): Optional port for the SMTP connection. Use '587' for an alternative port for STARTTLS. +SMTP_AUTHTYPE: # (default: 'LOGIN'): The method used for authentication. Use 'PLAIN' if no authentication or STARTLS is required. +SMTP_NAME: # (empty by default): The username for the authentication. +SMTP_PASSWORD: # (empty by default): The password for the authentication. +MAIL_FROM_ADDRESS: # (not set by default): Set the local-part for the 'from' field in the emails sent by Nextcloud. +MAIL_DOMAIN: # (not set by default): Set a different domain for the emails than the domain where Nextcloud is installed. +ADDITIONAL_CONFIG + mv /tmp/sample.conf ../helm-chart/values.yaml ENABLED_VARIABLES="$(grep -oP '^[A-Z_]+_ENABLED' ../helm-chart/values.yaml)" diff --git a/nextcloud-aio-helm-chart/values.yaml b/nextcloud-aio-helm-chart/values.yaml index 38598c33d92..fcf10e5fd51 100755 --- a/nextcloud-aio-helm-chart/values.yaml +++ b/nextcloud-aio-helm-chart/values.yaml @@ -46,3 +46,14 @@ NEXTCLOUD_DATA_STORAGE_SIZE: 5Gi # You can change the size of the nextclou NEXTCLOUD_TRUSTED_CACERTS_STORAGE_SIZE: 1Gi # You can change the size of the nextcloud-trusted-cacerts volume that default to 1Gi with this value ONLYOFFICE_STORAGE_SIZE: 1Gi # You can change the size of the onlyoffice volume that default to 1Gi with this value REDIS_STORAGE_SIZE: 1Gi # You can change the size of the redis volume that default to 1Gi with this value + +SUBSCRIPTION_KEY: # This allows to set the Nextcloud Enterprise key via ENV +APPS_ALLOWLIST: # This allows to configure allowed apps that will be shown in Nextcloud's Appstore. You need to enter the app-IDs of the apps here and separate them with spaces. E.g. 'files richdocuments' +SMTP_HOST: # (empty by default): The hostname of the SMTP server. +SMTP_SECURE: # (empty by default): Set to 'ssl' to use SSL, or 'tls' to use STARTTLS. +SMTP_PORT: # (default: '465' for SSL and '25' for non-secure connections): Optional port for the SMTP connection. Use '587' for an alternative port for STARTTLS. +SMTP_AUTHTYPE: # (default: 'LOGIN'): The method used for authentication. Use 'PLAIN' if no authentication or STARTLS is required. +SMTP_NAME: # (empty by default): The username for the authentication. +SMTP_PASSWORD: # (empty by default): The password for the authentication. +MAIL_FROM_ADDRESS: # (not set by default): Set the local-part for the 'from' field in the emails sent by Nextcloud. +MAIL_DOMAIN: # (not set by default): Set a different domain for the emails than the domain where Nextcloud is installed.