Commit 269b9b6a authored by Franco Fichtner's avatar Franco Fichtner

plugins: support start and restart

parent 4635ac7b
...@@ -49,6 +49,19 @@ function plugin_scan() ...@@ -49,6 +49,19 @@ function plugin_scan()
return $ret; return $ret;
} }
function plugins_action($service, $action)
{
if (!isset($service['plugin'])) {
return;
}
/* avoid auto-loading, it must have been required before */
$func = sprintf('%s_action', $service['plugin']);
if (function_exists($func)) {
$func($service, $action);
}
}
function plugins_services() function plugins_services()
{ {
$services = array(); $services = array();
......
<?php <?php
/* /*
Copyright (C) 2008 Shrew Soft Inc * Coypright (C) 2016 Franco Fichtner <franco@opnsense.org>
Copyright (C) 2008 Ermal Luçi * Copyright (C) 2008 Shrew Soft Inc
Copyright (C) 2004 Scott Ullrich * Copyright (C) 2008 Ermal Luçi
Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net> * Copyright (C) 2004 Scott Ullrich
All rights reserved. * Copyright (C) 2003-2004 Manuel Kasper <mk@neon1.net>
* All rights reserved.
Redistribution and use in source and binary forms, with or without *
modification, are permitted provided that the following conditions are met: * Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, *
this list of conditions and the following disclaimer. * 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright *
notice, this list of conditions and the following disclaimer in the * 2. Redistributions in binary form must reproduce the above copyright
documentation and/or other materials provided with the distribution. * notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, *
INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF * AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS * OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
POSSIBILITY OF SUCH DAMAGE. * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
*/ * POSSIBILITY OF SUCH DAMAGE.
*/
function vpn_configure() function vpn_configure()
{ {
...@@ -45,24 +46,48 @@ function vpn_services() ...@@ -45,24 +46,48 @@ function vpn_services()
$services = array(); $services = array();
if (isset($config['pptpd']['mode']) && $config['pptpd']['mode'] != 'off') { if (isset($config['pptpd']['mode']) && $config['pptpd']['mode'] != 'off') {
$pconfig = array(); $services[] = array(
$pconfig['name'] = 'pptpd'; 'description' => gettext('PPTP Server'),
$pconfig['description'] = gettext('PPTP Server'); 'pidfile' => '/var/run/pptp-vpn.pid',
$pconfig['pidfile'] = '/var/run/pptp-vpn.pid'; 'plugin' => 'vpn',
$services[] = $pconfig; 'name' => 'pptpd',
);
} }
if (isset($config['l2tp']['mode']) && $config['l2tp']['mode'] != 'off') { if (isset($config['l2tp']['mode']) && $config['l2tp']['mode'] != 'off') {
$pconfig = array(); $services[] = array(
$pconfig['name'] = 'l2tpd'; 'description' => gettext('L2TP Server'),
$pconfig['description'] = gettext('L2TP Server'); 'pidfile' => '/var/run/l2tp-vpn.pid',
$pconfig['pidfile'] = '/var/run/l2tp-vpn.pid'; 'plugin' => 'vpn',
$services[] = $pconfig; 'name' => 'l2tpd',
);
} }
return $services; return $services;
} }
function vpn_action($service, $action)
{
if ($action != 'start' && $action != 'restart') {
/* XXX also need stop */
return;
}
switch ($service['name']) {
case 'l2tpd':
vpn_l2tp_configure();
break;
case 'pptpd':
vpn_pptpd_configure();
break;
case 'pppoe':
/* XXX TBD */
break;
default:
break;
}
}
function vpn_netgraph_support() { function vpn_netgraph_support() {
$iflist = get_configured_interface_list(); $iflist = get_configured_interface_list();
foreach ($iflist as $iface) { foreach ($iflist as $iface) {
......
...@@ -273,8 +273,8 @@ function print_service_banner($service) ...@@ -273,8 +273,8 @@ function print_service_banner($service)
} }
} }
function get_std_save_message() { function get_std_save_message()
global $d_sysrebootreqd_path; {
$filter_related = false; $filter_related = false;
$filter_pages = array("nat", "filter"); $filter_pages = array("nat", "filter");
$to_return = gettext("The changes have been applied successfully."); $to_return = gettext("The changes have been applied successfully.");
......
...@@ -40,16 +40,9 @@ if ($_POST) { ...@@ -40,16 +40,9 @@ if ($_POST) {
$pconfig = $_POST; $pconfig = $_POST;
if ($_POST['apply']) { if ($_POST['apply']) {
$retval = 0; vpn_l2tp_configure();
if (!is_subsystem_dirty('rebootreq')) {
$retval = vpn_l2tp_configure();
}
$savemsg = get_std_save_message(); $savemsg = get_std_save_message();
if ($retval == 0) { clear_subsystem_dirty('l2tpusers');
if (is_subsystem_dirty('l2tpusers')) {
clear_subsystem_dirty('l2tpusers');
}
}
} }
} }
......
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