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.

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

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.