fix clamav permissions

Signed-off-by: Simon L <szaimen@e.mail.de>
This commit is contained in:
Simon L 2023-11-21 12:00:51 +01:00
parent ec33279209
commit feec123292
3 changed files with 39 additions and 6 deletions

View file

@ -1,6 +1,6 @@
name: nextcloud-aio-helm-chart
description: A generated Helm Chart for Nextcloud AIO from Skippbox Kompose
version: 7.7.0-beta3
version: 7.7.0-beta4
apiVersion: v2
keywords:
- latest

View file

@ -24,11 +24,22 @@ spec:
io.kompose.service: nextcloud-aio-clamav
spec:
initContainers:
- name: init-subpath
image: alpine
command:
- mkdir
- "-p"
- /nextcloud-aio-clamav/data
- /nextcloud-aio-clamav
volumeMounts:
- name: nextcloud-aio-clamav
mountPath: /nextcloud-aio-clamav
- name: init-volumes
image: alpine
command:
- chmod
- "777"
- chown
- 100:100
- "-R"
- /nextcloud-aio-clamav
volumeMounts:
- name: nextcloud-aio-clamav
@ -46,6 +57,7 @@ spec:
protocol: TCP
volumeMounts:
- mountPath: /var/lib/clamav
subPath: data
name: nextcloud-aio-clamav
volumes:
- name: nextcloud-aio-clamav

View file

@ -81,15 +81,34 @@ cat << EOL > /tmp/initcontainers.database
- "-R"
volumeMountsInitContainer:
EOL
cat << EOL > /tmp/initcontainers.clamav
initContainers:
- name: init-subpath
image: alpine
command:
- mkdir
- "-p"
- /nextcloud-aio-clamav/data
volumeMountsInitContainer:
- name: init-volumes
image: alpine
command:
- chown
- 100:100
- "-R"
volumeMountsInitContainer:
EOL
# shellcheck disable=SC1083
DEPLOYMENTS="$(find ./ -name '*deployment.yaml')"
mapfile -t DEPLOYMENTS <<< "$DEPLOYMENTS"
for variable in "${DEPLOYMENTS[@]}"; do
if grep -q volumeMounts "$variable"; then
if ! echo "$variable" | grep -q database; then
sed -i "/^ spec:/r /tmp/initcontainers" "$variable"
else
if echo "$variable" | grep -q database; then
sed -i "/^ spec:/r /tmp/initcontainers.database" "$variable"
elif echo "$variable" | grep -q clamav; then
sed -i "/^ spec:/r /tmp/initcontainers.clamav" "$variable"
else
sed -i "/^ spec:/r /tmp/initcontainers" "$variable"
fi
volumeNames="$(grep -A1 mountPath "$variable" | grep -v mountPath | sed 's|.*name: ||' | sed '/^--$/d')"
mapfile -t volumeNames <<< "$volumeNames"
@ -101,6 +120,8 @@ for variable in "${DEPLOYMENTS[@]}"; do
# Workaround for the database volume
if [ "$volumeName" = nextcloud-aio-database ]; then
sed -i "/mountPath: \/var\/lib\/postgresql\/data/a\ \ \ \ \ \ \ \ \ \ \ \ \ \ subPath: data" "$variable"
elif [ "$volumeName" = nextcloud-aio-clamav ]; then
sed -i "/mountPath: \/var\/lib\/clamav/a\ \ \ \ \ \ \ \ \ \ \ \ \ \ subPath: data" "$variable"
fi
fi