Merge claude/2
This commit is contained in:
commit
a6ae380aa7
@ -13,5 +13,6 @@ CFG_REQUIREMENT_CONFIGS_AUTO_UPDATE=true # Auto Config Updates -
|
|||||||
CFG_REQUIREMENT_CONFIGS_AUTO_DELETE=true # Auto Config Deletes - Remove config options no longer present in the template
|
CFG_REQUIREMENT_CONFIGS_AUTO_DELETE=true # Auto Config Deletes - Remove config options no longer present in the template
|
||||||
CFG_REQUIREMENT_MISSING_IPS=false # IP Configuration Check - Check for and alert about missing IP configurations
|
CFG_REQUIREMENT_MISSING_IPS=false # IP Configuration Check - Check for and alert about missing IP configurations
|
||||||
CFG_REQUIREMENT_CONTINUE_PROMPT=false # Continue Prompts - Show continue prompts during installation for user confirmation
|
CFG_REQUIREMENT_CONTINUE_PROMPT=false # Continue Prompts - Show continue prompts during installation for user confirmation
|
||||||
|
CFG_REQUIREMENT_CONTINUE_ON_ERROR=true # Continue On Error - Log failures to error_report.log and continue instead of aborting (on by default to surface issues; turn off for strict abort once clean)
|
||||||
CFG_REQUIREMENT_SUGGEST_INSTALLS=false # Install Suggestions - Enable application suggestions and recommendations during installation
|
CFG_REQUIREMENT_SUGGEST_INSTALLS=false # Install Suggestions - Enable application suggestions and recommendations during installation
|
||||||
CFG_REQUIREMENT_SUGGEST_METRICS=true # Metrics Suggestions - Offer Prometheus and Grafana during first install (requires Install Suggestions enabled)
|
CFG_REQUIREMENT_SUGGEST_METRICS=true # Metrics Suggestions - Offer Prometheus and Grafana during first install (requires Install Suggestions enabled)
|
||||||
|
|||||||
@ -1,22 +1,54 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
# checkSuccess "message" — report on the exit status of the PRECEDING command.
|
||||||
|
#
|
||||||
|
# IMPORTANT for callers: $? must still be the command's exit when this is called.
|
||||||
|
# `local VAR=$(cmd); checkSuccess ...` is a BUG — the `local`/`declare` builtin
|
||||||
|
# resets $? to 0, masking the command's real failure. Use `local VAR; VAR=$(cmd)`
|
||||||
|
# (split declaration from assignment) so $? survives.
|
||||||
|
#
|
||||||
|
# On failure this ALWAYS records the failure to a greppable error report
|
||||||
|
# ($logs_dir/error_report.log) with the caller's script:line + exit code, so a
|
||||||
|
# failure can never hide behind a green check again. Then it either continues
|
||||||
|
# (CFG_REQUIREMENT_CONTINUE_ON_ERROR=true, the default — surface every issue in a
|
||||||
|
# single pass) or falls back to the strict abort/prompt behaviour when that's off.
|
||||||
function checkSuccess()
|
function checkSuccess()
|
||||||
{
|
{
|
||||||
if [ $? -eq 0 ]; then
|
local rc=$?
|
||||||
isSuccessful "$1"
|
local msg="$1"
|
||||||
if [ -f "$logs_dir/$docker_log_file" ]; then
|
|
||||||
echo "✓ Success $1" | runInstallWrite -a "$logs_dir/$docker_log_file" >/dev/null
|
|
||||||
fi
|
|
||||||
else
|
|
||||||
isError "$1"
|
|
||||||
|
|
||||||
# Non-interactive (task processor / cron / piped): bail instead of
|
if [ "$rc" -eq 0 ]; then
|
||||||
# blocking on read.
|
isSuccessful "$msg"
|
||||||
if [[ "$LIBREPORTAL_NONINTERACTIVE" == "1" ]] || [ ! -t 0 ]; then
|
|
||||||
if [ -f "$logs_dir/$docker_log_file" ]; then
|
if [ -f "$logs_dir/$docker_log_file" ]; then
|
||||||
isError " $1" | runInstallWrite -a "$logs_dir/$docker_log_file" >/dev/null
|
echo "✓ Success $msg" | runInstallWrite -a "$logs_dir/$docker_log_file" >/dev/null
|
||||||
echo "===================================" | runInstallWrite -a "$logs_dir/$docker_log_file" >/dev/null
|
|
||||||
fi
|
fi
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ---- failure ----
|
||||||
|
isError "$msg"
|
||||||
|
|
||||||
|
# Record EVERY failure to a dedicated, greppable report (manager-owned logs),
|
||||||
|
# tagged with the caller's script:line + exit code. Best-effort; never aborts.
|
||||||
|
local _where="${BASH_SOURCE[1]##*/}:${BASH_LINENO[0]}"
|
||||||
|
local _stamp; _stamp="$(date '+%F %T' 2>/dev/null || echo now)"
|
||||||
|
printf '%s\t[exit %s]\t%s\t(%s)\n' "$_stamp" "$rc" "$msg" "$_where" \
|
||||||
|
| runInstallWrite -a "$logs_dir/error_report.log" 2>/dev/null || true
|
||||||
|
if [ -f "$logs_dir/$docker_log_file" ]; then
|
||||||
|
isError " $msg (exit $rc, $_where)" | runInstallWrite -a "$logs_dir/$docker_log_file" >/dev/null 2>&1 || true
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Continue-on-error (default true): log and carry on so a single failure
|
||||||
|
# doesn't abort the whole run and we surface EVERY issue in one pass. Turn
|
||||||
|
# CFG_REQUIREMENT_CONTINUE_ON_ERROR off for strict abort once things are clean.
|
||||||
|
if [[ "${CFG_REQUIREMENT_CONTINUE_ON_ERROR:-true}" == "true" ]]; then
|
||||||
|
isNotice "continue-on-error: logged to $logs_dir/error_report.log — continuing."
|
||||||
|
return 0
|
||||||
|
fi
|
||||||
|
|
||||||
|
# ---- strict mode (continue-on-error off) ----
|
||||||
|
# Non-interactive (task processor / cron / piped): bail instead of blocking.
|
||||||
|
if [[ "$LIBREPORTAL_NONINTERACTIVE" == "1" ]] || [ ! -t 0 ]; then
|
||||||
isNotice "Non-interactive mode: aborting on error."
|
isNotice "Non-interactive mode: aborting on error."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@ -24,30 +56,13 @@ function checkSuccess()
|
|||||||
while true; do
|
while true; do
|
||||||
isQuestion "An error has occurred. Do you want to continue, exit or go to back to the Menu? (c/x/m) "
|
isQuestion "An error has occurred. Do you want to continue, exit or go to back to the Menu? (c/x/m) "
|
||||||
read -rp "" error_occurred
|
read -rp "" error_occurred
|
||||||
if [[ -n "$error_occurred" ]]; then
|
[[ -n "$error_occurred" ]] && break
|
||||||
break
|
|
||||||
fi
|
|
||||||
isNotice "Please provide a valid input."
|
isNotice "Please provide a valid input."
|
||||||
done
|
done
|
||||||
|
|
||||||
if [[ "$error_occurred" == [cC] ]]; then
|
[[ "$error_occurred" == [cC] ]] && isNotice "Continuing after error has occurred."
|
||||||
isNotice "Continuing after error has occurred."
|
[[ "$error_occurred" == [xX] ]] && exit 1
|
||||||
fi
|
if [[ "$error_occurred" == [mM] && "$initial_command2" == "terminal" ]]; then
|
||||||
|
resetToMenu
|
||||||
if [[ "$error_occurred" == [xX] ]]; then
|
|
||||||
# Log the error output to the log file
|
|
||||||
isError " $1" | runInstallWrite -a "$logs_dir/$docker_log_file"
|
|
||||||
echo "===================================" | runInstallWrite -a "$logs_dir/$docker_log_file"
|
|
||||||
exit 1 # Exit the script with a non-zero status to stop the current action
|
|
||||||
fi
|
|
||||||
|
|
||||||
if [[ "$error_occurred" == [mM] ]]; then
|
|
||||||
# Log the error output to the log file
|
|
||||||
isError " $1" | runInstallWrite -a "$logs_dir/$docker_log_file"
|
|
||||||
echo "===================================" | runInstallWrite -a "$logs_dir/$docker_log_file"
|
|
||||||
if [[ "$initial_command2" == "terminal" ]]; then
|
|
||||||
resetToMenu;
|
|
||||||
fi
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user