Skip to content

Commit

Permalink
ddclient: T5791: Relocate process params to ExecStart
Browse files Browse the repository at this point in the history
Pull up all the global parameters controlling
process behavior to systemd service.

Also remove `syslog=yes`` as it is not needed with
`exec` type service.
  • Loading branch information
indrajitr committed Jan 9, 2025
1 parent 53cb3e5 commit a328575
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 9 deletions.
3 changes: 0 additions & 3 deletions data/templates/dns-dynamic/ddclient.conf.j2
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,7 @@ if{{ ipv }}={{ address }}, \
{{ host }}
{% endmacro %}
### Autogenerated by service_dns_dynamic.py ###
daemon={{ interval }}
syslog=yes
ssl=yes
cache={{ config_file | replace('.conf', '.cache') }}
{# ddclient default (web=dyndns) doesn't support ssl and results in process lockup #}
web=googledomains
{# ddclient default (use=ip) results in confusing warning message in log #}
Expand Down
3 changes: 2 additions & 1 deletion data/templates/dns-dynamic/override.conf.j2
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
{% set vrf_command = 'ip vrf exec ' ~ vrf ~ ' ' if vrf is vyos_defined else '' %}
{% set cache_file = config_file.replace('.conf', '.cache') %}
[Unit]
ConditionPathExists={{ config_file }}
Wants=
Expand All @@ -7,5 +8,5 @@ After=vyos-router.service
[Service]
EnvironmentFile=
ExecStart=
ExecStart={{ vrf_command }}/usr/bin/ddclient --file {{ config_file }} --foreground
ExecStart={{ vrf_command }}/usr/bin/ddclient --file {{ config_file }} --cache {{ cache_file }} --foreground --daemon {{ interval }}
Restart=always
19 changes: 14 additions & 5 deletions smoketest/scripts/cli/test_service_dns_dynamic.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,18 @@
from base_vyostest_shim import VyOSUnitTestSHIM

from vyos.configsession import ConfigSessionError
from vyos.utils.file import read_file
from vyos.utils.process import cmd
from vyos.utils.process import process_named_running
from vyos.xml_ref import default_value

DDCLIENT_SYSTEMD_UNIT = '/run/systemd/system/ddclient.service.d/override.conf'
DDCLIENT_CONF = '/run/ddclient/ddclient.conf'
DDCLIENT_PNAME = 'ddclient'

base_path = ['service', 'dns', 'dynamic']
name_path = base_path + ['name']
default_interval = default_value(base_path + ['interval'])
server = 'ddns.vyos.io'
hostname = 'test.ddns.vyos.io'
zone = 'vyos.io'
Expand Down Expand Up @@ -95,12 +98,14 @@ def test_01_dyndns_service_standard(self):

# Check the generating config parameters
ddclient_conf = cmd(f'sudo cat {DDCLIENT_CONF}')
# default value 300 seconds
self.assertIn(f'daemon=300', ddclient_conf)
self.assertIn(f'usev4=ifv4', ddclient_conf)
self.assertIn(f'ifv4={interface}', ddclient_conf)
self.assertIn(f'password=\'{password}\'', ddclient_conf)

# Check default interval of 300 seconds
systemd_override = read_file(DDCLIENT_SYSTEMD_UNIT)
self.assertIn(f'--daemon {default_interval}', systemd_override)

for opt in details.keys():
if opt == 'username':
login = details[opt]
Expand Down Expand Up @@ -140,7 +145,6 @@ def test_02_dyndns_service_ipv6(self):

# Check the generating config parameters
ddclient_conf = cmd(f'sudo cat {DDCLIENT_CONF}')
self.assertIn(f'daemon={interval}', ddclient_conf)
self.assertIn(f'usev6=ifv6', ddclient_conf)
self.assertIn(f'ifv6={interface}', ddclient_conf)
self.assertIn(f'protocol={proto}', ddclient_conf)
Expand All @@ -150,6 +154,10 @@ def test_02_dyndns_service_ipv6(self):
self.assertIn(f'min-interval={wait_time}', ddclient_conf)
self.assertIn(f'max-interval={expiry_time_good}', ddclient_conf)

# default value 300 seconds
systemd_override = read_file(DDCLIENT_SYSTEMD_UNIT)
self.assertIn(f'--daemon {interval}', systemd_override)

# IPv4+IPv6 dual DDNS service configuration
def test_03_dyndns_service_dual_stack(self):
services = {'cloudflare': {'protocol': 'cloudflare', 'zone': zone},
Expand Down Expand Up @@ -339,9 +347,10 @@ def test_08_dyndns_vrf(self):
self.cli_commit()

# Check for process in VRF
systemd_override = cmd(f'cat {DDCLIENT_SYSTEMD_UNIT}')
systemd_override = read_file(DDCLIENT_SYSTEMD_UNIT)
self.assertIn(f'ExecStart=ip vrf exec {vrf_name} /usr/bin/ddclient ' \
f'--file {DDCLIENT_CONF} --foreground', systemd_override)
f'--file {DDCLIENT_CONF} --cache {DDCLIENT_CONF.replace("conf", "cache")} ' \
f'--foreground --daemon {default_interval}', systemd_override)

# Check for process in VRF
proc = cmd(f'ip vrf pids {vrf_name}')
Expand Down

0 comments on commit a328575

Please sign in to comment.