-
-
Notifications
You must be signed in to change notification settings - Fork 2.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Display more meaningful exit message if dig
command fails during os_check
#3702
Conversation
Got some more stuff to do here... |
This comment has been minimized.
This comment has been minimized.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This runs the identical dig
two times and wouldn't catch it the second fails. I wonder if we should, instead, rather check for an invalid or empty response from
output="$(dig +short -t txt versions.pi-hole.net @ns1.pi-hole.net)"
rather than trying to extract the exact exit code?
In this case, we could show what was returned ("expired"
, empty or whatever) and still catch the error.
This comment has been minimized.
This comment has been minimized.
We could maybe simply redirect Example: $ out="$(dig +short -t txt versions.pi-hole.net @use-application-dns.net || echo "FAILED")"
dig: couldn't get address for 'use-application-dns.net': not found
$ echo "$out"
FAILED With $ out="$(dig +short -t txt versions.pi-hole.net @use-application-dns.net 2>&1 || echo "FAILED")"
[no output]
$ echo "$out"
dig: couldn't get address for 'use-application-dns.net': not found
FAILED Also: $ out="$(dig +short -t txt versions.pi-hole.net @1.2.3.4 2>&1 || echo "FAILED")"
[no output]
$ echo "$out"
;; connection timed out; no servers could be reached
FAILED Note: |
In the case of a failure, we only want the "failed" part (or more helpfully, just the exit code). Hence the double-hit of the function. With the 2>&1 it is nice because it hides the error message from immediate display, but we don't want the error message in the variable :) Otherwise we are in the territory of string comparison for actual error messages, which obviously will cause issues internationally |
I was thinking more along the lines of doing exactly this out="$(dig +short -t txt versions.pi-hole.net || echo "FAILED")"
# last line should be
echo "${out##*$'\n'}"
# or
echo "$out" | tail -n1
# Test based on these lines being == "FAILED"
# Only run loop if this is not the case!
while IFS= read -r line; do
# Check if $line is empty, in this case, break out of the loop and print some error?
echo "... $line ..."
done <<< "$out" Sorry, I don't have a Pi-hole with me right now or I'd propose a more working code for you. I'm just thinking out aloud here, trusting you will do something amazing with it :-) |
Hold my beer... |
results:
OK, I should be able to work with this, just need to check if the result is a number. According to this page it should only be one of 5 numbers:
|
21c7095
to
9e8187d
Compare
Include dig return code and response in debug run Signed-off-by: Adam Warner <me@adamwarner.co.uk>
9e8187d
to
8e219cb
Compare
This pull request has been mentioned on Pi-hole Userspace. There might be relevant details there: |
advanced/Scripts/piholeDebug.sh
Outdated
|
||
# Dig returned 0 code, so get the actual response, and loop through it to determine if the detected variables above are valid |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This comment is wrong here (copy-paste from the installer)
Co-authored-by: DL6ER <DL6ER@users.noreply.github.com>
Signed-off-by: Adam Warner <me@adamwarner.co.uk>
This pull request has been mentioned on Pi-hole Userspace. There might be relevant details there: https://discourse.pi-hole.net/t/pi-hole-core-web-v5-2-and-ftl-v5-3-released/40909/1 |
By submitting this pull request, I confirm the following:
git rebase
)What does this PR aim to accomplish?:
Fixes #3694
Alternative to #3695
Outputs as following:
Note: I couldn't be bothered with the rigmaroll of blocking outbound port 53 on my network so I changed the
@ns1.pi-hole.net
to@ns141@pi-hole.net
to simulate being unable to resolve@ns1.pi-hole.net