removed all sudo git instances

This commit is contained in:
mcguirepr89
2022-06-02 06:40:42 -04:00
parent fb6ffee404
commit 7bfe241e57
2 changed files with 11 additions and 18 deletions
+4 -8
View File
@@ -1,25 +1,21 @@
<?php <?php
session_start(); session_start();
$user = shell_exec("awk -F: '/1000/{print $1}' /etc/passwd"); $user = shell_exec("awk -F: '/1000/{print $1}' /etc/passwd");
$user = trim($user);
$home = shell_exec("awk -F: '/1000/{print $6}' /etc/passwd"); $home = shell_exec("awk -F: '/1000/{print $6}' /etc/passwd");
$home = trim($home); $home = trim($home);
if(!isset($_SESSION['behind'])) { if(!isset($_SESSION['behind'])) {
$fetch = shell_exec("sudo -u".$user." git -C ".$home."/BirdNET-Pi fetch 2>&1"); $fetch = shell_exec("sudo -u".$user." git -C ".$home."/BirdNET-Pi fetch 2>&1");
// some kind of error
if(strlen($fetch) > 0) { 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")); $_SESSION['behind'] = trim(shell_exec("sudo -u".$user." git -C ".$home."/BirdNET-Pi status | sed -n '2 p' | cut -d ' ' -f 7"));
} }
} if(isset($_SESSION['behind'])&&intval($_SESSION['behind']) >= 99) {?>
if(intval($_SESSION['behind']) >= 99) {?>
<style> <style>
.updatenumber { .updatenumber {
width:30px !important; width:30px !important;
} }
</style> </style>
<?php } <?php }}
?> ?>
<link rel="stylesheet" href="style.css"> <link rel="stylesheet" href="style.css">
<style> <style>
@@ -54,7 +50,7 @@ body::-webkit-scrollbar {
<button type="submit" name="view" value="View Log" form="views">View Log</button> <button type="submit" name="view" value="View Log" form="views">View Log</button>
</form> </form>
<form action="" method="GET" id="views"> <form action="" method="GET" id="views">
<button type="submit" name="view" value="Tools" form="views">Tools<?php if(intval($_SESSION['behind']) >= 50){ $updatediv = ' <div class="updatenumber">'.$_SESSION["behind"].'</div>'; } else { $updatediv = ""; } echo $updatediv; ?></button> <button type="submit" name="view" value="Tools" form="views">Tools<?php if(isset($_SESSION['behind']) && intval($_SESSION['behind']) >= 50){ $updatediv = ' <div class="updatenumber">'.$_SESSION["behind"].'</div>'; } else { $updatediv = ""; } echo $updatediv; ?></button>
</form> </form>
<button href="javascript:void(0);" class="icon" onclick="myFunction()"><img src="images/menu.png"></button> <button href="javascript:void(0);" class="icon" onclick="myFunction()"><img src="images/menu.png"></button>
</div> </div>
+2 -5
View File
@@ -1,14 +1,11 @@
<?php <?php
session_start(); session_start();
$user = shell_exec("awk -F: '/1000/{print $1}' /etc/passwd"); $user = shell_exec("awk -F: '/1000/{print $1}' /etc/passwd");
$user = trim($user);
$home = shell_exec("awk -F: '/1000/{print $6}' /etc/passwd"); $home = shell_exec("awk -F: '/1000/{print $6}' /etc/passwd");
$home = trim($home); $home = trim($home);
$fetch = shell_exec("sudo -u".$user." git -C ".$home."/BirdNET-Pi fetch 2>&1"); $fetch = shell_exec("sudo -u".$user." git -C ".$home."/BirdNET-Pi fetch 2>&1");
// some kind of error
if(strlen($fetch) > 0) { 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")); $_SESSION['behind'] = trim(shell_exec("sudo -u".$user." git -C ".$home."/BirdNET-Pi status | sed -n '2 p' | cut -d ' ' -f 7"));
} }
?><html> ?><html>
@@ -20,7 +17,7 @@ if(strlen($fetch) > 0) {
<button type="submit" name="submit" value="sudo reboot" onclick="return confirm('Are you sure you want to reboot?')">Reboot</button> <button type="submit" name="submit" value="sudo reboot" onclick="return confirm('Are you sure you want to reboot?')">Reboot</button>
</form> </form>
<form action="" method="GET"> <form action="" method="GET">
<button type="submit" name="submit" value="update_birdnet.sh" onclick="return confirm('Are you sure you want to update?')">Update <?php if($_SESSION['behind'] != "0" && $_SESSION['behind'] != "with"){?><div class="updatenumber"><?php echo $_SESSION['behind']; ?></div><?php } ?></button> <button type="submit" name="submit" value="update_birdnet.sh" onclick="return confirm('Are you sure you want to update?')">Update <?php if(isset($_SESSION['behind']) && $_SESSION['behind'] != "0" && $_SESSION['behind'] != "with"){?><div class="updatenumber"><?php echo $_SESSION['behind']; ?></div><?php } ?></button>
</form> </form>
<form action="" method="GET"> <form action="" method="GET">
<button type="submit" name="submit" value="sudo shutdown now" onclick="return confirm('Are you sure you want to shutdown?')">Shutdown</button> <button type="submit" name="submit" value="sudo shutdown now" onclick="return confirm('Are you sure you want to shutdown?')">Shutdown</button>