Move failed rsync cleanup into systemd module
[mirror/dsa-puppet.git] / modules / systemd / files / systemd-cleanup-failed
diff --git a/modules/systemd/files/systemd-cleanup-failed b/modules/systemd/files/systemd-cleanup-failed
new file mode 100755 (executable)
index 0000000..5cde92b
--- /dev/null
@@ -0,0 +1,15 @@
+#!/bin/bash
+
+# if a client goes away on socket activated connections before systemd launches
+# the process, things go sad and result in failed services.
+#
+# cf. https://github.com/systemd/systemd/issues/7172
+#
+# should be fixed in buster and newer, but for now clean those up.
+
+systemctl --failed --no-legend | awk '{print $1}' | \
+    while read service; do
+    if [[ $service =~ ^rsyncd-[a-z]*@.*\.service$ ]]; then
+        systemctl reset-failed "$service"
+    fi
+done