Merge remote-tracking branch 'origin/master' into staging
[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..3c0a3b6
--- /dev/null
@@ -0,0 +1,16 @@
+#!/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-z0-9-]*@.*\.service$ ]] ||
+       [[ $service =~ ^session-[0-9]+\.scope$ ]]; then
+        systemctl reset-failed "$service"
+    fi
+done