Closed rcknr closed 4 months ago
Thanks for the PR! Can you describe your case with CI? What was the problem exactly? Can it be solved by renaming the variable used in this script?
In my CI script I had docker rollout $SERVICE
so I can re-use it for multiple services. This failed because the script only checks only for variable existence not content. In my opinion, renaming won't solve the issue in the same way like a simple check I've added.
I'm not sure we want to maintain full POSIX sh compatibility (see shellcheck output below). Especially process substitution, which requires the use of temporary files as shown here: https://www.shellcheck.net/wiki/SC3001.
In fact, in alpine
images the default available shell is ash
, which implements some of the bash features (e.g. [[
). So after changing the shebang from #!/bin/bash
to #!/bin/sh
this script will not work on devices with POSIX-compatible /bin/sh
if we don't fix everything that shellcheck suggests.
What about merging this PR, but leaving the #!/bin/bash
shebang? This way we can have unofficial support for ash, requiring users to change /bin/bash
to /bin/ash
or /bin/sh
.
Changes required are quite straight-forward, so I have updated the code to fix Shellcheck warnings.
I have updated and tested the script: everything appears to be working right. Please have a look.
Closes #19
Because the official
docker
images are based on alpine and don't come withbash
installed, it makes sense to use busybox's shell to run the script. Alsogrep
options are adjusted to be compatible with the version available in alpine. This addresses the issue #19.Also, I have added an additional check for
$SERVICE
variable to see if it equals the first argument provided. This is to address a use case I had in my CI where the service name is provided with a variable and led to an error.