diff options
author | Christian Poessinger <christian@poessinger.com> | 2022-03-24 17:42:59 +0100 |
---|---|---|
committer | Christian Poessinger <christian@poessinger.com> | 2022-03-24 17:43:53 +0100 |
commit | 999b1e50dfdea8694174e82d22b2438cb1bf5e28 (patch) | |
tree | 866e9e0f6ad8bb399cef1aa9e5084f0fa3e9aba3 | |
parent | d193e5cb9040bfca5011400acef601e8c7111346 (diff) | |
download | vyos-1x-999b1e50dfdea8694174e82d22b2438cb1bf5e28.tar.gz vyos-1x-999b1e50dfdea8694174e82d22b2438cb1bf5e28.zip |
openvpn: T4294: force service restart on openvpn-option node change
-rwxr-xr-x | src/conf_mode/interfaces-openvpn.py | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/src/conf_mode/interfaces-openvpn.py b/src/conf_mode/interfaces-openvpn.py index 29a25eedc..c30c0bdd0 100755 --- a/src/conf_mode/interfaces-openvpn.py +++ b/src/conf_mode/interfaces-openvpn.py @@ -32,6 +32,7 @@ from shutil import rmtree from vyos.config import Config from vyos.configdict import get_interface_dict +from vyos.configdict import leaf_node_changed from vyos.configverify import verify_vrf from vyos.configverify import verify_bridge_delete from vyos.ifconfig import VTunIf @@ -88,6 +89,9 @@ def get_config(config=None): if 'deleted' not in openvpn: openvpn['pki'] = tmp_pki + tmp = leaf_node_changed(conf, ['openvpn-option']) + if tmp: openvpn['restart_required'] = '' + # We have to get the dict using 'get_config_dict' instead of 'get_interface_dict' # as 'get_interface_dict' merges the defaults in, so we can not check for defaults in there. tmp = conf.get_config_dict(base + [openvpn['ifname']], get_first_key=True) @@ -651,7 +655,10 @@ def apply(openvpn): # No matching OpenVPN process running - maybe it got killed or none # existed - nevertheless, spawn new OpenVPN process - call(f'systemctl reload-or-restart openvpn@{interface}.service') + action = 'reload-or-restart' + if 'restart_required' in openvpn: + action = 'restart' + call(f'systemctl {action} openvpn@{interface}.service') o = VTunIf(**openvpn) o.update(openvpn) |