Commit d1e5d32e authored by Ad Schellevis's avatar Ad Schellevis

(captiveportal, new) add configd actions to reconfigure

parent de008540
...@@ -30,6 +30,7 @@ namespace OPNsense\CaptivePortal\Api; ...@@ -30,6 +30,7 @@ namespace OPNsense\CaptivePortal\Api;
use \OPNsense\Base\ApiControllerBase; use \OPNsense\Base\ApiControllerBase;
use \OPNsense\Core\Backend; use \OPNsense\Core\Backend;
use \OPNsense\CaptivePortal\CaptivePortal;
/** /**
* Class ServiceController * Class ServiceController
...@@ -53,11 +54,25 @@ class ServiceController extends ApiControllerBase ...@@ -53,11 +54,25 @@ class ServiceController extends ApiControllerBase
$bckresult = trim($backend->configdRun("ipfw reload")); $bckresult = trim($backend->configdRun("ipfw reload"));
if ($bckresult == "OK") { if ($bckresult == "OK") {
// generate captive portal config // generate captive portal config
$backend->configdRun("template reload OPNsense.Captiveportal"); $bckresult = trim($backend->configdRun("template reload OPNsense.Captiveportal"));
// TODO: implement portal webservers restart/reconfigure if ($bckresult == "OK") {
$status = "ok"; $mdlCP = new CaptivePortal();
if ($mdlCP->isEnabled()) {
$bckresult = trim($backend->configdRun("captiveportal restart"));
if ($bckresult == "OK") {
$status = "ok";
} else {
$status = "error reloading captive portal";
}
} else {
$backend->configdRun("captiveportal restart");
$status = "ok";
}
} else {
$status = "error reloading captive portal template";
}
} else { } else {
$status = "error reloading captive portal (".$bckresult.")"; $status = "error reloading captive portal rules (".$bckresult.")";
} }
return array("status" => $status); return array("status" => $status);
......
...@@ -43,16 +43,16 @@ class SettingsController extends ApiControllerBase ...@@ -43,16 +43,16 @@ class SettingsController extends ApiControllerBase
* validate and save model after update or insertion. * validate and save model after update or insertion.
* Use the reference node and tag to rename validation output for a specific node to a new offset, which makes * Use the reference node and tag to rename validation output for a specific node to a new offset, which makes
* it easier to reference specific uuids without having to use them in the frontend descriptions. * it easier to reference specific uuids without having to use them in the frontend descriptions.
* @param $mdlShaper * @param $mdl model reference
* @param $node reference node, to use as relative offset * @param $node reference node, to use as relative offset
* @param $reference reference for validation output, used to rename the validation output keys * @param $reference reference for validation output, used to rename the validation output keys
* @return array result / validation output * @return array result / validation output
*/ */
private function save($mdlShaper, $node = null, $reference = null) private function save($mdl, $node = null, $reference = null)
{ {
$result = array("result"=>"failed","validations" => array()); $result = array("result"=>"failed","validations" => array());
// perform validation // perform validation
$valMsgs = $mdlShaper->performValidation(); $valMsgs = $mdl->performValidation();
foreach ($valMsgs as $field => $msg) { foreach ($valMsgs as $field => $msg) {
// replace absolute path to attribute for relative one at uuid. // replace absolute path to attribute for relative one at uuid.
if ($node != null) { if ($node != null) {
...@@ -66,7 +66,7 @@ class SettingsController extends ApiControllerBase ...@@ -66,7 +66,7 @@ class SettingsController extends ApiControllerBase
// serialize model to config and save when there are no validation errors // serialize model to config and save when there are no validation errors
if (count($result['validations']) == 0) { if (count($result['validations']) == 0) {
// save config if validated correctly // save config if validated correctly
$mdlShaper->serializeToConfig(); $mdl->serializeToConfig();
Config::getInstance()->save(); Config::getInstance()->save();
$result = array("result" => "saved"); $result = array("result" => "saved");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment