2) return 1; return 0; } function restart_service_if_running($service) { global $config; if(is_service_running($service)) restart_service($service); return; } 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(strtolower($service) == strtolower($aservice['name'])) { if(!$aservice['executable']) return false; if(in_array($aservice['executable'], $ps)) { return true; } else { return false; } break; } } } return false; }