From 50f6fb29d1a8f2b777edb9c5a2c7b37266734f4e Mon Sep 17 00:00:00 2001 From: ehpersonal38 <103586016+ehpersonal38@users.noreply.github.com> Date: Wed, 1 Jun 2022 17:24:47 -0400 Subject: [PATCH] Revert "Revert "Trying and catching"" This reverts commit 4670a68533a82a9a63f45352b7373a88176ca9df. --- homepage/views.php | 9 ++++++++- scripts/system_controls.php | 9 ++++++++- 2 files changed, 16 insertions(+), 2 deletions(-) diff --git a/homepage/views.php b/homepage/views.php index 7e8723c..7a2d34b 100644 --- a/homepage/views.php +++ b/homepage/views.php @@ -4,7 +4,14 @@ $user = shell_exec("awk -F: '/1000/{print $1}' /etc/passwd"); $home = shell_exec("awk -F: '/1000/{print $6}' /etc/passwd"); $home = trim($home); if(!isset($_SESSION['behind'])) { - $_SESSION['behind'] = trim(shell_exec("sudo -u$user git -C ".$home."/BirdNET-Pi fetch > /dev/null 2>&1 && sudo -u$user git -C ".$home."/BirdNET-Pi status | sed -n '2 p' | cut -d ' ' -f 7")); + $fetch = shell_exec("sudo -u".$user." git -C ".$home."/BirdNET-Pi fetch 2>&1"); + // some kind of error + if(strlen($fetch) > 0) { + $fetch = shell_exec("sudo git -C ".$home."/BirdNET-Pi fetch 2>&1"); + $_SESSION['behind'] = trim(shell_exec("sudo git -C ".$home."/BirdNET-Pi status | sed -n '2 p' | cut -d ' ' -f 7")); + } else { + $_SESSION['behind'] = trim(shell_exec("sudo -u".$user." git -C ".$home."/BirdNET-Pi status | sed -n '2 p' | cut -d ' ' -f 7")); + } } if(intval($_SESSION['behind']) >= 99) {?>