From 6d7d0bc357070778fac9147e4e3c9e548cd0d952 Mon Sep 17 00:00:00 2001 From: Franco Fichtner Date: Sun, 21 Feb 2016 20:02:21 +0100 Subject: [PATCH] vpn: plug pppoe servers into services --- src/etc/inc/plugins.inc.d/vpn.inc | 43 ++++++++++++++++++++++++++++++- 1 file changed, 42 insertions(+), 1 deletion(-) diff --git a/src/etc/inc/plugins.inc.d/vpn.inc b/src/etc/inc/plugins.inc.d/vpn.inc index 77a25d76c..557b0c145 100644 --- a/src/etc/inc/plugins.inc.d/vpn.inc +++ b/src/etc/inc/plugins.inc.d/vpn.inc @@ -69,7 +69,23 @@ function vpn_services() ); } - /* XXX pppoe server instances too */ + if (isset($config['pppoes']['pppoe'])) { + foreach ($config['pppoes']['pppoe'] as $pppoecfg) { + if (isset($pppoecfg['mode']) || $pppoecfg['mode'] != 'off') { + $services[] = array( + 'description' => gettext('PPPoE Server') . ': ' . htmlspecialchars($pppoecfg['descr']), + 'php' => array( + 'restart' => array('vpn_pppoe_configure_by_id'), + 'start' => array('vpn_pppoe_configure_by_id'), + 'args' => array('pppoeid'), + ), + 'pidfile' => "/var/run/pppoe{$pppoecfg['pppoeid']}-vpn.pid", + 'pppoeid' => $pppoecfg['pppoeid'], + 'name' => 'pppoed', + ); + } + } + } return $services; } @@ -319,6 +335,31 @@ function vpn_pppoes_configure() } } +function vpn_pppoe_configure_by_id($id) +{ + global $config; + + $found = null; + + if (isset($config['pppoes']['pppoe'])) { + foreach ($config['pppoes']['pppoe'] as $pppoe) { + if (!isset($pppoe['mode']) || $pppoe['mode'] == 'off') { + continue; + } + if ($id != 0 && $id == $pppoe['pppoeid']) { + $found = $pppoe; + break; + } + } + } + + if ($found == null) { + return; + } + + vpn_pppoe_configure($found); +} + function vpn_pppoe_configure(&$pppoecfg) { global $config;