From a91c6e3f9225c5817a13c05abba174d34fcab630 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Sat, 30 Dec 2017 22:48:35 +0100 Subject: [PATCH] www/c-icap: switch to mutable service controller Clean up the headers, the copyright is just Michael's as there is no other code in here anymore. --- .../CICAP/Api/AntivirusController.php | 45 +++-- .../OPNsense/CICAP/Api/GeneralController.php | 47 +++-- .../OPNsense/CICAP/Api/ServiceController.php | 168 +++--------------- 3 files changed, 71 insertions(+), 189 deletions(-) diff --git a/www/c-icap/src/opnsense/mvc/app/controllers/OPNsense/CICAP/Api/AntivirusController.php b/www/c-icap/src/opnsense/mvc/app/controllers/OPNsense/CICAP/Api/AntivirusController.php index b8f5831f1..679f46b73 100644 --- a/www/c-icap/src/opnsense/mvc/app/controllers/OPNsense/CICAP/Api/AntivirusController.php +++ b/www/c-icap/src/opnsense/mvc/app/controllers/OPNsense/CICAP/Api/AntivirusController.php @@ -1,40 +1,37 @@ configdRun("firmware plugin clamav"); return $response; } - - /** - * start cicap service (in background) - * @return array - */ - public function startAction() - { - if ($this->request->isPost()) { - // close session for long running action - $this->sessionClose(); - - $backend = new Backend(); - $response = $backend->configdRun("cicap start"); - return array("response" => $response); - } else { - return array("response" => array()); - } - } - - /** - * stop cicap service - * @return array - */ - public function stopAction() - { - if ($this->request->isPost()) { - // close session for long running action - $this->sessionClose(); - - $backend = new Backend(); - $response = $backend->configdRun("cicap stop"); - return array("response" => $response); - } else { - return array("response" => array()); - } - } - - /** - * restart cicap service - * @return array - */ - public function restartAction() - { - if ($this->request->isPost()) { - // close session for long running action - $this->sessionClose(); - - $backend = new Backend(); - $response = $backend->configdRun("cicap restart"); - return array("response" => $response); - } else { - return array("response" => array()); - } - } - - /** - * retrieve status of cicap - * @return array - * @throws \Exception - */ - public function statusAction() - { - $backend = new Backend(); - $mdlGeneral = new General(); - $response = $backend->configdRun("cicap status"); - - if (strpos($response, "not running") > 0) { - if ($mdlGeneral->enabled->__toString() == 1) { - $status = "stopped"; - } else { - $status = "disabled"; - } - } elseif (strpos($response, "is running") > 0) { - $status = "running"; - } elseif ($mdlGeneral->enabled->__toString() == 0) { - $status = "disabled"; - } else { - $status = "unkown"; - } - - return array("status" => $status); - } - - /** - * reconfigure cicap, generate config and reload - */ - public function reconfigureAction() - { - if ($this->request->isPost()) { - // close session for long running action - $this->sessionClose(); - - $mdlGeneral = new General(); - $backend = new Backend(); - - $runStatus = $this->statusAction(); - - // stop cicap if it is running or not - $this->stopAction(); - - // generate template - $backend->configdRun('template reload OPNsense/CICAP'); - - // (res)start daemon - if ($mdlGeneral->enabled->__toString() == 1) { - $this->startAction(); - } - - return array("status" => "ok"); - } else { - return array("status" => "failed"); - } - } }