Skip to content

Switch the init command and lifecycle hook from /bin/sh to /bin/bash - #1060

Open
FrederikNJS wants to merge 1 commit into
Keyfactor:mainfrom
Penneo:fix-script-using-wrong-shell
Open

Switch the init command and lifecycle hook from /bin/sh to /bin/bash#1060
FrederikNJS wants to merge 1 commit into
Keyfactor:mainfrom
Penneo:fix-script-using-wrong-shell

Conversation

@FrederikNJS

Copy link
Copy Markdown

The current scripts are invalid when using /bin/sh. Specifically the [[ syntax is not valid. This syntax is however supported in /bin/bash.

Describe your changes

When running the helm chart, the init container fails to run, and throws as error because the syntax of the command is incorrect for /bin/sh. I have switched the shell to using /bin/bash, where the syntax is correct.

How has this been tested?

We ran the helm chart with the change, and it no longer fails.

Checklist before requesting a review

  • I have performed a self-review of my code
  • I have kept the patch limited to only change the parts related to the patch
  • This change requires a documentation update

See also Contributing Guidelines.

The current scripts are invalid when using /bin/sh. Specifically the `[[` syntax is not valid. This syntax is however supported in /bin/bash.
- "-c"
- |
/opt/keyfactor/bin/start.sh &
until [ -f /opt/keyfactor/appserver/standalone/deployments/ejbca.ear.deployed ]; do sleep 5; done

@FrederikNJS FrederikNJS Jul 14, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not valid in /bin/sh, but is in /bin/bash.

{{- end }}
{{- if and (hasKey .Values.ejbca "superadminPasswordOverride") (eq .Values.ejbca.env.TLS_SETUP_ENABLED "true") }}
until [ -f /opt/keyfactor/appserver/standalone/deployments/ejbca.ear.deployed ]; do sleep 5; done
until [[ $(/opt/keyfactor/bin/ejbca.sh roles listadmins --role "Super Administrator Role" | grep -v 'USERNAME TYPE_EQUALCASE "ejbca"') ]]; do sleep 5; done

@FrederikNJS FrederikNJS Jul 14, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not valid in /bin/sh, but is in /bin/bash.

@primetomas

Copy link
Copy Markdown
Collaborator

Thanks for the contribution. Instead of changing to /bin/bash, is it not better to modify the syntax to be compatible with simpler shells? I.e. what base OS where you using to discover this? If the container base is switched something so slim it doesn't have bash it sounds better to modify the [[ lines? (I suck at shell script so I'm not evaluating how hard that is).

@primetomas

Copy link
Copy Markdown
Collaborator

You are building an own container right? In the official container /bin/sh is linked to /bin/bash so there should be no issue there. What container OS are you using where this is an issue?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants