/** * Execute action * * @param \CentreonConfiguration\Events\CopyFiles $event * @throws Exception */ public static function execute(CopyFilesEvent $event) { $config = Di::getDefault()->get('config'); $tmpdir = $config->get('global', 'centreon_generate_tmp_dir'); if (false === is_dir($tmpdir . '/broker/apply/' . $event->getPollerId())) { if (false === mkdir($tmpdir . '/broker/apply/' . $event->getPollerId())) { throw new Exception("Error while prepare copy of Broker configuration files\n"); } } $output = array(); exec("rm -rf {$tmpdir}/broker/apply/{$event->getPollerId()}/* 2>&1", $output, $statusDelete); if ($statusDelete) { $event->setOutput(_('Error while deleting Broker configuration files') . "\n" . implode("\n", $output)); } exec("cp -Rpf {$tmpdir}/broker/generate/{$event->getPollerId()}/* {$tmpdir}/broker/apply/{$event->getPollerId()}/ 2>&1", $output, $status); if ($status) { $event->setOutput(_('Error while copying Broker configuration files') . "\n" . implode("\n", $output)); } else { $event->setOutput(_('Successfully copied files for Broker.')); } }