mirror of
https://github.com/pfsense/pfsense.git
synced 2025-10-26 11:38:35 +00:00
Use the actual openvpn restart routine when starting/stopping from services rather than killing/restarting manually.
This commit is contained in:
parent
b9f6677017
commit
ef84458311
@ -1047,4 +1047,35 @@ function openvpn_clear_route($mode, $settings) {
|
||||
}
|
||||
}
|
||||
|
||||
function openvpn_get_settings($mode, $vpnid) {
|
||||
global $config;
|
||||
|
||||
if (is_array($config['openvpn']['openvpn-server'])) {
|
||||
foreach ($config['openvpn']['openvpn-server'] as $settings) {
|
||||
if (isset($settings['disable']))
|
||||
continue;
|
||||
|
||||
if ($vpnid != 0 && $vpnid == $settings['vpnid'])
|
||||
return $settings;
|
||||
}
|
||||
}
|
||||
|
||||
if (is_array($config['openvpn']['openvpn-client'])) {
|
||||
foreach ($config['openvpn']['openvpn-client'] as $settings) {
|
||||
if (isset($settings['disable']))
|
||||
continue;
|
||||
|
||||
if ($vpnid != 0 && $vpnid == $settings['vpnid'])
|
||||
return $settings;
|
||||
}
|
||||
}
|
||||
|
||||
return array();
|
||||
}
|
||||
|
||||
function openvpn_restart_by_vpnid($mode, $vpnid) {
|
||||
$settings = openvpn_get_settings($mode, $vpnid);
|
||||
openvpn_restart($mode, $settings);
|
||||
}
|
||||
|
||||
?>
|
||||
|
||||
@ -40,6 +40,7 @@
|
||||
require_once("guiconfig.inc");
|
||||
require_once("captiveportal.inc");
|
||||
require_once("service-utils.inc");
|
||||
require_once("openvpn.inc");
|
||||
require_once("ipsec.inc");
|
||||
require_once("vpn.inc");
|
||||
require_once("vslb.inc");
|
||||
@ -94,12 +95,8 @@ if($_GET['mode'] == "restartservice" and !empty($_GET['service'])) {
|
||||
if ($vpnmode == "server" || $vpnmode == "client") {
|
||||
$id = $_GET['id'];
|
||||
$configfile = "{$g['varetc_path']}/openvpn/{$vpnmode}{$id}.conf";
|
||||
$pidfile = $g['varrun_path'] . "/openvpn_{$vpnmode}{$id}.pid";
|
||||
if (file_exists($configfile)) {
|
||||
killbypid($pidfile);
|
||||
sleep(1);
|
||||
mwexec_bg("/usr/local/sbin/openvpn --config {$configfile}");
|
||||
}
|
||||
if (file_exists($configfile))
|
||||
openvpn_restart_by_vpnid($vpnmode, $id);
|
||||
}
|
||||
break;
|
||||
case 'relayd':
|
||||
@ -146,7 +143,7 @@ if($_GET['mode'] == "startservice" and !empty($_GET['service'])) {
|
||||
$id = $_GET['id'];
|
||||
$configfile = "{$g['varetc_path']}/openvpn/{$vpnmode}{$id}.conf";
|
||||
if (file_exists($configfile))
|
||||
mwexec_bg("/usr/local/sbin/openvpn --config {$configfile}");
|
||||
openvpn_restart_by_vpnid($vpnmode, $id);
|
||||
}
|
||||
break;
|
||||
case 'relayd':
|
||||
|
||||
Loading…
Reference in New Issue
Block a user