fix: inlude symlinks in scanning for init scripts

When the `/container-init.d` directory is mounted from a secret in k8s, the file type could be a symbolic link not a regular file.

Steps to reproduce:

Create init file

```bash
mkdir ipfs-container-init-d
echo "ipfs config Routing.Type dhtserver" > ipfs-container-init-d/01_init.sh
```

Create this kustomization.yaml file:

```yaml
apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
configMapGenerator:
- name: ipfs-container-init-d
  files:
    - ipfs-container-init-d/01_init.sh
resources:
- k8s.yaml
```

Create a StatefulSet with the secret volume mount:

```yaml
apiVersion: apps/v1
kind: StatefulSet
metadata:
  name: ipfs
spec:
  selector:
    matchLabels:
      app: ipfs
  replicas: 1
  template:
    metadata:
      labels:
        app: ipfs
    spec:
      containers:
      - name: kubo
        image: ipfs/kubo:v0.38.2  # https://github.com/ipfs/kubo/releases/tag/v0.38.2
        ports:
        - containerPort: 4001
          protocol: TCP
        - containerPort: 4001
          protocol: UDP
        - containerPort: 5001
        - containerPort: 8080
        volumeMounts:
        - name: ipfs-container-init-d
          mountPath: /container-init.d
      volumes:
      - name: ipfs-container-init-d
        configMap:
          name: ipfs-container-init-d
```

Apply with `kubectl apply -k .`

Using `kubectl logs` observe the init script is NOT loaded unless this fix is applied.
This commit is contained in:
Filip Rembiałkowski 2025-11-25 23:10:34 +01:00
parent 2844a913d3
commit 8391232c24
No known key found for this signature in database

View File

@ -50,6 +50,6 @@ else
unset IPFS_SWARM_KEY_FILE
fi
find /container-init.d -maxdepth 1 -type f -iname '*.sh' -print0 | sort -z | xargs -n 1 -0 -r container_init_run
find /container-init.d -maxdepth 1 \( -type f -o -type l \) -iname '*.sh' -print0 | sort -z | xargs -n 1 -0 -r container_init_run
exec ipfs "$@"