convert service_controls.php system_controls.php

This commit is contained in:
frederik
2024-03-15 10:38:58 +01:00
parent 83f72c4991
commit a48bda055b
3 changed files with 12 additions and 15 deletions
+5 -3
View File
@@ -1,7 +1,9 @@
<?php
$home = trim(shell_exec("awk -F: '/1000/{print $6}' /etc/passwd"));
require_once "scripts/common.php";
$home = get_home();
function do_service_mount($action) {
echo "value=\"sudo systemctl ".$action." ".service_mount()." && sudo reboot\"";
echo "value=\"sudo systemctl ".$action." ".get_service_mount_name()." && sudo reboot\"";
}
function service_status($name) {
global $home;
@@ -81,7 +83,7 @@ function service_status($name) {
<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>
<h3>Ram drive (!experimental!) <?php echo service_status(get_service_mount_name());?></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>
+3 -8
View File
@@ -8,6 +8,7 @@ ini_set('user_agent', 'PHP_Flickr/1.0');
error_reporting(0);
ini_set('display_errors', 0);
require_once 'scripts/common.php';
$home = get_home();
$db = new SQLite3('./scripts/birds.db', SQLITE3_OPEN_READONLY);
$db->busyTimeout(1000);
@@ -41,9 +42,6 @@ if(isset($_GET['species'])){
$result3 = $statement3->execute();
}
$user = shell_exec("awk -F: '/1000/{print $1}' /etc/passwd");
$home = shell_exec("awk -F: '/1000/{print $6}' /etc/passwd");
$home = trim($home);
if(!file_exists($home."/BirdNET-Pi/scripts/disk_check_exclude.txt") || strpos(file_get_contents($home."/BirdNET-Pi/scripts/disk_check_exclude.txt"),"##start") === false) {
file_put_contents($home."/BirdNET-Pi/scripts/disk_check_exclude.txt", "");
file_put_contents($home."/BirdNET-Pi/scripts/disk_check_exclude.txt", "##start\n##end\n");
@@ -192,11 +190,8 @@ while($results=$result3->fetchArray(SQLITE3_ASSOC)){
ob_flush();
flush();
if (file_exists('./scripts/thisrun.txt')) {
$config = parse_ini_file('./scripts/thisrun.txt');
} elseif (file_exists('./scripts/firstrun.ini')) {
$config = parse_ini_file('./scripts/firstrun.ini');
}
$config = get_config();
if (! empty($config["FLICKR_API_KEY"])) {
// only open the file once per script execution
if(!isset($lines)) {
+4 -4
View File
@@ -1,9 +1,9 @@
<?php
session_start();
$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);
require_once "scripts/common.php";
$user = get_user();
$home = get_home();
$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"));
if (preg_match("/behind '.*?' by (\d+) commit(s?)\b/", $str, $matches)) {