dyndns/rfc2136: proper enabled helper

This commit is contained in:
Franco Fichtner 2017-03-19 20:33:06 +01:00
parent 66de2bde0e
commit d51dd4adf1
2 changed files with 28 additions and 7 deletions

View File

@ -41,11 +41,28 @@ function dyndns_configure()
);
}
function dyndns_enabled()
{
global $config;
if (isset($config['dyndnses']['dyndns'])) {
foreach ($config['dyndnses']['dyndns'] as $conf) {
if (isset($conf['enable'])) {
return true;
}
}
}
return false;
}
function dyndns_cron()
{
$jobs = array();
$jobs[]['autocron'] = array('/usr/local/etc/rc.dyndns.update', '11', '1');
if (dyndns_enabled()) {
$jobs[]['autocron'] = array('/usr/local/etc/rc.dyndns.update', '11', '1');
}
return $jobs;
}
@ -119,15 +136,12 @@ function dyndns_configure_do($verbose = false, $int = '')
{
global $config;
if (!isset($config['dyndnses']['dyndns'])) {
if (!dyndns_enabled()) {
return;
}
$dyndnscfg = $config['dyndnses']['dyndns'];
$gwgroups = return_gateway_groups_array();
if (!is_array($dyndnscfg)) {
return;
}
if ($verbose) {
echo 'Configuring dynamic DNS clients...';

View File

@ -42,8 +42,15 @@ function rfc2136_enabled()
{
global $config;
/* XXX not entirely correct */
return isset($config['dnsupdates']['dnsupdate']);
if (isset($config['dnsupdates']['dnsupdate'])) {
foreach ($config['dnsupdates']['dnsupdate'] as $dnsupdate) {
if (isset($dnsupdate['enable'])) {
return true;
}
}
}
return false;
}
function rfc2136_cron()