Rundown on how to start an interactive console application automatically on boot using systemd. Useful for unattended Raspberry Pis.
By default the service getty is launched. That will do the magic that opens a login prompt on any tty.
To automatically launch an application instead of that login prompt, one has to simply overwrite that behaviour.
Create a file named /etc/systemd/system/mytui@.service.
[Unit] Description=Custom user interface on %I Documentation=https://unix.stackexchange.com/a/318336/5132 Conflicts=getty@%I.service Before=getty.target [Service] ExecStart=/usr/local/bin/mytui StandardInput=tty StandardOutput=tty Restart=always RestartSec=1 UtmpIdentifier=%I TTYPath=/dev/%I TTYReset=yes TTYVHangup=yes TTYVTDisallocate=yes SendSIGHUP=yes [Install] WantedBy=multi-user.target
Obviuosly adjust the filename and the ExecStart parameter.
Simply enable your new service:
systemctl enable email@example.com
tty1 works for debian. It also has to be tty1 as this is the one that will be selected by default.
Launching on tty2 would require switching to that tty after boot, and that would be the opposite of "unattended".
Prevent systemd from starting the getty at the same time on the same tty:
systemctl mask firstname.lastname@example.org