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;
use \OPNsense\Base\ApiControllerBase;
use \OPNsense\Core\Backend;
use \OPNsense\CaptivePortal\CaptivePortal;
/**
* Class ServiceController
......@@ -53,11 +54,25 @@ class ServiceController extends ApiControllerBase
$bckresult = trim($backend->configdRun("ipfw reload"));
if ($bckresult == "OK") {
// generate captive portal config
$backend->configdRun("template reload OPNsense.Captiveportal");
// TODO: implement portal webservers restart/reconfigure
$status = "ok";
$bckresult = trim($backend->configdRun("template reload OPNsense.Captiveportal"));
if ($bckresult == "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 {
$status = "error reloading captive portal (".$bckresult.")";
$status = "error reloading captive portal rules (".$bckresult.")";
}
return array("status" => $status);
......
......@@ -43,16 +43,16 @@ class SettingsController extends ApiControllerBase
* 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
* 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 $reference reference for validation output, used to rename the validation output keys
* @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());
// perform validation
$valMsgs = $mdlShaper->performValidation();
$valMsgs = $mdl->performValidation();
foreach ($valMsgs as $field => $msg) {
// replace absolute path to attribute for relative one at uuid.
if ($node != null) {
......@@ -66,7 +66,7 @@ class SettingsController extends ApiControllerBase
// serialize model to config and save when there are no validation errors
if (count($result['validations']) == 0) {
// save config if validated correctly
$mdlShaper->serializeToConfig();
$mdl->serializeToConfig();
Config::getInstance()->save();
$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