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
function _defunc removed #2199
function _defunc removed #2199
Conversation
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.
LGTM 👍🏼
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.
LGTM 👍
I see a common pattern though with the "Failed to start.." lines. In some cases the original || _defunc
handled in the loop could have been kept to call _shutdown
, although I guess that's more complicated/hassle in shell scripts to reference the service index/key :/
Could still be a good case for adding a new panic type to replace the _shutdown
calls as this is kind of what it's intended for (repetition and re-use across scripts with common error messages):
function dms_panic
{
# ...
( 'fail-init' ) # PANIC_INFO == <name of service or process that failed to start / initialize>
SHUTDOWN_MESSAGE="Failed to start ${PANIC_INFO}!"
;;
# ...
}
function dms_panic__fail_init { dms_panic 'fail-init' "${1}" "${2}"; }
The other two variants "Failed to fix" / "Failed to remove" may not benefit as much atm 🤷♂️
I don't mind either way with _shutdown
as is, or adopting dms_panic
like above.
_notify 'task' 'Cleaning up disabled ClamAV' | ||
rm /etc/logrotate.d/clamav-* /etc/cron.d/clamav-freshclam || _shutdown 'Failed to remove ClamAV configuration' | ||
} | ||
|
||
function _fix_cleanup_spamassassin | ||
{ | ||
_notify 'task' 'Cleaning up disabled SpamAssassin' | ||
rm -f /etc/cron.daily/spamassassin | ||
rm /etc/cron.daily/spamassassin || _shutdown 'Failed to remove SpamAssassin configuration' |
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.
Is there a reason for dropping -f
on rm
calls?
-f
,--force
ignore nonexistent files and arguments, never prompt
I understand that usually docker-mailserver
isn't run with an interactive terminal, and prompting probably doesn't happen in that case, but is it desirable to be prompted when using something like docker run -it
? We usually only do docker run -t
if not using compose commands.
Without -f
that also implies it'll error if the file does not exist, which in this context doesn't seem like it should be a concern to throw such an error?
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.
When using -f
, rm
will never fail (exit 1), which makes testing for success pointless.
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.
it'll error if the file does not exist
This should never be the case when using the images we provide?
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 should never be the case when using the images we provide?
🤷♂️ haven't looked into it myself, I guess we'll know soon enough 😂
Is the other concern about being prompted when using docker ... -it
a misunderstanding on my part too?
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.
rm <file>
never prompts for confirmation. However, many Linux distributions ship with some default aliases like:
alias rm='rm -i' # prompt before every removal
alias cp='cp -i' # prompt before overwrite
PS: Aliases do not work in shell scripts. So it doesn't matter if they exist or not when running a shell script.
Did you also want to add |
In most cases,
You'll only see the "something went wrong" output, if the last echo command in that functions fails. Pretty pointless if you ask me. Therefore I've added the extra _shutdown calls explicitly to operations, where I thought they are important. Ideally, we should This PR should only obsolete |
Nope. If someone wants to add it - okay. But I don't see a reason for it (see my comment there). We shouldn't start, providing default settings on the command line. |
89be9f3
This sounds good (the functionality, my shell-fu doesn't recall that incantation that well), I suppose it might make sense to do that as early as possible during init scripts? |
Yes. But keep in mind, it's not just putting the line on top of the script. The script itself may need some adjustments. Every command that is expected to fail for whatever reasons, must be catched or the script will fail. this-command-may-fail-or-not-we-dont-care || true This allows the rest of the script to continue. Otherwise, in "strict mode" the script will exit on the first failed command. |
At the moment, I'd advise against using |
The test failed 😞
|
The failed test does not seem to be related to this PR, as it was successful in the past. Edit: I've restarted the test. |
I was seeing multiple issues with this test too, unrelated to any of my changes. Disable it too? |
Description
Follow up PR as discussed in #2196
This removes the function
_defunc
, which probably never worked as intended._defunc
calls were replaced by_shutdown
.Fixes #
Type of change
Checklist:
docs/
)