Skip to content

Commit

Permalink
create a G_BUG_REPORT function, which can be executed to generate the…
Browse files Browse the repository at this point in the history
… troubleshoot template for the forum.

This info will also be integrated into G_EXEC, when one of the dietpi-* scripts error out.
  • Loading branch information
JappeHallunken committed Jan 22, 2024
1 parent 6a4b6e0 commit 8767a87
Showing 1 changed file with 43 additions and 11 deletions.
54 changes: 43 additions & 11 deletions dietpi/func/dietpi-globals
Original file line number Diff line number Diff line change
Expand Up @@ -804,6 +804,31 @@ $grey─────────────────────────
return "${result:-1}"
}

<<<<<<< HEAD
=======
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 <<EOF
#### Required Information
- DietPi version | $dietpi_version
- Distro version | $G_DISTRO_NAME (ID=$G_DISTRO${G_RASPBIAN:+,RASPBIAN=$G_RASPBIAN})
- Kernel version | \`$(uname -a)\`
- Architecture | \`$(dpkg --print-architecture)\`
- SBC model | $G_HW_MODEL_NAME (ID=$G_HW_MODEL)
- Image creator | $image_creator
- Pre-image | $preimage_name
EOF
}

>>>>>>> 7f106513 (create a G_BUG_REPORT function, which can be executed to generate the troubleshoot template for the forum.)
#-----------------------------------------------------------------------------------
# Error handled command execution wrapper
#-----------------------------------------------------------------------------------
Expand Down Expand Up @@ -874,31 +899,37 @@ $grey─────────────────────────
# 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") image_creator preimage_name dietpi_version="v$G_DIETPI_VERSION_CORE.$G_DIETPI_VERSION_SUB.$G_DIETPI_VERSION_RC ($G_GITOWNER/$G_GITBRANCH)" 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)
# 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

fi
local dietpi_version="v$G_DIETPI_VERSION_CORE.$G_DIETPI_VERSION_SUB.$G_DIETPI_VERSION_RC ($G_GITOWNER/$G_GITBRANCH)"
local error_details=$(generate_error_details "$dietpi_version")

# Create GitHub issue template if error was produced by one of our scripts
[[ ${G_PROGRAM_NAME,,} == 'dietpi-'* ]] && echo -e "\e[41m
cat <<EOF > "$fp_error_report"
\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:
<<<<<<< HEAD
- Date | $(date)
- DietPi version | $dietpi_version
- Image creator | $image_creator
- Pre-image | $preimage_name
- Hardware | $G_HW_MODEL_NAME (ID=$G_HW_MODEL)
- Kernel version | \`$(uname -a)\`
- Distro | $G_DISTRO_NAME (ID=$G_DISTRO${G_RASPBIAN:+,RASPBIAN=$G_RASPBIAN})
=======
$error_details
- Date | $(date)
>>>>>>> 7f106513 (create a G_BUG_REPORT function, which can be executed to generate the troubleshoot template for the forum.)
- Command | \`$ecommand\`
- Exit code | $exit_code
- Software title | $G_PROGRAM_NAME
Expand All @@ -919,7 +950,8 @@ $grey─────────────────────────
\`\`\`
$log_content
\`\`\`\e[41m
---------------------------------------------------------------------\e[0m" > "$fp_error_report"
---------------------------------------------------------------------\e[0m
EOF

# Enter error handler menu loop in interactive mode
[[ $G_INTERACTIVE == 1 ]] && while :
Expand Down

0 comments on commit 8767a87

Please sign in to comment.