diff --git a/dietpi/func/dietpi-globals b/dietpi/func/dietpi-globals index 5bf8d700da..3fce9d8d85 100644 --- a/dietpi/func/dietpi-globals +++ b/dietpi/func/dietpi-globals @@ -803,27 +803,60 @@ $grey───────────────────────── return "${result:-1}" } - G_BUG_REPORT() { - local dietpi_version="v$G_DIETPI_VERSION_CORE.$G_DIETPI_VERSION_SUB.$G_DIETPI_VERSION_RC ($G_GITOWNER/$G_GITBRANCH)" - local image_creator preimage_name - - if [[ -f '/boot/dietpi/.prep_info' ]]; then - image_creator=$(mawk 'NR==1' /boot/dietpi/.prep_info) - [[ $image_creator == 0 ]] && image_creator='DietPi Core Team' - preimage_name=$(mawk 'NR==2' /boot/dietpi/.prep_info) - fi - - cat < +1. ... +2. ... +#### Expected behaviour: + +- ... +#### Actual behaviour: + +- ... +#### Extra details: + +- ... +#### Additional logs: +```' + # - Add log if given + [[ -f '/tmp/G_EXEC_LOG' ]] && cat '/tmp/G_EXEC_LOG' || echo '' + echo '```' + } #----------------------------------------------------------------------------------- # Error handled command execution wrapper @@ -889,56 +922,17 @@ EOF # Retry non-interactively if current $attempt is <= $G_EXEC_RETRIES [[ $attempt -le $G_EXEC_RETRIES ]] && { ((attempt++)) && continue; } + # Print command output if not done already + [[ $G_EXEC_OUTPUT != 1 ]] && cat "$fp_log" + # Print FAILED, append raw command string if $G_EXEC_DESC is given G_DIETPI-NOTIFY 1 "${G_EXEC_DESC:+$G_EXEC_DESC\n - Command: }$ecommand" # Exit retry loop if $G_EXEC_NOHALT=1 is given [[ $G_EXEC_NOHALT == 1 ]] && break - # Prepare error handler menu and GitHub issue template - local fp_error_report='/tmp/G_EXEC_ERROR_REPORT' log_content=$(<"$fp_log") last_whip_menu_item sent_bug_report - if [[ -f '/boot/dietpi/.prep_info' ]]; then - image_creator=$(mawk 'NR==1' /boot/dietpi/.prep_info) - [[ $image_creator == 0 ]] && image_creator='DietPi Core Team' - preimage_name=$(mawk 'NR==2' /boot/dietpi/.prep_info) - fi - - local dietpi_version="v$G_DIETPI_VERSION_CORE.$G_DIETPI_VERSION_SUB.$G_DIETPI_VERSION_RC ($G_GITOWNER/$G_GITBRANCH)" - local error_details=$(G_BUG_REPORT) - - [[ ${G_PROGRAM_NAME,,} == 'dietpi-'* ]] && echo -e "\e[41m -\e[41m ---------------------------------------------------------------------- -- DietPi has encountered an error - -- Please create a ticket: https://github.com/MichaIng/DietPi/issues - -- Copy and paste only the BLUE lines below into the ticket - ----------------------------------------------------------------------\e[44m -#### Details: -- Date | $(date) -- Command | \`$ecommand\` -- Exit code | $exit_code -- Software title | $G_PROGRAM_NAME -$error_details -#### Steps to reproduce: - -1. ... -2. ... -#### Expected behaviour: - -- ... -#### Actual behaviour: - -- ... -#### Extra details: - -- ... -#### Additional logs: -\`\`\` -$log_content -\`\`\`\e[41m ----------------------------------------------------------------------\e[0m" > "$fp_error_report" - # Enter error handler menu loop in interactive mode + local last_whip_menu_item sent_bug_report fp_error_report='/tmp/G_EXEC_ERROR_REPORT' dietpi_version="v$G_DIETPI_VERSION_CORE.$G_DIETPI_VERSION_SUB.$G_DIETPI_VERSION_RC ($G_GITOWNER/$G_GITBRANCH)" [[ $G_INTERACTIVE == 1 ]] && while : do G_WHIP_MENU_ARRAY=('Retry' ': Re-run the last command that failed') @@ -948,8 +942,12 @@ $log_content pgrep -cf 'dietpi-config' &> /dev/null || G_WHIP_MENU_ARRAY+=('DietPi-Config' ': Edit network, APT/NTP mirror settings etc') G_WHIP_MENU_ARRAY+=('Open subshell' ': Open a subshell to investigate or solve the issue') - # Allow to send bug report, if it was produced by one of our scripts - [[ ${G_PROGRAM_NAME,,} == 'dietpi-'* && $G_PROGRAM_NAME != 'DietPi-Installer' ]] && G_WHIP_MENU_ARRAY+=('Send report' ': Uploads bugreport containing system info to DietPi') + # Allow to send bug report if it was produced by one of our scripts, excluding DietPi-Installer + [[ ${G_PROGRAM_NAME,,} == 'dietpi-'* && $G_PROGRAM_NAME != 'DietPi-Installer' ]] && G_WHIP_MENU_ARRAY+=('Send report' ': Upload bug report including system info to DietPi') + + # Allow to print bug report template if it was produced by one of our scripts + [[ ${G_PROGRAM_NAME,,} == 'dietpi-'* ]] && G_WHIP_MENU_ARRAY+=('Print report' ': Print bug report template for GitHub or forum') + G_WHIP_MENU_ARRAY+=('' '●─ Devs only ') G_WHIP_MENU_ARRAY+=('Change command' ': Adjust and rerun the command') @@ -959,8 +957,8 @@ $log_content G_WHIP_MENU "${G_EXEC_DESC:+$(mawk '{gsub("\\\e[[0-9][;0-9]*m","");print}' <<< "$G_EXEC_DESC")\n} - Command: ${acommand[*]} - Exit code: $exit_code - DietPi version: $dietpi_version | HW_MODEL: $G_HW_MODEL | HW_ARCH: $G_HW_ARCH | DISTRO: $G_DISTRO -${image_creator:+ - Image creator: $image_creator\n}${preimage_name:+ - Pre-image: $preimage_name\n} - Error log: -$log_content" || break # Exit error handler menu loop on cancel + - Error log: +$(<"$fp_log")" || break # Exit error handler menu loop on cancel last_whip_menu_item=$G_WHIP_RETURNED_VALUE @@ -987,10 +985,34 @@ $log_content" || break # Exit error handler menu loop on cancel elif [[ $G_WHIP_RETURNED_VALUE == 'Send report' ]]; then + # Store error details to append to bug report upload + G_BUG_REPORT -c "${acommand[*]}" -? "$exit_code" > "$fp_error_report" + + # Send report /boot/dietpi/dietpi-bugreport 1 && sent_bug_report=1 read -rp ' Press any key to continue...' + elif [[ $G_WHIP_RETURNED_VALUE == 'Print report' ]]; then + + echo -e '\e[41m--------------------------------------------------------------------- +- DietPi bug report template for GitHub or forum - +- Please report at: https://github.com/MichaIng/DietPi/issues - + or: https://dietpi.com/forum/c/troubleshooting/10 - +- Copy and paste ONLY the BLUE lines below, replacing the template! - +---------------------------------------------------------------------\e[44m' + # Add bug report ID if sent already + if [[ $sent_bug_report == 1 ]] + then + sed --follow-symlinks -i "/^- Date | /a\- Bug report | $G_HW_UUID" "$fp_error_report" + cat "$fp_error_report" + else + G_BUG_REPORT -c "${acommand[*]}" -? "$exit_code" + fi + echo -e '\e[41m---------------------------------------------------------------------\e[0m' + read -rp ' +Press any key to continue...' + elif [[ $G_WHIP_RETURNED_VALUE == 'Change command' ]]; then G_WHIP_DEFAULT_ITEM=${acommand[*]} @@ -1016,14 +1038,7 @@ Press any key to continue...' fi done - # Error has not been solved, print GitHub issue template if it was produced and exit error handler menu loop - if [[ -f $fp_error_report ]]; then - - # Add bug report ID if it was sent - [[ $sent_bug_report == 1 ]] && sed --follow-symlinks -i "/^- Date | /a\- Bug report | $G_HW_UUID" "$fp_error_report" - cat "$fp_error_report" - - fi + # Error has not been solved, exit error handler menu loop break done