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

plugins: support start and restart

parent 4635ac7b
......@@ -49,6 +49,19 @@ function plugin_scan()
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()
{
$services = array();
......
<?php
/*
Copyright (C) 2008 Shrew Soft Inc
Copyright (C) 2008 Ermal Luçi
Copyright (C) 2004 Scott Ullrich
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:
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
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
AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
POSSIBILITY OF SUCH DAMAGE.
*/
* Coypright (C) 2016 Franco Fichtner <franco@opnsense.org>
* Copyright (C) 2008 Shrew Soft Inc
* Copyright (C) 2008 Ermal Luçi
* Copyright (C) 2004 Scott Ullrich
* 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:
*
* 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
* 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
* AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
* AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
function vpn_configure()
{
......@@ -45,24 +46,48 @@ function vpn_services()
$services = array();
if (isset($config['pptpd']['mode']) && $config['pptpd']['mode'] != 'off') {
$pconfig = array();
$pconfig['name'] = 'pptpd';
$pconfig['description'] = gettext('PPTP Server');
$pconfig['pidfile'] = '/var/run/pptp-vpn.pid';
$services[] = $pconfig;
$services[] = array(
'description' => gettext('PPTP Server'),
'pidfile' => '/var/run/pptp-vpn.pid',
'plugin' => 'vpn',
'name' => 'pptpd',
);
}
if (isset($config['l2tp']['mode']) && $config['l2tp']['mode'] != 'off') {
$pconfig = array();
$pconfig['name'] = 'l2tpd';
$pconfig['description'] = gettext('L2TP Server');
$pconfig['pidfile'] = '/var/run/l2tp-vpn.pid';
$services[] = $pconfig;
$services[] = array(
'description' => gettext('L2TP Server'),
'pidfile' => '/var/run/l2tp-vpn.pid',
'plugin' => 'vpn',
'name' => 'l2tpd',
);
}
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() {
$iflist = get_configured_interface_list();
foreach ($iflist as $iface) {
......
......@@ -273,8 +273,8 @@ function print_service_banner($service)
}
}
function get_std_save_message() {
global $d_sysrebootreqd_path;
function get_std_save_message()
{
$filter_related = false;
$filter_pages = array("nat", "filter");
$to_return = gettext("The changes have been applied successfully.");
......
......@@ -40,16 +40,9 @@ if ($_POST) {
$pconfig = $_POST;
if ($_POST['apply']) {
$retval = 0;
if (!is_subsystem_dirty('rebootreq')) {
$retval = vpn_l2tp_configure();
}
vpn_l2tp_configure();
$savemsg = get_std_save_message();
if ($retval == 0) {
if (is_subsystem_dirty('l2tpusers')) {
clear_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