Discussion:
Menu on bootup?
Nevyn
2011-10-17 06:16:36 UTC
Permalink
Does anyone know what the usual approach is to showing a menu AFTER a linux
distro has been booted? I'm thinking in terms of the appliance type
distributions like pfsense (not Linux I know) or Clonezilla... So a menu
that shows up on tty1 only...
--
Regards,
Nevyn
http://nevsramblings.blogspot.com/
_______________________________________________
NZLUG mailing list ***@linux.net.nz
http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
Nevyn
2011-10-17 07:04:04 UTC
Permalink
Post by Nevyn
Does anyone know what the usual approach is to showing a menu AFTER a linux
distro has been booted? I'm thinking in terms of the appliance type
distributions like pfsense (not Linux I know) or Clonezilla... So a menu
that shows up on tty1 only...
--
Regards,
Nevyn
http://nevsramblings.blogspot.com/
On Clonezilla I've found:
/etc/init.d/start-ocs-live
With the following contents:

exec </dev/console >/dev/console 2>&1

[ ! -d "/etc/ocs/ocs-live.d/" ] && exit 1
for script in /etc/ocs/ocs-live.d/S[0-9][0-9]*; do
$script
done

The script stuff is fairly trivial. I've never really understood file
descriptors. Is anyone able to explain that first line to me?

exec </dev/console >/dev/console 2>&1

Regards,
Nevyn
http://nevsramblings.blogspot.com/
_______________________________________________
NZLUG mailing list ***@linux.net.nz
http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
Bruce Clement
2011-10-17 07:28:08 UTC
Permalink
Post by Nevyn
exec </dev/console >/dev/console 2>&1
[...]
I've never really understood file
descriptors. Is anyone able to explain that first line to me?
"2>&1" = close file descriptor 2 & make it an alias of file descriptor 1

Which doesn't really help unless you know that 2 is STDERR (Standard Error
stream) and 1 is STDOUT (Standard Output stream)

So this just says send error messages to the output stream, not to the
console (Unless the console happens to be the destination of the output
stream).

HTH
--
Bruce Clement

Home: http://www.clement.co.nz/
Twitter: http://twitter.com/Bruce_Clement
Directory: http://www.searchme.co.nz/

"Before attempting to create something new, it is vital to have a good
appreciation of everything that already exists in this field." Mikhail
Kalashnikov
_______________________________________________
NZLUG mailing list ***@linux.net.nz
http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
Steve Holdoway
2011-10-17 20:13:41 UTC
Permalink
Post by Bruce Clement
Post by Nevyn
exec </dev/console >/dev/console 2>&1
[...]
I've never really understood file
descriptors. Is anyone able to explain that first line to me?
"2>&1" = close file descriptor 2 & make it an alias of file descriptor 1
Which doesn't really help unless you know that 2 is STDERR (Standard Error
stream) and 1 is STDOUT (Standard Output stream)
So this just says send error messages to the output stream, not to the
console (Unless the console happens to be the destination of the output
stream).
HTH
Standard streams ( created by default when any process starts ):

0 = input
1 = output
2 = error

The difference between stdout and stderr is that stdout is buffered,
whereas stderr is not - you see error messages immediately.

If you wish to combine the 2 output streams ( eg to save all output to a
file, or to post-process with another command ), you can redirect one to
the other: 2>&1 sends error to out, 1>&2 sends out to error. You can
also send to a file ( &>filename redirects all output as a shortcut ).

Note in the example above that the order of redirection is important:

command >filename 2>&1

output and error will end up in filename

command 2>&1 >filename

output -> filename
error -> output

Clear as mud???

(:

Steve
--
Steve Holdoway BSc(Hons) MNZCS <***@greengecko.co.nz>
http://www.greengecko.co.nz
MSN: ***@greengecko.co.nz
Skype: sholdowa
Martin D Kealey
2011-10-17 20:59:45 UTC
Permalink
Post by Nevyn
exec </dev/console >/dev/console 2>&1
The script stuff is fairly trivial. I've never really understood file
descriptors. Is anyone able to explain that first line to me?
exec </dev/console >/dev/console 2>&1
The "exec" built-in is a bit funny. Unlike most shell commands where if you
preface a variable-setting or set some I/O-redirection they only apply to
just that one command, for "exec" (without a filename) they remain in effect
for the rest of the script or shell session. (Using "exec" *with* a filename
results in the current shell session being *replaced by* that other
program.)

In this case it means connect the stdin and stdout each to /dev/console, and
then connect stderr to wherever stdout is connected.

/dev/console is a generic device that starts out meaning /dev/tty1, but can
be redirected to an xconsole, or into syslog, or wherever is useful.

Not sure why they'd bother connecting stdin, unless they expect that
something might possibly need keyboard input, and that would only work if
it's still connected to /dev/tty1. It would be shorter and more appropriate
to write

exec </dev/null >/dev/console 2>&1

-Martin

_______________________________________________
NZLUG mailing list ***@linux.net.nz
http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
Jan Bakuwel
2011-10-17 21:58:59 UTC
Permalink
Hi Nevyn,
Post by Nevyn
Does anyone know what the usual approach is to showing a menu AFTER a linux
distro has been booted? I'm thinking in terms of the appliance type
distributions like pfsense (not Linux I know) or Clonezilla... So a menu
that shows up on tty1 only...
I've used something called "pdmenu" in the past - is that something that
would fit?

cheers,
Jan



_______________________________________________
NZLUG mailing list ***@linux.net.nz
http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug
Nevyn
2011-10-17 22:34:57 UTC
Permalink
Post by Jan Bakuwel
Hi Nevyn,
Post by Nevyn
Does anyone know what the usual approach is to showing a menu AFTER a
linux
Post by Nevyn
distro has been booted? I'm thinking in terms of the appliance type
distributions like pfsense (not Linux I know) or Clonezilla... So a menu
that shows up on tty1 only...
I've used something called "pdmenu" in the past - is that something that
would fit?
cheers,
Jan
Hey... that's kind of pretty. The issue isn't how to generate a menu, but
more, how would you get it to start a menu in tty1 when booting off a
liveusb?

It occurred to me that I could just put a test for tty1 from .bashrc. And
then it turns out that casper does some magic-fu that means that there is no
/home on the live media. Going to play with persistence now. Maybe that'll
yield the results I need.

Regards,
Nevyn
http://nevsramblings.blogspot.com/
_______________________________________________
NZLUG mailing list ***@linux.net.nz
http://www.linux.net.nz/cgi-bin/mailman/listinfo/nzlug

Loading...