mirror of
https://github.com/pfsense/pfsense.git
synced 2025-10-26 11:38:35 +00:00
Add is_service_running.
This commit is contained in:
parent
dc312bf5e9
commit
ec4e071aa4
@ -118,3 +118,27 @@ function restart_service($service) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function is_service_running($service, $ps = "") {
|
||||
global $config;
|
||||
if(!$ps) {
|
||||
exec("/bin/ps a | awk '{ print $5 }'", $psout);
|
||||
array_shift($psout);
|
||||
foreach($psout as $line) {
|
||||
$ps[] = array_pop(explode('/', $line));
|
||||
}
|
||||
}
|
||||
if($config['installedpackages']['service']) {
|
||||
foreach($config['installedpackages']['service'] as $service) {
|
||||
if($service['name'] == $service) {
|
||||
if(in_array($service['executable'], $ps)) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user