diff options
author | Colin Smith <colin@pfsense.org> | 2005-06-26 07:29:40 +0000 |
---|---|---|
committer | Colin Smith <colin@pfsense.org> | 2005-06-26 07:29:40 +0000 |
commit | a8dbad898e9a3629de68dbef40d4912d6006c84c (patch) | |
tree | df397dc2f573546c431b7a37fd90319509c64a24 /etc/inc/service-utils.inc | |
parent | 636ab238132435a2a8d2c1ef434d6ed49fcdc93f (diff) | |
download | pfsense-a8dbad898e9a3629de68dbef40d4912d6006c84c.zip pfsense-a8dbad898e9a3629de68dbef40d4912d6006c84c.tar.gz |
Whoops. Don't forget to merge.
Diffstat (limited to 'etc/inc/service-utils.inc')
-rw-r--r-- | etc/inc/service-utils.inc | 40 |
1 files changed, 18 insertions, 22 deletions
diff --git a/etc/inc/service-utils.inc b/etc/inc/service-utils.inc index 250df4b..b66b7bb 100644 --- a/etc/inc/service-utils.inc +++ b/etc/inc/service-utils.inc @@ -43,10 +43,10 @@ function write_rcfile($params) { if($params['stop']) { $tokill =& $params['stop']; } elseif($params['executable']) { - // just nuke the executable + /* just nuke the executable */ $tokill = "/usr/bin/killall {$params['executable']}"; } else { - // make an educated guess (bad) + /* make an educated guess (bad) */ $tokill = array_pop(explode('/', array_shift(explode(' ', $params['start'])))); } $towrite .= "rc_stop() {\n\t" . $tokill . "\n}\n\n"; @@ -64,7 +64,7 @@ function start_service($name) { global $config, $g; if($config['installedpackages']['service']) { foreach($config['installedpackages']['service'] as $service) { - if($service['name'] == $name) { + if(strtolower($service['name']) == strtolower($name)) { if($service['rcfile']) { if($service['prefix']) { $prefix =& $service['prefix']; @@ -86,7 +86,7 @@ function stop_service($name) { global $config, $g; if($config['installedpackages']['service']) { foreach($config['installedpackages']['service'] as $service) { - if($service['name'] == $name) { + if(strtolower($service['name']) == strtolower($name)) { if($service['rcfile']) { if($service['prefix']) { $prefix =& $service['prefix']; @@ -113,7 +113,7 @@ function restart_service($name) { start_service($name); if($config['installedpackages']['service']) { foreach($config['installedpackages']['service'] as $service) { - if($service['name'] == $name) { + if(strtolower($service['name']) == strtolower($name)) { if($service['restartcmd']) { eval($service['restartcmd']); } @@ -123,30 +123,26 @@ function restart_service($name) { } } -function is_process_running($process, $ps = "") { - if(!$ps) { - exec("/bin/ps ax | awk '{ print $5 }'", $psout); - array_shift($psout); - foreach($psout as $line) { - $ps[] = trim(array_pop(explode(' ', array_pop(explode('/', $line))))); - } - print_r($ps); - } - if(in_array($process, $ps)) { - return true; - } else { - return false; - } - return false; +function is_process_running($process) { + $status = `/bin/ps ax | /usr/bin/grep {$process} | wc -l`; + if($status > 2) return 1; + return 0; } function is_service_running($service, $ps = "") { global $config; + if(!$ps) { + exec("/bin/ps ax | awk '{ print $5 }'", $psout); + array_shift($psout); + foreach($psout as $line) { + $ps[] = trim(array_pop(explode(' ', array_pop(explode('/', $line))))); + } + } if($config['installedpackages']['service']) { foreach($config['installedpackages']['service'] as $aservice) { - if($service == $aservice['name']) { + if(strtolower($service) == strtolower($aservice['name'])) { if(!$aservice['executable']) return false; - if(is_process_running($aservice['executable'], $ps)) { + if(in_array($aservice['executable'], $ps)) { return true; } else { return false; |