Based on Ubuntu core 12.04, I have prepared a bootable DVD. After booting (to console only), I can login as a user and start a script for installation of an embedded device:
sudo install_script
In order to execute this script already at startup, I've added the following to /etc/rc.local
in the image of the root filesystem on the DVD:
/bin/bash -ic install_script
Since this script is executed unconditionally, I'd like to give the user some opportunity to bypass installation and get on to a login prompt. To that end, I'd like to use read
in the install_script. Unfortunately, the script does not react to keyboard input when run from /etc/rc.local
. (There is no problem with the same script started from a shell after login).
How can I get some user input at startup?
(Some thoughts:
- Maybe, I can somehow detect and connect a tty to
read
or to the script? I tried/bin/bash -ic install_script </dev/console
to no avail. - Maybe, there are more suitable options to
/bin/bash
or toread
? - Maybe, I could boot into a single shell of a certain user (maybe
root
, without logging in?) with.bashrc
callingsudo install_script
(avoiding password check for sudo?)? - Maybe, there exists a better place for calling the script?
- I would not like to separate the interaction (to occur earlier) and the install_script (e.g., by providing different boot options via isolinux and examining
/proc/cmdline
in the script) for the following reason: Before asking the user, I'd like to examine the system and give an overview of what exactly would happen during the install. At earlier stages of the boot process, the necessary information for the examination of the system may not yet be easily available.
)
Best Answer
In my current solution, I'm using
openvt
to startinstall_script
by adding the following line to\etc\rc.local
:Alt-F[1-7]
).-s
tellsopenvt
to switch to the new virtual terminal (without pressingAlt-F8
).-w
letsopenvt
wait for completion of the command/path/to/install_script
given toopenvt
.read
.