diff --git a/setup/arch-autoinstall.sh b/setup/arch-autoinstall.sh index e1ab659..722e1a2 100755 --- a/setup/arch-autoinstall.sh +++ b/setup/arch-autoinstall.sh @@ -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 ############################################ diff --git a/setup/archbaseos-guided-install.sh b/setup/archbaseos-guided-install.sh index f30024d..798f9a2 100755 --- a/setup/archbaseos-guided-install.sh +++ b/setup/archbaseos-guided-install.sh @@ -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 ############################################ diff --git a/setup/archiso/overlay/packages.extra b/setup/archiso/overlay/packages.extra index 0522978..38885e7 100644 --- a/setup/archiso/overlay/packages.extra +++ b/setup/archiso/overlay/packages.extra @@ -6,3 +6,5 @@ libfido2 btop fastfetch openssh +dialog +croc