Skip to content

Commit

Permalink
helm chart - allow to configure additional values
Browse files Browse the repository at this point in the history
Signed-off-by: Simon L <[email protected]>
  • Loading branch information
szaimen committed Nov 16, 2023
1 parent 97a4960 commit 21b34d8
Show file tree
Hide file tree
Showing 5 changed files with 71 additions and 1 deletion.
1 change: 1 addition & 0 deletions Containers/nextcloud/config/apps.config.php
Original file line number Diff line number Diff line change
Expand Up @@ -12,4 +12,5 @@
'writable' => true,
),
),
'appsallowlist' => getenv('APPS_ALLOWLIST') ? explode(" ", getenv('APPS_ALLOWLIST')) : [],
);
22 changes: 22 additions & 0 deletions Containers/nextcloud/config/smtp.config.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
<?php
if (getenv('SMTP_HOST') && getenv('MAIL_FROM_ADDRESS') && getenv('MAIL_DOMAIN')) {
$CONFIG = array (
'mail_smtpmode' => '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') || (getenv('SMTP_PASSWORD_FILE') && file_exists(getenv('SMTP_PASSWORD_FILE')))),
'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_FILE') && file_exists(getenv('SMTP_PASSWORD_FILE'))) {
$CONFIG['mail_smtppassword'] = trim(file_get_contents(getenv('SMTP_PASSWORD_FILE')));
} elseif (getenv('SMTP_PASSWORD')) {
$CONFIG['mail_smtppassword'] = getenv('SMTP_PASSWORD');
} else {
$CONFIG['mail_smtppassword'] = '';
}
}
3 changes: 3 additions & 0 deletions Containers/nextcloud/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -464,6 +464,9 @@ 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" ]; then
php /var/www/html/occ config:app:set support subscription_key --value="$SUBSCRIPTION_KEY"
fi

# Adjusting log files to be stored on a volume
echo "Adjusting log files..."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ spec:
value: "{{ .Values.TIMEZONE }}"
- name: UPDATE_NEXTCLOUD_APPS
value: "{{ .Values.UPDATE_NEXTCLOUD_APPS }}"
image: nextcloud/aio-nextcloud:20231113_125854-latest
image: nextcloud/aio-nextcloud:20231113_12585-latest
name: nextcloud-aio-nextcloud
ports:
- containerPort: 9000
Expand Down
44 changes: 44 additions & 0 deletions nextcloud-aio-helm-chart/update-helm.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)"
Expand Down

0 comments on commit 21b34d8

Please sign in to comment.