wider regex for clearing failed rsyncd service to catch rsyncd-snapshot-farm@
[mirror/dsa-puppet.git] / modules / systemd / files / systemd-cleanup-failed
1 #!/bin/bash
2
3 # if a client goes away on socket activated connections before systemd launches
4 # the process, things go sad and result in failed services.
5 #
6 # cf. https://github.com/systemd/systemd/issues/7172
7 #
8 # should be fixed in buster and newer, but for now clean those up.
9
10 systemctl --failed --no-legend | awk '{print $1}' | \
11     while read service; do
12     if [[ $service =~ ^rsyncd-[a-z0-9-]*@.*\.service$ ]] ||
13        [[ $service =~ ^session-[0-9]+\.scope$ ]]; then
14         systemctl reset-failed "$service"
15     fi
16 done