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
Add err_trap function #2288
Add err_trap function #2288
Conversation
local rc1=0 rc2=0 rc3=0 | ||
tag_output; cp -a $fromDir/pihole.8 $toManDir/man8/pihole.8 >&4 2>&1; rc1=$? | ||
tag_output; cp -a $fromDir/pihole-FTL.8 $toManDir/man8/pihole-FTL.8 >&4 2>&1; rc2=$? | ||
tag_output; cp -a $fromDir/pihole-FTL.conf.5 $toManDir/man5/pihole-FTL.conf.5 >&4 2>&1; rc3=$? |
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.
rc3 appears unused. Verify it or export it.
local toManDir=/usr/local/share/man | ||
local rc1=0 rc2=0 rc3=0 | ||
tag_output; cp -a $fromDir/pihole.8 $toManDir/man8/pihole.8 >&4 2>&1; rc1=$? | ||
tag_output; cp -a $fromDir/pihole-FTL.8 $toManDir/man8/pihole-FTL.8 >&4 2>&1; rc2=$? |
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.
rc2 appears unused. Verify it or export it.
DCO issue is due to a misconfiguration on my end. Is there any way to fix it aside from killing my repo and reinstating it? |
Yes, have a look at https://github.com/pi-hole/pi-hole/wiki/Contributing-to-the-project for the directions on how to fix the signature. |
Signed-off-by: Rob Gill <rrobgill@protonmail.com>
Signed-off-by: Neepawa <github@groupbcl.ca>
Signed-off-by: Neepawa <github@groupbcl.ca>
Signed-off-by: Neepawa <github@groupbcl.ca>
Signed-off-by: Neepawa <github@groupbcl.ca>
We're scheduled for a release coming up rather quickly. We can look again at this after the release and see about solving the merge conflict. |
@dschaper Do you know the current status of this PR? The last comment is almost one year old. |
I don't have any other information about it. |
Hi! I got distracted by some work on Python Markdown, then being released from my employment, then porting a 1980s-era DOS Point of Sale system to Linux. If there's continued interest in this, I can close this pull request, fix up the conflicts against the most recent branch, and submit a new request. Or can I do that work on this PR? |
@Neepawa I really like the output and the level of debugging info this provides. However, I'm a little concerned in how much work has to be done to trigger the code (lots of file redirects and manually calling We are also currently trying to figure out how best to evolve the installation process, and I don't want this work to be lost in that process. It might be best to wait until we know for certain the direction we want to go in before making too many changes to the installer. @pi-hole/core-approvers should also chime in if they have any other thoughts. |
Sorry, this fell by the wayside again. I think the overall consensus was that it is a good addition to the code, there was just uncertainty on which direction we were headed with the install process. To be honest, I don't see any major changes happening for a while, any ideas we have floated internally are the "ideal" situation, and I personally don't think any of us really have the time to put into such a major overhaul of the install script at this time. With that said: @Neepawa Would you mind fixing up some of the merge conflicts so that we can test this against current 5.0 code? |
I was reminded of this PR by some threads in the forum. Currently, especially due to Of course one can try to handle all cases, check for the existence of every command before executing it, else print a reasonable error message, like suggested in #3209, but this would cause a very large coding effort (with every change again) and huge amount of code lines. An exit trap is actually the most common and "simple" solution for this. Having that in mind, actually this PR is not the "major overhaul" it looks like. It just forwards commands output to a file and prints the content + call stack back when the command fails. It just looks like a large change because of the many changed code lines. What I suggest is indeed implementing such an ERR trap, probably even an EXIT trap, which includes regular exit and interrupts (user hitting ctrl+c) but make any related code change (other then the trap definition) optional to avoid the need to implement it (correctly) for every single command and when doing any changes to the script. The issue currently is that the trap prints the last entry of the implemented file descriptor without knowing if it was actually generated by the failed command or not. Probably it would be less intrusive to create an error handler function to use like There are some code changes when a failed command should only lead to a function return code. Since those cases are already handled, with meaningful output or related actions, IMO calling So final result would be:
|
I'll read this Wall Of Text™ (😉) properly when I have some time later, but just to clarify, I was not talking about this PR when I was mentioning major overhaul. I agree in principle with the PR and think it is a good idea. The major overhaul would be some ideas that have been floated about internally for the direction the install script should head in, but like I say, I don't see it coming to fruition in the near future. So IMHO this PR can land (provided merge conflicts are tidied up) |
Ah okay, sorry for misunderstanding and sorry for the wall of text 😅. The implementation changes above should be reviewed by @Neepawa anyway, probably I've overseen something. Making the actual redirect and print of commands output optional for the error trap to function, is generally a good thing IMO, so there is no strict need to wrap any code around every command call. |
Closing due to inactivity. Feel free to reopen if you want to revive this. |
Signed-off-by: Neepawa github@groupbcl.ca
By submitting this pull request, I confirm the following
contributors guide,
as well as this entire template.
(
git rebase
)What does this PR aim to accomplish?
Fix issue #2252 by providing useful messages to the user if a command run as part of the
base-install.sh
script faile.How does this PR accomplish the above?
The PR implements a new function called
err_trap
, which run whenever an error occurs in a stand-alone command (that is, a commmand that is not part of a pipeline.) Output is similar to the following:Experienced users can use this information to jump-start troubleshooting on problems. Inexperienced users can copy and paste the information to a help forum.
Implementation notes
In order for the command's output to be displayed to the user, it must be redirected to file descriptor 4:
tag_output; command --parameters >&4 2>&1
File descriptor 4 is set up shortly after the installer starts.
The
tag_ouput
call is needed to add__TAG__
to file descriptor 4. This is required because writes to file descriptors are appending, and the__TAG__
lines separate output between commands. Without it, whenerr_trap
runs it would display the output of all prior commands in addition to the one it's reporting on.I added code to terminate the script if
installPihole
fails.Minor cosmetic changes
What documentation changes (if any) are needed to support this PR?
None.