diff --git a/Makefile b/Makefile index cee72ad64..c1b2f85a8 100644 --- a/Makefile +++ b/Makefile @@ -167,9 +167,10 @@ CORE_DEPENDS?= ca_root_nss \ php${CORE_PHP}-gettext \ php${CORE_PHP}-google-api-php-client \ php${CORE_PHP}-ldap \ + php${CORE_PHP}-pcntl \ php${CORE_PHP}-pdo \ - php${CORE_PHP}-pecl-radius \ php${CORE_PHP}-pear-Crypt_CHAP \ + php${CORE_PHP}-pecl-radius \ php${CORE_PHP}-phalcon \ php${CORE_PHP}-phpseclib \ php${CORE_PHP}-session \ diff --git a/src/etc/inc/plugins.inc.d/dpinger.inc b/src/etc/inc/plugins.inc.d/dpinger.inc index 048bd8a52..f12d5c06d 100644 --- a/src/etc/inc/plugins.inc.d/dpinger.inc +++ b/src/etc/inc/plugins.inc.d/dpinger.inc @@ -319,12 +319,17 @@ function dpinger_configure_do($verbose = false, $gwname = null, $bootup = false) } if (count(dpinger_services())) { - /* use a separate script to produce the monitor alerts which runs forever */ - mwexecf( - '/usr/sbin/daemon -f -p %s /usr/local/opnsense/scripts/routes/gateway_watcher.php %s', - ['/var/run/gateway_watcher.pid', 'interface routes alarm'], - true - ); + if (isvalidpid('/var/run/gateway_watcher.pid')) { + /* indicate that the configuration needs a reload */ + killbypid('/var/run/gateway_watcher.pid', 'HUP'); + } else { + /* use a separate script to produce the monitor alerts which runs forever */ + mwexecf( + '/usr/sbin/daemon -f -p %s /usr/local/opnsense/scripts/routes/gateway_watcher.php %s', + ['/var/run/gateway_watcher.pid', 'interface routes alarm'], + true + ); + } } else { killbypid('/var/run/gateway_watcher.pid'); } diff --git a/src/opnsense/scripts/routes/gateway_watcher.php b/src/opnsense/scripts/routes/gateway_watcher.php index e67debbff..248650205 100755 --- a/src/opnsense/scripts/routes/gateway_watcher.php +++ b/src/opnsense/scripts/routes/gateway_watcher.php @@ -31,7 +31,18 @@ require_once 'config.inc'; require_once 'util.inc'; require_once 'interfaces.inc'; +function signalhandler($signal) +{ + global $config; + + OPNsense\Core\Config::getInstance()->forceReload(); + $config = parse_config(); + + syslog(LOG_NOTICE, 'Reloaded gateway watcher configuration on SIGHUP'); +} + openlog('dpinger', LOG_DAEMON, LOG_LOCAL4); +pcntl_signal(SIGHUP, 'signalhandler'); $action = !empty($argv[1]) ? $argv[1] : null; @@ -43,12 +54,10 @@ $mode = []; sleep($wait); while (1) { - $alarm = false; - - OPNsense\Core\Config::getInstance()->forceReload(); - $config = parse_config(); + pcntl_signal_dispatch(); $status = return_gateways_status(); + $alarm = false; /* clear known gateways in first step to flush unknown in second step */ $cleanup = $mode;