From f8804b74f91523f447ce939250f4180dcc201bfa Mon Sep 17 00:00:00 2001 From: Phil Davis Date: Tue, 1 Oct 2013 22:03:16 -0700 Subject: Check for disabled OpenVPN instances in openvpn_resync_if_needed It is much cleaner if we check first for disabled OpenVPN instances, before diving into all the other checks. Note, the final openvpn_resync() does call other routines that finally check if the instance is disabled, but there are so many checks here for various conditions to be met before calling openvpn_resync that it looks better (safer) to bail out early if the instance is disabled. --- etc/rc.openvpn | 26 +++++++++++++++----------- 1 file changed, 15 insertions(+), 11 deletions(-) diff --git a/etc/rc.openvpn b/etc/rc.openvpn index 8cf9ea2..7ec7df8 100755 --- a/etc/rc.openvpn +++ b/etc/rc.openvpn @@ -42,17 +42,21 @@ function openvpn_resync_if_needed ($mode, $ovpn_settings, $interface) { global $g, $config; $resync_needed = true; - if (!empty($interface)) { - $mode_id = $mode . $ovpn_settings['vpnid']; - $fpath = "{$g['varetc_path']}/openvpn/{$mode_id}.interface"; - 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 (isset($ovpn_settings['disable'])) { + $resync_needed = false; + } else { + if (!empty($interface)) { + $mode_id = $mode . $ovpn_settings['vpnid']; + $fpath = "{$g['varetc_path']}/openvpn/{$mode_id}.interface"; + 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; + } } } } -- cgit v1.1