4

I have a custom systemd service that runs during the first boot.

If the user has no bootsplash I would like to write to the console and give some info on what's going on. Is there a way to do that from my service?

Here's my systemd service:

[Unit]
Description=Prepare operator after installation
Before=getty@tty1.service getty@tty2.service getty@rrt3.service getty@tty4.service getty@tty5.service getty@tty6.service
Wants=network-online.target
After=network.target network-online.target
OnFailure=emergency.target
OnFailureJobMode=replace-irreversibly

[Service]
Type=oneshot
ExecStart=/usr/bin/provision-operator

[Install]
WantedBy=multi-user.target
  • selinux-autorelabel.service does this with StandardInput=tty [sic], but I don't know how it works if you do have a bootsplash. – sourcejedi Mar 17 '17 at 15:11
4

In man systemd.directives, you can search for "output" and find that StandardOutput= is documented in in man systemd.exec. There you can find options including journal+console to send output to the systemd Journal and the system console. You might also try kmsg+console. According to the docs kmsg "connects standard output with the kernel log buffer which is accessible via dmesg(1),"

0

I did it like this. I don't have a login prompt in tty1. So it does not show MOTD out of the box.

[Service]
Type=oneshot
Restart=no
ExecStartPre=/bin/sleep 10
After=getty@tty2.service 
ExecStart=
ExecStart=-/bin/cat /etc/motd
StandardOutput=tty
TTYPath=/dev/tty1

Where oneshot says: exec only once. Restart=no requirement of oneshot. Not sure why there are two ExecStart and why "-", this was copy and paste. I added After= / ExecStartPre= because the message did not show up, probably screen was cleared by someone else. So it should be after target "login prompt".

Disclaimer: Use this answer as a collection of ideas. I didn't want them to get lost. Do your own research if you have any questions and feel free to contribute your findings.

This was done on Debian stretch w/o X.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.