docker-mailserver / docker-mailserver-helm

Kubernetes Helm chart for docker-mailserver
https://github.com/docker-mailserver/docker-mailserver/
MIT License
107 stars 67 forks source link

Add support for user-patches.sh #56

Closed RangaSamudrala closed 9 months ago

RangaSamudrala commented 2 years ago

While using this helm chart, I have encountered permissions issues. For example, during startup, the script sets ownership of /var/mail to 5000:5000 (docker:docker). This results in sieve scripts to fail with permission issues. There is an article about being able to fix these kinds of issues using user_patches . The default user-patch script looks as documented here. Some thing like

#! /bin/bash
##
# This user patches script runs right before starting the daemons. That means, all the other configuration is in place, so the script can make final adjustments.
# If you modify any supervisord configuration, make sure to run "supervisorctl update" or "supervisorctl reload" afterwards.
# To enable the script, you must save it in your config directory as "user-patches.sh".
##
echo "Default user-patches.sh successfully executed"

We should provide support for this in helm chart. Logic should be similar to how it is for am-i-healthy.sh in the file configmap.yaml.

The user should then be able to override these using values.

RangaSamudrala commented 2 years ago

In the file configmap.yaml, we add the below section:


  {{ if .Values.userPatches }}
  {{- if .Values.userPatches.enabled }}
  user-patches.sh: |
    #!/bin/bash
    ##
    # This user patches script runs right before starting the daemons. That means, all the other configuration is in place, so the script can make final adjustments.
    # If you modify any supervisord configuration, make sure to run "supervisorctl update" or "supervisorctl reload" afterwards.
    # To enable the script, you must save it in your config directory as "user-patches.sh".
    ##
    {{- range .Values.userPatches.commands }}
    {{ . }} && \
    {{- end }}
    echo "user-patches.sh successfully executed"
  {{- end }}
  {{- end }}

In values.yaml, we add the below section:

userPatches:
  enabled: false
  commands: []
funkypenguin commented 2 years ago

That sounds like a good improvement :) Would you be willing to submit a PR?

RangaSamudrala commented 2 years ago

I have zero experience submitting a PR in an open source project. I presume this also requires writing test cases, etc. I will look into but will take time.

cfis commented 9 months ago

Yes, you can do this now by adding it to a mail-config volume. See https://github.com/docker-mailserver/docker-mailserver-helm/blob/master/charts/docker-mailserver/README.md#volume