$docroot ??= ($_SERVER['DOCUMENT_ROOT'] ?: '/usr/local/emhttp');
// add translations
$_SERVER['REQUEST_URI'] = '';
require_once "$docroot/webGui/include/Translations.php";
$name = $_POST['name'];
switch ($name) {
case 'crontab':
$pid = file_exists("/boot/config/plugins/{$_POST['plugin']}/{$_POST['job']}.cron");
break;
case 'preclear_disk':
$pid = exec("ps -o pid,command --ppid 1|awk -F/ ".escapeshellarg("/$name .*{$_POST['device']}$/{print $1;exit}"));
break;
case is_numeric($name):
$pid = exec("lsof -i:$name -Pn|awk '/\(LISTEN\)/{print $2;exit}'");
break;
case 'pid':
$pid = file_exists("/var/run/{$_POST['plugin']}.pid");
break;
default:
$pid = exec("pidof -s -x ".escapeshellarg($name));
break;
}
if (isset($_POST['update'])) {$span = ""; $_span = "";}
else {$span = ""; $_span = "";}
echo $pid ? "{$span}"._('Status').":"._('Running')."{$_span}" : "{$span}"._('Status').":"._('Stopped')."{$_span}";
?>