mirror of
https://github.com/netbirdio/plugins.git
synced 2026-05-22 18:44:07 -07:00
dns/ddclient - prevent model usage in ddclient_services()
The ddclient model uses configd for additional info, which makes model initialization a bit slower than usual. When only checking if the module is used, accessing the config object saves a lot of time.
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
PLUGIN_NAME= ddclient
|
||||
PLUGIN_VERSION= 1.21
|
||||
PLUGIN_REVISION= 1
|
||||
PLUGIN_REVISION= 2
|
||||
PLUGIN_DEPENDS= ddclient py${PLUGIN_PYTHON}-boto3
|
||||
PLUGIN_COMMENT= Dynamic DNS client
|
||||
PLUGIN_MAINTAINER= ad@opnsense.org
|
||||
|
||||
@@ -30,9 +30,13 @@
|
||||
function ddclient_services()
|
||||
{
|
||||
$services = [];
|
||||
$cnf = \OPNsense\Core\Config::getInstance()->object();
|
||||
$is_enabled = false;
|
||||
if ($cnf->OPNsense && $cnf->OPNsense->DynDNS && $cnf->OPNsense->DynDNS->general){
|
||||
$is_enabled = $cnf->OPNsense->DynDNS->general->enabled == '1';
|
||||
}
|
||||
|
||||
$mdl = new \OPNsense\DynDNS\DynDNS();
|
||||
if ($mdl->general->enabled == '1') {
|
||||
if ($is_enabled) {
|
||||
$service = [
|
||||
'description' => gettext('ddclient'),
|
||||
'configd' => [
|
||||
@@ -42,7 +46,7 @@ function ddclient_services()
|
||||
],
|
||||
'name' => 'ddclient',
|
||||
];
|
||||
$service['pidfile'] = (string)$mdl->general->backend != 'opnsense' ? '/var/run/ddclient.pid' : '/var/run/ddclient_opn.pid';
|
||||
$service['pidfile'] = $cnf->OPNsense->DynDNS->general->backend != 'opnsense' ? '/var/run/ddclient.pid' : '/var/run/ddclient_opn.pid';
|
||||
$services[] = $service;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user