mirror of
https://github.com/systemd/systemd.git
synced 2024-11-01 09:21:26 +03:00
27b4d60678
We use the `autologin` mkosi option (see mkosi.default.d/10-systemd.conf), so the pexpect root login throws a (harmless) error: ``` Arch Linux (built from systemd tree) Kernel 5.4.0-1047-azure on an x86_64 (console) image login: root (automatic login) root root [root@image ~]# systemctl poweroff root -bash: root: command not found [root@image ~]# systemctl poweroff ```
25 lines
423 B
Python
Executable File
25 lines
423 B
Python
Executable File
#!/usr/bin/env python3
|
|
# SPDX-License-Identifier: LGPL-2.1-or-later
|
|
|
|
import pexpect
|
|
import sys
|
|
|
|
|
|
def run() -> None:
|
|
p = pexpect.spawnu(" ".join(sys.argv[1:]), logfile=sys.stdout, timeout=300)
|
|
|
|
p.expect("#")
|
|
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)
|