4

I have a script which solicits a numeric input from the user while booting the computer. The computer is running Fedora 16. It used work, on Fedora 13, but after the upgrade

read INTEGER

returns immediately, without catching any user input. I tried

read INTEGER
wait $!

but (predictably) that too doesn't work. The script is run from a systemd service file (see comments below). It must be run as root, and must started before the user logs in. It currently calls bash as its interpreter, but with some effort, that could be changed. Can anyone help return this script to normal?

Extra credit: In F13, it used to halt booting for user input (as desired) but the input was not displayed as the user typed. Is there a way to add this functionality?

Alternatively, I could cue a graphical interface (e.g. from tkinter/Python) to ask for INTEGER after graphical.target loads. Any thoughts on how I might do this? Is it straightforward to load things with windows before the desktop loads?

voretaq7
  • 79,879
  • 17
  • 130
  • 214
Mark C.
  • 141
  • 4

1 Answers1

1

Use the systemd-ask-password command and systemd will take care of prompting the user for input in an appropriate manner, either using a text prompt or a graphical prompt.

TomH
  • 1,290
  • 7
  • 10
  • That's an excellent suggestion. Unfortunately, it still doesn't interrupt startup, so I still don't get input. I found `StandardInput` in the `systemd.unit` man page, which I think would also solve the `stdin` issue, if not the interruption-of-startup issue. I tried setting `StandardInput=tty-force` but it didn't help with the start-up interruption issue. I know I'm not getting instant EOF (as I was before) because the program would flag it. – Mark C. Jan 23 '12 at 22:35
  • It certainly should work at boot time - there are agents for both the text mode console and the plymouth graphical console. Trying to access the terminal directly is just not going to work. – TomH Jan 23 '12 at 22:46
  • Hm. It's not using the Plymouth agent nor the text-mode agent; instead, when I open Gnome terminal after boot, it pings me every so often asking for me to log in as root and use `systemd-tty-ask-password-agent`. – Mark C. Jan 24 '12 at 08:49
  • 1
    Could you update your answer as to exactly *how* to use `systemd-ask-password`? Is it in the service as some part of `ExecStart`? Writing it into it's own service that needs to be called before the password-requiring service is called? The docs talk about the command, but not how to use it in conjunction with a service that needs a password... Thanks for assisting a confused systemd noob! – Hendy Nov 08 '12 at 17:13
  • The program that wants the password should invoke `systemd-ask-password` and then use the result as the password. – TomH Nov 08 '12 at 17:33
  • @TomH In the Arch forums, this is being suggested: `ExecStart=/bin/sh -c '/usr/bin/truecrypt -t -p \`systemd-ask-password "Please enter password for truecrypt volume"\` /dev/sda4'`. Is that what you mean by "invoke" `systemd-ask-password`? – Hendy Nov 09 '12 at 16:44
  • Like a cheater, I piggy-backed on a different Arch topic that was related since it was so similar. Got things worked out [over there](https://bbs.archlinux.org/viewtopic.php?pid=1190366#p1190366) – Hendy Nov 09 '12 at 17:07
  • You would really have been better to ask a separate question about how to configure truecrypt to call a program to get the password... If you really can't tell it to do that then write a shell wrapper like what you have above and ExecStart that - your suggestion may work but it's really nasty. – TomH Nov 09 '12 at 17:18