feat(plugins): adding default apps install with env

New configmap cm-plugin-scripts uses NEXTCLOUD_PLUGIN_LIST env
to install apps

This script is runned on each pod "start"
This commit is contained in:
Philippe Caseiro 2023-09-18 15:25:51 +02:00
parent 2b88f112fc
commit 64fe182998
2 changed files with 44 additions and 22 deletions

View File

@ -14,21 +14,10 @@ spec:
- $(MINIO_BOOTSTRAP_JOB_NAME) - $(MINIO_BOOTSTRAP_JOB_NAME)
containers: containers:
- name: nextcloud - name: nextcloud
#envFrom:
#- configMapRef:
# name: nextcloud-env-update
env: env:
- name: POSTGRES_USER
valueFrom:
secretKeyRef:
name: nextcloud-postgres-app
key: username
- name: POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: nextcloud-postgres-app
key: password
- name: OBJECTSTORE_S3_BUCKET
value: nxt-minio
- name: OBJECTSTORE_S3_AUTOCREATE
value: "true"
- name: OBJECTSTORE_S3_KEY - name: OBJECTSTORE_S3_KEY
valueFrom: valueFrom:
secretKeyRef: secretKeyRef:
@ -39,14 +28,6 @@ spec:
secretKeyRef: secretKeyRef:
name: nextcloud-minio-user name: nextcloud-minio-user
key: CONSOLE_SECRET_KEY key: CONSOLE_SECRET_KEY
- name: OBJECTSTORE_S3_HOST
value: minio:$(MINIO_SERVICE_PORT)
- name: OBJECTSTORE_S3_PORT
value: "443"
- name: OBJECTSTORE_S3_SSL
value: "true"
- name: OBJECTSTORE_S3_USEPATH_STYLE
value: "true"
livenessProbe: livenessProbe:
httpGet: httpGet:
@ -76,6 +57,9 @@ spec:
- mountPath: /docker-entrypoint-hooks.d/post-installation/ldap.sh - mountPath: /docker-entrypoint-hooks.d/post-installation/ldap.sh
name: script-config-ldap name: script-config-ldap
subPath: poststart-ldap.sh subPath: poststart-ldap.sh
- mountPath: /docker-entrypoint-hooks.d/before-starting/plugins.sh
name: script-config-plugins
subPath: poststart-plugins.sh
- mountPath: /etc/minio-ccerts - mountPath: /etc/minio-ccerts
name: minio-certs name: minio-certs
readOnly: true readOnly: true
@ -87,5 +71,9 @@ spec:
configMap: configMap:
name: script-config-ldap name: script-config-ldap
defaultMode: 0755 defaultMode: 0755
- name: script-config-plugins
configMap:
name: script-config-plugins
defaultMode: 0755
restartPolicy: Always restartPolicy: Always
serviceAccountName: nextcloud-sa serviceAccountName: nextcloud-sa

View File

@ -0,0 +1,34 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: script-config-plugins
data:
poststart-plugins.sh: |
#!/bin/sh
set -eu
(
if ! flock -n 7; then
echo "Another process is installing plugins. waiting"
flock 7
exit 0
fi
echo "Installing default apps"
plugin_list="${NEXTCLOUD_PLUGIN_LIST}"
OPTS=""
occ="/var/www/html/occ"
installed_apps=$(mktemp)
/bin/sh -c "${occ} app:list" | awk '!/Enabled|Disabled/ {print substr($2, 1, length($2)-1)}' > "${installed_apps}"
for plugin in ${plugin_list}; do
if ! grep -q "${plugin}" "${installed_apps}"; then
/bin/sh -c "${occ} ${OPTS} app:install ${plugin}"
/bin/sh -c "${occ} ${OPTS} app:update ${plugin}"
/bin/sh -c "${occ} ${OPTS} app:enable ${plugin}"
else
echo "${plugin} allready installed"
fi
done
) 7> /var/www/html/nextcloud-plugin-install.lock
echo "Apps installation finished"