net/zerotier: Prevent invalid 'local.conf' on initial save.

There is potential for an invalid local.conf to be written out during first
save. Whilst it doesn't stop Zerotier from starting, it does cause it to
return a 1 as an error code, thus fooling configd that the service has failed
to start. Adding in a default '{}' resolves this issue.

-=david=-
This commit is contained in:
David Harrigan
2017-10-14 08:53:21 +02:00
committed by Franco Fichtner
parent b384ce560f
commit 14c1b3b447
2 changed files with 5 additions and 0 deletions
@@ -48,6 +48,9 @@ class SettingsController extends ApiMutableModelControllerBase
$result = array();
if ($this->request->isGet()) {
$mdlZerotier = $this->getModel();
if(empty($mdlZerotier->localconf->__toString())) {
$mdlZerotier->localconf = '{}';
}
$result = array("zerotier" => $mdlZerotier->getNodes());
}
return $result;
@@ -1,3 +1,5 @@
{% if helpers.exists('OPNsense.zerotier.localconf') and OPNsense.zerotier.localconf|default("") != "" %}
{{ OPNsense.zerotier.localconf }}
{% else %}
{}
{% endif %}