Skip to content

Commit

Permalink
created a G_BUG_REPORT() function, which prints out the data for the …
Browse files Browse the repository at this point in the history
…forums troubleshoot template.

This info will be also integrated into G_EXEC error handler
  • Loading branch information
JappeHallunken authored and MichaIng committed Jul 7, 2024
1 parent 1de1ccb commit b1df1e9
Showing 1 changed file with 36 additions and 17 deletions.
53 changes: 36 additions & 17 deletions dietpi/func/dietpi-globals
Original file line number Diff line number Diff line change
Expand Up @@ -803,6 +803,28 @@ $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 <<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
}

#-----------------------------------------------------------------------------------
# Error handled command execution wrapper
#-----------------------------------------------------------------------------------
Expand Down Expand Up @@ -873,34 +895,30 @@ $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
# 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

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)
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")

fi

# 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:
- 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})
- Command | \`$ecommand\`
- Exit code | $exit_code
- Software title | $G_PROGRAM_NAME
$error_details
#### Steps to reproduce:
<!-- Explain how to reproduce the issue -->
1. ...
Expand All @@ -918,7 +936,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 b1df1e9

Please sign in to comment.