From 082be6a9f5e892e3edd4e704d2d067d51e4b0d53 Mon Sep 17 00:00:00 2001 From: Scott Ullrich Date: Thu, 12 Mar 2009 16:00:02 -0400 Subject: [PATCH] Added custom_php_service_status_command support for packages. Package authors can define a custom_php_service_status_command block in their package XML. Such block should only contain function calls, and the first should be one to include their function library file if necessary, as this is not done by service-utils.inc. The return code of the last function call will be returned to the service check. --- etc/inc/service-utils.inc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/etc/inc/service-utils.inc b/etc/inc/service-utils.inc index 01d2714ddc..436926d51f 100644 --- a/etc/inc/service-utils.inc +++ b/etc/inc/service-utils.inc @@ -167,14 +167,15 @@ function is_service_running($service, $ps = "") { if(is_array($config['installedpackages']['service'])) { foreach($config['installedpackages']['service'] as $aservice) { if(strtolower($service) == strtolower($aservice['name'])) { - if(!$aservice['executable']) return false; - /* - if(count(preg_grep("/{$aservice['executable']}/i", $ps))) { - return true; - } else { + if(!$aservice['executable']) return false; + if($aservice['custom_php_service_status_command'] <> "") { + $_cmd=explode(';', $aservice['custom_php_service_status_command']); + foreach($_cmd as $_acmd) { + if($_acmd) eval('$rc='.$_acmd.';'); + } + return $rc; } - */ return is_process_running($aservice['executable']) ? true : false; } }