armbian-next: split of config-prepare into multiple functions, allowing for logging of all non-interactive sections

- introduce `do_with_conditional_logging()` which only starts logging sections if `do_logging=no`
- with this we should get complete logs (ofc except for the interactive sections)
This commit is contained in:
Ricardo Pardini
2023-01-05 11:56:10 +01:00
parent 61d4691e09
commit f167864f2c
7 changed files with 129 additions and 74 deletions

View File

@@ -120,10 +120,21 @@ function do_with_logging() {
function do_with_logging_unless_user_terminal() {
# Is user on a terminal? If so, don't log, just show on screen.
if [[ -t 1 ]]; then
display_alert "User is on a terminal, not logging output" "terminal" "debug"
display_alert "User is on a terminal, not logging output" "do_with_logging_unless_user_terminal" "debug"
"$@"
else
display_alert "User is not on a terminal, logging output" "terminal" "debug"
display_alert "User is not on a terminal, logging output" "do_with_logging_unless_user_terminal" "debug"
do_with_logging "$@"
fi
}
function do_with_conditional_logging() {
# if "do_logging=no", just run the command, otherwise, log it.
if [[ "${do_logging:-"yes"}" == "no" ]]; then
display_alert "do_logging=no, not starting logging section" "do_with_conditional_logging" "debug"
"$@"
else
display_alert "normally logging output" "do_with_conditional_logging" "debug"
do_with_logging "$@"
fi
}