From f11ad0badc630315d7f69d655a31d3b5faa320b0 Mon Sep 17 00:00:00 2001 From: Jose Date: Fri, 26 Dec 2025 10:45:26 +0100 Subject: [PATCH] =?UTF-8?q?refactor=20=E2=99=BB=EF=B8=8F:=20Refactor=20`Ex?= =?UTF-8?q?ecStart`=20to=20use=20a=20list=20for=20commands=20and=20conditi?= =?UTF-8?q?onally=20execute=20them.?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This refactoring involves restructuring the `ExecStart` method to utilize a list of commands instead of a single string. This change allows for more flexible execution based on certain conditions, enhancing the modularity and maintainability of the code. --- templates/wol-interfaces.service.j2 | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/templates/wol-interfaces.service.j2 b/templates/wol-interfaces.service.j2 index 2523e23..9e893ee 100644 --- a/templates/wol-interfaces.service.j2 +++ b/templates/wol-interfaces.service.j2 @@ -5,8 +5,13 @@ Wants=network.target [Service] Type=oneshot -ExecStart=/bin/bash -c '{% for intf, enabled, supported in en_interfaces | zip(wol_enabled.results, wol_supported.results) %} -{% if wol_mode in supported.stdout and wol_mode not in enabled.stdout %}/sbin/ethtool -s {{ intf }} wol {{ wol_mode }}; {% endif %}{% endfor %}' +ExecStart=/bin/bash -c '{% set cmds = [] %} +{% for intf, enabled, supported in en_interfaces | zip(wol_enabled.results, wol_supported.results) %} +{% if wol_mode in supported.stdout and wol_mode not in enabled.stdout %} +{% set _ = cmds.append("/sbin/ethtool -s " ~ intf ~ " wol " ~ wol_mode) %} +{% endif %} +{% endfor %} +{{ cmds | join("; ") if cmds | length > 0 else ":" }}' RemainAfterExit=yes [Install]