Accepting User Input from service script during booting

Hi Robert,

May I have a general Linux question:
I am trying to write a service script to accept user input from UART debug console during booting process.
I followed the steps outlined :
https://alan-mushi.github.io/2014/10/26/execute-an-interactive-script-at-boot-with-systemd.html

and the link:
https://www.golinuxcloud.com/read-user-input-during-boot-stage-linux/

here is my service:

//=== ncu-install.service
[Unit]
Description=NCU Installation
After=network.target sshd.service systemd-logind.service [getty@tty2.servic](mailto:getty@tty2.servic)e
[Service]
Type=oneshot
TTYPath=/dev/tty2
ExecStartPre=/bin/chvt 13
ExecStart=/ncu_install/ncu_install.sh
ExecStartPost=/bin/chvt 1
StandardInput=tty
TTYVHangup=yes
TTYReset=yes
TTYVTDisallocate=yes
#RemainAfterExit=no
[Install]
WantedBy=default.target
RequiredBy=sshd.service systemd-logind.service [getty@tty1.servic](mailto:getty@tty1.servic)e

But it is not showing prompt for user input on UART debug console: /dev/ttyS0

crw------- 1 debian tty 4, 64 May  3 16:46 /dev/ttyS0
crw--w---- 1 root tty 4, 2 Jul  7  2019 /dev/tty2

I am not sure it is because the rights or because ttyS0 cannot be redirected to tty2

Best Regards,
David

I commented chvt in the service. I found chvt command doesn’t switch: for example:
$tty
/dev/ttyS0
$sudo chvt 6
/dev/ttyS0
And it is not connected to vt, probably.

//=============ncu-install.service
[Unit]
Description=NCU Installation
After=serial-getty@ttyS0.service
[Service]
Type=oneshot
TTYPath=/dev/ttyS0
ExecStart=/ncu_install/ncu_install.sh
StandardInput=tty
TTYReset=yes
[Install]
WantedBy=default.target

in the ncu_install.sh
I added dialog --msgbox “Hello”
it was displayed
But it still cannot read keystrokes.

There are three tty’s runing:

root       791     1  0 16:21 tty1     00:00:00 /sbin/agetty -o -p -- \u --noclear tty1 linux
root      1128     1  0 16:22 ttyGS0   00:00:00 /sbin/agetty -o -p -- \u --keep-baud 115200,38400,9600 ttyGS0 vt220
root      1327     1  0 16:24 ?        00:00:00 /sbin/agetty --autologin debian temppwd -o -p -- \u --keep-baud 115200,38400,9600 ttyS0 vt220

Totally confused: ttyGS0 and ?
Best Regards
David

that’s the libcomposite usb module we load on startup, to give serial access over the USB…

Odd, that looks like the systemd tty service…

Regards,

Hi Robert,
I gave up. Using other ways to handle.
? probably is created when I added --autologin at the end. If just -a USERNAME, and remove -o ’ - p \u ’ stuff. The tty with ? disppears.

Best Regards,
David

Hi Robert,

Also systemd is a mult-users & multi-threads system, so it is not good place for holding some process until user input. So I think I don’t need a dialog or user input for things I need to install for bare boards.

Best Regards,
David

I agree, that 2014 article just seemed weird…

Regards,