Add ram drive support in the ui

This commit is contained in:
frederik
2024-02-12 11:53:35 +01:00
parent a4122b5bcc
commit 189ef116d0
2 changed files with 18 additions and 5 deletions
+7
View File
@@ -29,6 +29,11 @@ $user = shell_exec("awk -F: '/1000/{print $1}' /etc/passwd");
$user = trim($user);
$home = shell_exec("awk -F: '/1000/{print $6}' /etc/passwd");
$home = trim($home);
function service_mount() {
global $home;
$service_mount=trim(shell_exec("systemd-escape -p --suffix=mount ".$home."/BirdSongs/StreamData"));
return $service_mount;
}
if(!isset($_SESSION['behind'])) {
$fetch = shell_exec("sudo -u".$user." git -C ".$home."/BirdNET-Pi fetch 2>&1");
$str = trim(shell_exec("sudo -u".$user." git -C ".$home."/BirdNET-Pi status"));
@@ -319,6 +324,8 @@ if(isset($_GET['view'])){
'sudo systemctl restart spectrogram_viewer.service',
'sudo systemctl disable --now spectrogram_viewer.service',
'sudo systemctl enable --now spectrogram_viewer.service',
'sudo systemctl enable '.service_mount().' && sudo reboot',
'sudo systemctl disable '.service_mount().' && sudo reboot',
'stop_core_services.sh',
'restart_services.sh',
'sudo reboot',
+11 -5
View File
@@ -1,9 +1,10 @@
<?php
<?php
$home = trim(shell_exec("awk -F: '/1000/{print $6}' /etc/passwd"));
function do_service_mount($action) {
echo "value=\"sudo systemctl ".$action." ".service_mount()." && sudo reboot\"";
}
function service_status($name) {
$user = shell_exec("awk -F: '/1000/{print $1}' /etc/passwd");
$home = shell_exec("awk -F: '/1000/{print $6}' /etc/passwd");
$home = trim($home);
global $home;
if($name == "birdnet_analysis.service") {
$filesinproc=trim(shell_exec("ls ".$home."/BirdSongs/StreamData | wc -l"));
if($filesinproc > 200) {
@@ -79,6 +80,11 @@ function service_status($name) {
<button type="submit" name="submit" value="sudo systemctl disable --now spectrogram_viewer.service">Disable</button>
<button type="submit" name="submit" value="sudo systemctl enable --now spectrogram_viewer.service">Enable</button>
</form>
<form action="" method="GET">
<h3>Ram drive (!experimental!) <?php echo service_status(service_mount());?></h3>
<button type="submit" name="submit" <?php do_service_mount("disable");?> onclick="return confirm('This will reboot, are you sure?')">Disable</button>
<button type="submit" name="submit" <?php do_service_mount("enable");?> onclick="return confirm('This will reboot, are you sure?')">Enable</button>
</form>
<form action="" method="GET">
<button type="submit" name="submit" value="stop_core_services.sh">Stop Core Services</button>
</form>