piholeDebug: Fix warning if lighttpd/php are not installed #3902
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
By submitting this pull request, I confirm the following:
git rebase
)What does this PR aim to accomplish?:
If the installation is done without web interface lighttpd and php are typically missing on the system. The
piholeDebug.sh
script tries to detect that but fails to do so properly. The current output looks like this:This is fixed by adjusting the commands to retrieve the versions of lighttpd and php.
How does this PR accomplish the above?:
This is a bit a tricky one as I have to admit that I don't fully understand what's going wrong here and that it might even be something that is depending on the version of bash. I observed this behaviour on CentOS 8 with
bash-4.4.19-10.el8
and on Gentoo withbash-5.0_p18
.When running the section in debug mode the output (e.g. for the lighttpd) check shows:
Lightthpd obviously is not installed so a plain version check would result in the following output (on stderr):
It looks like the pipefail option that is globally set doesn't play well with the merging of stdout/stderr
|&
. It looks like bash is not stopping when the lighttpd command failed and continues parsing some mysterious strings. I didn't figure out where these 'opt' and 'line' strings which will be assigned to theprogram_version
variable are coming from. They are certainly not leaking from any previous code as the variable is only defined above and local to the function.The simplest change that was fixing the issue for me was to simply get rid of the output merging and suppress stderr (the "command not found" message). lighttpd as well as php print the version information to stdout on the systems that I tested. With the proposed patch the behaviour looks again as intended:
Eventually the version check output then looks as following:
I don't assume that there are lighttpd/php versions that are printing their version to stderr so I'm asking for feedback. If there would be, this change would obviously introduce a regression for those systems which won't be able to detect a properly installed lighttpd or php version anymore.
Alternatively I could just rewrite the version check logic to only be executed if the command exists.
What documentation changes (if any) are needed to support this PR?:
None