Skip to content

PR #2095 broke post-installation scripts in k8s #2114

@Sad-Soul-Eater

Description

@Sad-Soul-Eater

In PR #2095, the next line was added:

find "${hook_folder_path}" -type f -maxdepth 1 -iname '*.sh' -print | sort | while read -r script_file_path; do

The main problem is in the -type f filter because Kubernetes mounts ConfigMap as a directory with symlinks, not files, thus leading to to incapability of the find utility to find scripts because of the -type f filter.

This issue can be fixed by changing the -type f filter to -type f,l. I tested the entrypoint.sh that includes this change - it working as expected.

Nextcloud deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
  name: &app nextcloud
  labels:
    app: *app
spec:
  replicas: 1

  strategy:
    type: Recreate

  selector:
    matchLabels:
      app: *app

  template:
    metadata:
      labels:
        app: *app

    spec:
      containers:
        - name: nextcloud
          image: nextcloud:27.1.4-apache

          volumeMounts:
            - name: nextcloud-scripts-post-installation
              mountPath: /docker-entrypoint-hooks.d/post-installation

      volumes:
        - name: nextcloud-scripts-post-installation
          configMap:
            name: nextcloud-scripts-post-installation
            defaultMode: 0555
/docker-entrypoint-hooks.d/post-installation content
root@nextcloud-596db956c4-bs2rd:/docker-entrypoint-hooks.d/post-installation# ls -lah
total 4.0K
drwxrwsrwx 3 root www-data 4.0K Dec  5 09:38 .
drwxr-xr-x 7 root root      117 Nov 28 18:29 ..
drwxr-sr-x 2 root www-data  164 Dec  5 09:38 ..2023_12_05_09_38_13.2954059579
lrwxrwxrwx 1 root www-data   32 Dec  5 09:38 ..data -> ..2023_12_05_09_38_13.2954059579
lrwxrwxrwx 1 root www-data   25 Dec  5 09:38 01-disable-apps.sh -> ..data/01-disable-apps.sh
lrwxrwxrwx 1 root www-data   23 Dec  5 09:38 01-oidc-setup.sh -> ..data/01-oidc-setup.sh
lrwxrwxrwx 1 root www-data   20 Dec  5 09:38 01-theming.sh -> ..data/01-theming.sh
lrwxrwxrwx 1 root www-data   27 Dec  5 09:38 02-configure-ldap.sh -> ..data/02-configure-ldap.sh
lrwxrwxrwx 1 root www-data   25 Dec  5 09:38 02-install-apps.sh -> ..data/02-install-apps.sh
lrwxrwxrwx 1 root www-data   32 Dec  5 09:38 99-install-notify-push.sh -> ..data/99-install-notify-push.sh

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions