@ -314,13 +317,68 @@ runonce() { #run command only if it's never been run before. Useful for one-time
}
format_log_file() { #remove ANSI escape sequences from a given file, and add OS information to beginning of file
[ -z "$1" ] && error "format_log_file: no filename given!"
[ ! -f "$1" ] && error "format_log_file: given filename ($1) does not exist or is not a file!"
echo -e "$(get_device_info)\n\nBEGINNING OF ERROR LOG:\n-----------------------\n\n$(cat "$1" | sed 's/\x1b\[[0-9;]*m//g' | sed 's/\x1b\[[0-9;]*//g')" > "$1"
}
get_device_info() { #returns information about current install and hardware
send_error_report_gui() { #Ask user for permission to send error report
[ -z "$1" ] && error "send_error_report_gui(): requires an argument for error report file!"
[ ! -f "$1" ] && error "send_error_report_gui(): Given error report file ($1) does not exist!"
[ -z "$2" ] && error "send_error_report_gui(): requires an argument for window text!"
export -f text_editor
export DIRECTORY
yad --center --title="Send error report?" --window-icon="${DIRECTORY}/icons/logo.png" \
--text="$2"$'\n'"Send error report to Pi-Apps developers?"$'\n'"Help is available on <a href=\"https://discord.gg/RXSTvaUvuu\">Discord</a> and <a href=\"https://github.com/Botspot/pi-apps/issues/new/choose\">Github</a>." --on-top \
--button='View report'!"${DIRECTORY}/icons/log-file.png"!"View the log file to be sent."$'\n'"Feel free to edit the file with more debug information to help us.":"bash -c 'text_editor "\""$1"\""'" \
#this app failed to install - add it to the list of failed apps
failed_apps="$failed_apps
$app"
fi
done
app_results="${app_results:1}" #remove first blank newline
for app in $failed_apps ;do
logfile="$(ls -dt "${DIRECTORY}/logs"/* | grep '\-'"${app}"'\.log' -m 1)" #sort logfiles by modification date, get the most recent one for the current app
#if logfile detected, exists, and is not empty, ask permission to send error report
#this app failed to install - add it to the list of failed apps
failed_apps="$failed_apps
$app"
fi
done
IFS="$PREIFS"
if [ $failed == 1 ];then
app_results="${app_results:1}" #remove first blank newline
for app in $failed_apps ;do
logfile="$(ls -dt "${DIRECTORY}/logs"/* | grep '\-'"${app}"'\.log' -m 1)" #sort logfiles by modification date, get the most recent one for the current app
#if logfile detected, exists, and is not empty, ask permission to send error report