ci: check for failed services after boot
This should, hopefully, catch issues like systemd/systemd#21671 automagically.main
parent
1f013e0c49
commit
24acd4064e
@ -1,26 +0,0 @@
|
||||
#!/usr/bin/env python3
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
import pexpect
|
||||
import re
|
||||
import sys
|
||||
|
||||
|
||||
def run() -> None:
|
||||
p = pexpect.spawnu(" ".join(sys.argv[1:]), logfile=sys.stdout, timeout=300)
|
||||
|
||||
# distro-independent root prompt
|
||||
p.expect(re.compile("~[^#]{0,3}#"))
|
||||
p.sendline("systemctl poweroff")
|
||||
|
||||
p.expect(pexpect.EOF)
|
||||
|
||||
|
||||
try:
|
||||
run()
|
||||
except pexpect.EOF:
|
||||
print("UNEXPECTED EOF")
|
||||
sys.exit(1)
|
||||
except pexpect.TIMEOUT:
|
||||
print("TIMED OUT")
|
||||
sys.exit(1)
|
@ -0,0 +1,14 @@
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
[Unit]
|
||||
Description=Check if any service failed and then shutdown the machine
|
||||
After=multi-user.target network-online.target
|
||||
Requires=multi-user.target
|
||||
Wants=systemd-resolved.service systemd-networkd.service network-online.target
|
||||
OnFailure=poweroff.target
|
||||
OnFailureJobMode=replace-irreversibly
|
||||
|
||||
[Service]
|
||||
Type=oneshot
|
||||
ExecStartPre=-rm -f /failed-services
|
||||
ExecStart=/usr/lib/systemd/mkosi-check-and-shutdown.sh
|
||||
ExecStartPost=systemctl poweroff --no-block
|
@ -0,0 +1,9 @@
|
||||
#!/bin/bash -eux
|
||||
# SPDX-License-Identifier: LGPL-2.1-or-later
|
||||
|
||||
systemctl --failed --no-legend | tee /failed-services
|
||||
|
||||
# Exit with non-zero EC if the /failed-services file is not empty (we have -e set)
|
||||
[[ ! -s /failed-services ]]
|
||||
|
||||
: >/testok
|
Loading…
Reference in New Issue