help-bash
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [Help-bash] upstart sh script, wait 60 seconds, abort on key press


From: Bob Proulx
Subject: Re: [Help-bash] upstart sh script, wait 60 seconds, abort on key press
Date: Sun, 8 Jul 2012 09:28:06 -0600
User-agent: Mutt/1.5.21 (2010-09-15)

address@hidden wrote:
> The hardcoded sleep 60 is awful. I'd like to write a patch adding a
> feature to allow aborting the wait.

The difficulty of that task isn't related to bash, nor any other
programming language, but instead depends upon the environment that is
running at the time.  At boot time network configuration you probably
don't have access to the keyboard.

> Is there any sh command to wait and at the same time break if ESC,
> ctrl + c or any other key is pressed?

The 'read' shell built-in can read input with a timeout.

> I tried with 'read', but while booting (upstart) does not seem not
> to use the console (command ignored).

And with that you see that the real problem isn't with trying to use a
shell programming construct but simply trying to interact at all.
There isn't any magic programming construct in the shell nor in any
other language that can workaround not having human interaction
available at that boot time script.

A better solution would be to go deeper into the problem and see why
it needs to wait for the network at all.  For example on my Debian
system I eschew network-manager and set up /etc/network/interfaces for
my needs.  There is no long 60 second delay there.  Why does your
Ubuntu do it then?

However if a network is configured using dhcp, an external dependency,
and it requires networking to operate, then it should wait for the
network to be configured.  If the dhcp action takes a while then
bringing networking online might take a while and so the system boot
should wait for it.  The way to avoid that type of external delay
would be to configure a static IP address so that no waiting for
external network actions is needed.

I think any deep discussion of this problem would simply be a
discussion of the distribution specific boot time process.  That
wouldn't be bash specific and wouldn't have anything to do with bash.
Probably this discussion is something for one of the Ubuntu boot time
development mailing lists.

Good luck!
Bob



reply via email to

[Prev in Thread] Current Thread [Next in Thread]