Commit 04ccf983 authored by Franco Fichtner's avatar Franco Fichtner

plugins: allow to configure through multiple call sites

This is the glue needed to be entirely plugin-agnostic, it only
needs new hooks for spots we haven't pluginified yet.  The dns
subsystem is another likely candidate in the long run.

Allows to move these plugins away from core: bsnmpd, igmpproxy,
relayd, miniupnpd.  ACL and menu entries pending...
parent e7268a99
......@@ -162,15 +162,23 @@ function plugins_firewall($fw)
return $fw;
}
function plugins_configure($verbose = false)
function plugins_configure($hook, $verbose = false)
{
foreach (plugins_scan() as $name => $path) {
require_once $path;
$func = sprintf('%s_configure', $name);
if (function_exists($func)) {
$workers = $func();
foreach ($workers as $worker) {
$worker($verbose);
foreach ($workers as $when => $worker) {
if (is_array($worker)) {
foreach ($worker as $task) {
$task($verbose);
}
}
/* XXX compat glue from when configure wasn't indexed (remove in 17.1) */
if ($hook == 'bootup' && !is_array($worker)) {
$worker($verbose);
}
}
}
}
......
......@@ -57,7 +57,10 @@ function bsnmpd_services()
function bsnmpd_configure()
{
return array('bsnmpd_configure_do');
return array(
'bootup' => array('bsnmpd_configure_do'),
'interface' => array('bsnmpd_configure_do'),
);
}
function bsnmpd_configure_do($verbose = false)
......
......@@ -56,7 +56,10 @@ function igmpproxy_services()
function igmpproxy_configure()
{
return array('igmpproxy_configure_do');
return array(
'bootup' => array('igmpproxy_configure_do'),
'interface' => array('igmpproxy_configure_do'),
);
}
function igmpproxy_configure_do($verbose = false)
......
......@@ -92,7 +92,10 @@ function relayd_subnetv4_expand($subnet)
function relayd_configure()
{
return array('relayd_configure_do');
return array(
'bootup' => array('relayd_configure_do'),
'xmlrpc' => array('relayd_configure_do'),
);
}
function relayd_configure_do($kill_first = false)
......
......@@ -39,10 +39,7 @@
* files. Maybe eventually this will change...
*/
require_once('dyndns.class');
require_once('plugins.inc.d/bsnmpd.inc');
require_once('plugins.inc.d/dnsmasq.inc');
require_once('plugins.inc.d/igmpproxy.inc');
require_once('plugins.inc.d/relayd.inc');
require_once('plugins.inc.d/unbound.inc');
function generate_ipv6_from_mac($mac)
......
......@@ -140,9 +140,12 @@ function filter_configure_xmlrpc()
dnsmasq_configure_do();
unbound_configure_do();
services_dhcpd_configure();
relayd_configure_do();
openvpn_resync_all();
if (function_exists('plugins_configure')) {
plugins_configure('xmlrpc');
}
return true;
}
......
......@@ -191,9 +191,9 @@ mwexec("/usr/local/etc/rc.dyndns.update");
/* Run a filter configure now that most all services have started */
filter_configure_sync(true);
/* Run all registered plugins */
/* start all registered plugins */
if (function_exists('plugins_configure')) {
plugins_configure(true);
plugins_configure('bootup', true);
}
/* start IPsec tunnels */
......
......@@ -211,9 +211,10 @@ if (!is_ipaddr($oldip) || $curwanip != $oldip || !is_ipaddrv4($config['interface
/* reload graphing functions */
enable_rrd_graphing();
/* XXX reload plugins */
bsnmpd_configure_do();
igmpproxy_configure_do();
/* reload plugins */
if (function_exists('plugins_configure')) {
plugins_configure('interface');
}
/* reconfigure ntpd */
system_ntp_configure(false);
......
......@@ -158,9 +158,10 @@ if (substr($interface_real, 0, 4) != "ovpn")
/* reload graphing functions */
enable_rrd_graphing();
/* XXX reload plugins */
bsnmpd_configure_do();
igmpproxy_configure_do();
/* reload plugins */
if (function_exists('plugins_configure')) {
plugins_configure('interface');
}
/* reconfigure ntpd */
system_ntp_configure(false);
......@@ -523,9 +523,10 @@ if ($_SERVER['REQUEST_METHOD'] === 'GET') {
}
}
}
/* XXX restart plugins o that the bind to correct address */
bsnmpd_configure_do();
igmpproxy_configure_do();
/* restart plugins */
if (function_exists('plugins_configure')) {
plugins_configure('interface');
}
/* sync filter configuration */
setup_gateways_monitor();
filter_configure();
......
......@@ -31,6 +31,7 @@ require_once("guiconfig.inc");
require_once("filter.inc");
require_once("services.inc");
require_once("interfaces.inc");
require_once('plugins.inc.d/relayd.inc');
if (empty($config['load_balancer']['monitor_type']) || !is_array($config['load_balancer']['monitor_type'])) {
$config['load_balancer']['monitor_type'] = array();
......
......@@ -31,6 +31,7 @@ require_once("guiconfig.inc");
require_once("filter.inc");
require_once("services.inc");
require_once("interfaces.inc");
require_once('plugins.inc.d/relayd.inc');
if (empty($config['load_balancer']['lbpool']) || !is_array($config['load_balancer']['lbpool'])) {
$config['load_balancer']['lbpool'] = array();
......
......@@ -32,6 +32,7 @@ require_once("guiconfig.inc");
require_once("filter.inc");
require_once("services.inc");
require_once("interfaces.inc");
require_once('plugins.inc.d/relayd.inc');
if (empty($config['load_balancer']) || !is_array($config['load_balancer'])) {
$config['load_balancer'] = array();
......
......@@ -31,6 +31,7 @@ require_once("guiconfig.inc");
require_once("filter.inc");
require_once("services.inc");
require_once("interfaces.inc");
require_once('plugins.inc.d/relayd.inc');
if (empty($config['load_balancer']['virtual_server']) || !is_array($config['load_balancer']['virtual_server'])) {
$config['load_balancer']['virtual_server'] = array();
......
......@@ -30,6 +30,7 @@
require_once("guiconfig.inc");
require_once("services.inc");
require_once("interfaces.inc");
require_once('plugins.inc.d/relayd.inc');
if (empty($config['load_balancer']) || !is_array($config['load_balancer'])) {
$config['load_balancer'] = array();
......
......@@ -32,6 +32,7 @@
require_once("guiconfig.inc");
require_once("interfaces.inc");
require_once("services.inc");
require_once('plugins.inc.d/igmpproxy.inc');
$a_igmpproxy = array();
if (isset($config['igmpproxy']['igmpentry'])) {
......
......@@ -31,6 +31,7 @@
require_once("guiconfig.inc");
require_once("services.inc");
require_once('plugins.inc.d/igmpproxy.inc');
if (!isset($config['igmpproxy']['igmpentry'])) {
$config['igmpproxy']['igmpentry'] = array();
......
......@@ -31,7 +31,7 @@ require_once("guiconfig.inc");
require_once("interfaces.inc");
require_once("services.inc");
require_once("system.inc");
require_once('plugins.inc.d/bsnmpd.inc');
if ($_SERVER['REQUEST_METHOD'] === 'GET') {
$pconfig = array();
......
......@@ -31,6 +31,7 @@ require_once("guiconfig.inc");
require_once("filter.inc");
require_once("services.inc");
require_once("interfaces.inc");
require_once('plugins.inc.d/relayd.inc');
if (empty($config['load_balancer']) || !is_array($config['load_balancer'])) {
$config['load_balancer'] = array();
......
......@@ -30,6 +30,7 @@
require_once("guiconfig.inc");
require_once("filter.inc");
require_once("services.inc");
require_once('plugins.inc.d/relayd.inc');
if (empty($config['load_balancer']['lbpool']) || !is_array($config['load_balancer']['lbpool'])) {
$a_pool = array();
......
......@@ -34,6 +34,7 @@
require_once("guiconfig.inc");
require_once("filter.inc");
require_once("services.inc");
require_once('plugins.inc.d/relayd.inc');
$now = time();
$year = date("Y");
......
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