8

I need to start and print a script on tty1 instead of asking for login. In link with : How to parse /proc/cmdline before asking tty login with systemd

I tried to make a service which launch a simple bash script:

#!/bin/bash
echo "trying to print this on screen before tty login"
read ok

And the service:

[Unit]
Description=Before tty login script launcher

[Service]
Type=simple
ExecStart=/bin/bash -c "/opt/starter.sh"

[Install]
WantedBy=getty.target

After that

cd /lib/systemd/system ; ln -s ./starter.service ./getty.target.wants/starter.service

At boot, it keep launching tty login without prompting my script. I don't want to start script after login cause, script needs root privileges, so if somebody CTRL+C, he will have root access.

1 Answer 1

8

Here what's working :

[Unit]
Description=Script starter
After=getty.target
Conflicts=getty@tty1.service

[Service]
Type=oneshot
RemainAfterExit=yes
ExecStart=/opt/starter.sh
StandardInput=tty-force
StandardOutput=inherit
StandardError=inherit

[Install]
WantedBy=graphical.target

Thanks to #systemd "grawity" and "zdzichu" for helping.

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .