summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristian Poessinger <christian@poessinger.com>2022-03-24 17:42:59 +0100
committerChristian Poessinger <christian@poessinger.com>2022-03-24 17:45:35 +0100
commit27141654b3cca3083ac50177871235a4eae822ec (patch)
tree4eb21e8f56e0cc85881a66c6620f701ae4ee5ab3
parent2ccd2fffdc342b5e30711476d221ef67fe0e3de7 (diff)
downloadvyos-1x-27141654b3cca3083ac50177871235a4eae822ec.tar.gz
vyos-1x-27141654b3cca3083ac50177871235a4eae822ec.zip
openvpn: T4294: force service restart on openvpn-option node change
(cherry picked from commit 999b1e50dfdea8694174e82d22b2438cb1bf5e28)
-rwxr-xr-xsrc/conf_mode/interfaces-openvpn.py10
1 files changed, 9 insertions, 1 deletions
diff --git a/src/conf_mode/interfaces-openvpn.py b/src/conf_mode/interfaces-openvpn.py
index d9276c4aa..2ca7b1ee0 100755
--- a/src/conf_mode/interfaces-openvpn.py
+++ b/src/conf_mode/interfaces-openvpn.py
@@ -29,6 +29,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.configverify import verify_diffie_hellman_length
@@ -80,6 +81,10 @@ def get_config(config=None):
base = ['interfaces', 'openvpn']
openvpn = get_interface_dict(conf, base)
+ if 'deleted' not in openvpn:
+ tmp = leaf_node_changed(conf, ['openvpn-option'])
+ if tmp: openvpn['restart_required'] = ''
+
openvpn['auth_user_pass_file'] = '/run/openvpn/{ifname}.pw'.format(**openvpn)
return openvpn
@@ -509,7 +514,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')
conf = VTunIf.get_config()
conf['device_type'] = openvpn['device_type']