feat(installer): show croc log-send TUI on install error

On any ERR, both installers now trap the failure, log the line/exit
code, and pop a dialog yes/no asking whether to send the log to another
system via croc. Falls back to a plain read prompt if dialog is absent.
Added dialog and croc to packages.extra so they are present in the live ISO.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
main
Amir Alexander Abdelbaki 2026-05-21 19:28:43 +02:00
parent 319af7bde7
commit a0a2b66ccf
3 changed files with 88 additions and 2 deletions

View File

@ -7,7 +7,7 @@
# Answerfile fields: drive, kernel, keymap, hostname, username, encrypt, fido2_root,
# fido2_user, run_tui (password always prompted interactively)
set -euo pipefail
set -Eeuo pipefail
############################################
# LOGGING
@ -22,6 +22,48 @@ LOGFILE="$HOME/arch-autoinstall.log"
} >> "$LOGFILE"
exec > >(tee -a "$LOGFILE") 2>&1
############################################
# Error handler — TUI prompt to send log via croc
############################################
error_handler() {
local exit_code=$? line_num="${1:-?}"
echo "" >> "$LOGFILE"
echo "ERROR: installer failed at line $line_num (exit code $exit_code)" >> "$LOGFILE"
if command -v dialog &>/dev/null; then
if dialog --clear --title " Installer Error " \
--yesno \
"Installation failed at line $line_num (exit code: $exit_code).\n\nSend the log to another system via croc for analysis?" \
9 62; then
clear
if ! command -v croc &>/dev/null; then
echo "Installing croc..."
pacman -Sy --noconfirm croc 2>/dev/null || true
fi
if command -v croc &>/dev/null; then
croc send "$LOGFILE"
else
echo "croc unavailable — log is at: $LOGFILE"
fi
else
clear
echo "Log saved to: $LOGFILE"
fi
else
echo ""
echo "Installation failed at line $line_num (exit code $exit_code)."
read -rp "Send log via croc? [y/N]: " _croc_ans
if [[ "${_croc_ans,,}" == "y" ]]; then
command -v croc &>/dev/null || pacman -Sy --noconfirm croc 2>/dev/null || true
croc send "$LOGFILE" || true
else
echo "Log saved to: $LOGFILE"
fi
fi
exit "$exit_code"
}
trap 'error_handler $LINENO' ERR
############################################
# ANSWERFILE
############################################

View File

@ -4,7 +4,7 @@
# If /answerfile.json exists (e.g. embedded via build.sh --preconf), all prompts
# are answered from it. Missing fields fall back to interactive prompts.
set -euo pipefail
set -Eeuo pipefail
############################################
# LOGGING
@ -19,6 +19,48 @@ LOGFILE="$HOME/archbaseos-guided-install.log"
} >> "$LOGFILE"
exec > >(tee -a "$LOGFILE") 2>&1
############################################
# Error handler — TUI prompt to send log via croc
############################################
error_handler() {
local exit_code=$? line_num="${1:-?}"
echo "" >> "$LOGFILE"
echo "ERROR: installer failed at line $line_num (exit code $exit_code)" >> "$LOGFILE"
if command -v dialog &>/dev/null; then
if dialog --clear --title " Installer Error " \
--yesno \
"Installation failed at line $line_num (exit code: $exit_code).\n\nSend the log to another system via croc for analysis?" \
9 62; then
clear
if ! command -v croc &>/dev/null; then
echo "Installing croc..."
pacman -Sy --noconfirm croc 2>/dev/null || true
fi
if command -v croc &>/dev/null; then
croc send "$LOGFILE"
else
echo "croc unavailable — log is at: $LOGFILE"
fi
else
clear
echo "Log saved to: $LOGFILE"
fi
else
echo ""
echo "Installation failed at line $line_num (exit code $exit_code)."
read -rp "Send log via croc? [y/N]: " _croc_ans
if [[ "${_croc_ans,,}" == "y" ]]; then
command -v croc &>/dev/null || pacman -Sy --noconfirm croc 2>/dev/null || true
croc send "$LOGFILE" || true
else
echo "Log saved to: $LOGFILE"
fi
fi
exit "$exit_code"
}
trap 'error_handler $LINENO' ERR
############################################
# Helper Functions
############################################

View File

@ -6,3 +6,5 @@ libfido2
btop
fastfetch
openssh
dialog
croc