summaryrefslogtreecommitdiff
path: root/src/conf_mode/service_mdns-repeater.py
diff options
context:
space:
mode:
authorIndrajit Raychaudhuri <irc@indrajit.com>2023-11-07 14:03:20 -0600
committerMergify <37929162+mergify[bot]@users.noreply.github.com>2023-12-01 05:39:38 +0000
commitccee236ee5f60969e07df5578dd1cb95f8573d82 (patch)
tree23c1cab772d9ca030f23d0b9a0a615b544b6e5a3 /src/conf_mode/service_mdns-repeater.py
parent652e235894aeae46765ea9fbbe2208578aaa7a8c (diff)
downloadvyos-1x-ccee236ee5f60969e07df5578dd1cb95f8573d82.tar.gz
vyos-1x-ccee236ee5f60969e07df5578dd1cb95f8573d82.zip
mdns: T5723: Always reload systemd daemon before applying changes
Additionally, templatize system service override and move it to the runtime path. (cherry picked from commit eb906739047187c322b6ce9efe7c9479bed9a024)
Diffstat (limited to 'src/conf_mode/service_mdns-repeater.py')
-rwxr-xr-xsrc/conf_mode/service_mdns-repeater.py14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/conf_mode/service_mdns-repeater.py b/src/conf_mode/service_mdns-repeater.py
index 6909731ff..6526c23d1 100755
--- a/src/conf_mode/service_mdns-repeater.py
+++ b/src/conf_mode/service_mdns-repeater.py
@@ -29,6 +29,7 @@ from vyos import airbag
airbag.enable()
config_file = '/run/avahi-daemon/avahi-daemon.conf'
+systemd_override = r'/run/systemd/system/avahi-daemon.service.d/override.conf'
vrrp_running_file = '/run/mdns_vrrp_active'
def get_config(config=None):
@@ -48,6 +49,8 @@ def get_config(config=None):
if mdns:
mdns['vrrp_exists'] = conf.exists('high-availability vrrp')
+ mdns['config_file'] = config_file
+
return mdns
def verify(mdns):
@@ -101,11 +104,16 @@ def generate(mdns):
return None
render(config_file, 'mdns-repeater/avahi-daemon.conf.j2', mdns)
+ render(systemd_override, 'mdns-repeater/override.conf.j2', mdns)
return None
def apply(mdns):
+ systemd_service = 'avahi-daemon.service'
+ # Reload systemd manager configuration
+ call('systemctl daemon-reload')
+
if not mdns or 'disable' in mdns:
- call('systemctl stop avahi-daemon.service')
+ call(f'systemctl stop {systemd_service}')
if os.path.exists(config_file):
os.unlink(config_file)
@@ -120,10 +128,10 @@ def apply(mdns):
os.mknod(vrrp_running_file) # vrrp script looks for this file to update mdns repeater
if len(mdns['interface']) < 2:
- call('systemctl stop avahi-daemon.service')
+ call(f'systemctl stop {systemd_service}')
return None
- call('systemctl restart avahi-daemon.service')
+ call(f'systemctl restart {systemd_service}')
return None