From a932f33cad780cfa97c0c50efef000ce8087aab4 Mon Sep 17 00:00:00 2001 From: Botspot Date: Sat, 3 Jul 2021 12:01:12 -0500 Subject: [PATCH] App details view log button if corrupted --- etc/viewlog | 6 +++++- gui | 12 ++++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/etc/viewlog b/etc/viewlog index 906db12..4086cf4 100755 --- a/etc/viewlog +++ b/etc/viewlog @@ -5,6 +5,9 @@ DIRECTORY="$(readlink -f "$(dirname "$(dirname "$0")")")" file="$6" +if [ -z "$file" ];then + file="$1" +fi echo "$file" > "$DIRECTORY/data/current-viewed-logfile" if command -v mousepad ;then @@ -20,7 +23,8 @@ else pid=$! fi -while [ "$(cat "$DIRECTORY/data/current-viewed-logfile")" == "$file" ];do +#while the user-selection stays the same, AND the text editor is still running, wait. +while [ "$(cat "$DIRECTORY/data/current-viewed-logfile")" == "$file" ] && kill -0 $pid;do sleep 1 done kill $pid 2>/dev/null diff --git a/gui b/gui index b560814..152815c 100755 --- a/gui +++ b/gui @@ -424,6 +424,13 @@ This app installed these packages: $(cat "${DIRECTORY}/data/installed-packages/$ #if disabled, display no buttons whichbutton+=("--button=Enable!!Force this app to install on your system."$'\n'"This app was disabled for a reason so if you enable it..."$'\n'"YOU HAVE BEEN WARNED.:12") else + #if app status is 'corrupted', and a log file exists for this app, then display a button to view the log file + if [ "$(app_status "${output}")" == 'corrupted' ];then + logfile="$(ls "$DIRECTORY/logs"/* -t | grep "fail-${output}" | head -n1)" + if [ ! -z "$logfile" ];then + whichbutton+=("--button=Errors!${DIRECTORY}/icons/log-file.png!$output failed to $(echo "$(basename "$logfile")" | awk -F'-' '{print $1}'). Click this button to view the error output saved in the log file.:14") + fi + fi #if status is corrupted or unknown, then show both buttons whichbutton+=("--button=!${DIRECTORY}/icons/uninstall.png:2" "--button=!${DIRECTORY}/icons/install.png:4") fi @@ -483,6 +490,11 @@ This app installed these packages: $(cat "${DIRECTORY}/data/installed-packages/$ #remove status file containing 'disabled' rm -f "${DIRECTORY}/data/status/${app}" ;; + 14) + echo "Viewing error log of $output..." + echo "Log filepath: $logfile" + "${DIRECTORY}/etc/viewlog" "$logfile" + ;; *) error 'unknown button. Exiting now.' exit 1