Add safety belts to code in rc.openvpn to avoid php errors to leave stale locks around

This commit is contained in:
Ermal 2013-09-04 08:31:34 +00:00
parent 48085d0cc8
commit 5d1bde9670

View File

@ -41,19 +41,22 @@ require_once("openvpn.inc");
function openvpn_resync_if_needed ($mode, $ovpn_settings, $interface) {
global $g, $config;
$resync_needed = false;
if (empty($interface)) {
$resync_needed = true;
} else {
$resync_needed = true;
if (!empty($interface)) {
$mode_id = $mode . $ovpn_settings['vpnid'];
$fpath = "{$g['varetc_path']}/openvpn/{$mode_id}.interface";
$current_device = file_get_contents($fpath);
$new_device = get_failover_interface($ovpn_settings['interface']);
$this_device = $config['interfaces'][$interface]['if'];
if (($current_device != $new_device) || ($current_device == $this_device) || ($new_device == $this_device))
$resync_needed = true;
if (file_exists($fpath)) {
$current_device = file_get_contents($fpath);
$current_device = trim($current_device, " \t\n");
$new_device = get_failover_interface($ovpn_settings['interface']);
if (isset($config['interfaces'][$interface])) {
$this_device = $config['interfaces'][$interface]['if'];
if (($current_device == $new_device) || ($current_device != $this_device) || ($new_device != $this_device))
$resync_needed = false;
}
}
}
if ($resync_needed) {
if ($resync_needed == true) {
log_error("OpenVPN: Resync " . $mode_id . " " . $ovpn_settings['description']);
openvpn_resync($mode, $ovpn_settings);
}