From a063b1a7e1ac3ae49881ff5a51b30b39fb937785 Mon Sep 17 00:00:00 2001 From: Robert Günzler Date: Sun, 7 Sep 2025 17:32:13 +0200 Subject: syncthing: conditionally run actions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Robert Günzler --- bundles/syncthing/items.py | 24 +++++++++++++----------- 1 file changed, 13 insertions(+), 11 deletions(-) (limited to 'bundles') diff --git a/bundles/syncthing/items.py b/bundles/syncthing/items.py index 75b713c..8d06223 100644 --- a/bundles/syncthing/items.py +++ b/bundles/syncthing/items.py @@ -3,9 +3,9 @@ if node.os != "alpine": svc_openrc = { "syncthing": { - "enabled": True, - "running": True, - "needs": [ + 'enabled': True, + 'running': True, + 'needs': [ "pkg_apk:syncthing-openrc", ], }, @@ -13,19 +13,20 @@ svc_openrc = { files = { "/etc/traefik/syncthing-gui.yaml": { - "content_type": "mako", - "source": "traefik.yaml", - "needs": {"bundle:traefik"}, + 'content_type': "mako", + 'source': "traefik.yaml", + 'needs': {"bundle:traefik"}, }, } actions = { "syncthing_generate_config": { - "command": "test -d /var/lib/syncthing/.local/state/syncthing || syncthing generate --no-default-folder", + 'command': "syncthing generate --no-default-folder", + 'unless': "test -d /var/lib/syncthing/.local/state/syncthing", }, "syncthing_patch_config": { - "command": "patch -sfN -d /var/lib/syncthing -p1", - "data_stdin": """ + 'command': "patch -sfN -d /var/lib/syncthing -p1", + 'data_stdin': """ --- a/.local/state/syncthing/config.xml +++ b/.local/state/syncthing/config.xml @@ -52,7 +52,7 @@ @@ -38,7 +39,8 @@ actions = { default """, - "needs": {"action:syncthing_generate_config"}, - "triggers": {"svc_openrc:syncthing:restart"}, + 'needs': {"action:syncthing_generate_config"}, + 'triggers': {"svc_openrc:syncthing:restart"}, + 'unless': "grep -q '0.0.0.0:8384' /var/lib/syncthing/.local/state/syncthing/config.xml", }, } -- cgit 1.4.1