One more question related to LSB init scripts:
A commonly found current approach in init scripts for services that require networking to be up is:
# Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ "$NETWORKING" = "no" ] && exit 0
Silently exiting with 0 no matter which action was requested does not look like something expected of LSB compliant init scripts.
Actually, all of 1) silent exit and 2) the zero exit value and 3) the way "is networking up?" is checked seem questionable to me. Anyone have ideas for better approaches to this?
On Sun, Jul 08, 2007 at 05:04:08PM +0300, Ville Skyttä wrote:
Actually, all of 1) silent exit and 2) the zero exit value and 3) the way "is networking up?" is checked seem questionable to me. Anyone have ideas for better approaches to this?
Isn't that just supposed to be checking if networking is enabled at all? If that is "no", presumably we don't even have the loopback interface up.
Steve
On Sunday 08 July 2007, Steven Pritchard wrote:
On Sun, Jul 08, 2007 at 05:04:08PM +0300, Ville Skyttä wrote:
Actually, all of 1) silent exit and 2) the zero exit value and 3) the way "is networking up?" is checked seem questionable to me. Anyone have ideas for better approaches to this?
Isn't that just supposed to be checking if networking is enabled at all? If that is "no", presumably we don't even have the loopback interface up.
Hard to tell, but that's just one bit of the puzzle. To elaborate on the issues:
a) Why doesn't it output an error message saying that the service requires networking but networking doesn't seem to be available?
b) Why is the exit status 0, indicating success?
c) Why is the check done before doing anything else instead of being done eg. only in the start (and restart, reload and friends if they're not implemented using start) action? That and b) will result in eg. the status action returning 0, indicating in LSB terms "program is running or service is OK" which it most likely is not if it requires networking and networking isn't up.
d) Why does it just read something from a config file instead of actually checking whether networking is up? Not sure if that check is necessary in the first place - could just let the service fail. Maybe it's used/useful for optimization purposes and/or to provide a hook for a more descriptive error message than what the failing service would output.
Ville Skyttä wrote:
On Sunday 08 July 2007, Steven Pritchard wrote:
On Sun, Jul 08, 2007 at 05:04:08PM +0300, Ville Skyttä wrote:
Actually, all of 1) silent exit and 2) the zero exit value and 3) the way "is networking up?" is checked seem questionable to me. Anyone have ideas for better approaches to this?
Isn't that just supposed to be checking if networking is enabled at all? If that is "no", presumably we don't even have the loopback interface up.
Hard to tell, but that's just one bit of the puzzle. To elaborate on the issues:
a) Why doesn't it output an error message saying that the service requires networking but networking doesn't seem to be available?
b) Why is the exit status 0, indicating success?
c) Why is the check done before doing anything else instead of being done eg. only in the start (and restart, reload and friends if they're not implemented using start) action? That and b) will result in eg. the status action returning 0, indicating in LSB terms "program is running or service is OK" which it most likely is not if it requires networking and networking isn't up.
d) Why does it just read something from a config file instead of actually checking whether networking is up? Not sure if that check is necessary in the first place - could just let the service fail. Maybe it's used/useful for optimization purposes and/or to provide a hook for a more descriptive error message than what the failing service would output.
It might be a good idea to start looking at a nice way to handle network service deps. This could easily be cleaned at the same time.
/Thomas
* Steven Pritchard [08/07/2007 22:09] :
Isn't that just supposed to be checking if networking is enabled at all? If that is "no", presumably we don't even have the loopback interface up.
It's sourced from /etc/sysconfig/network so the question being answered is "Does the box sysadmin want networking to be started on boot ?".
Seems a bit redundant with "chkconfig network off" to me but checking it to see if network-related services should be started on boot sounds OK. Probably best to check with "/etc/init.d/network status", though.
Emmanuel
Ville Skyttä (ville.skytta@iki.fi) said:
One more question related to LSB init scripts:
A commonly found current approach in init scripts for services that require networking to be up is:
# Source networking configuration. . /etc/sysconfig/network # Check that networking is up. [ "$NETWORKING" = "no" ] && exit 0
Silently exiting with 0 no matter which action was requested does not look like something expected of LSB compliant init scripts.
Actually, all of 1) silent exit and 2) the zero exit value and 3) the way "is networking up?" is checked seem questionable to me. Anyone have ideas for better approaches to this?
NETWORKING=no means 'networking has never been configured on this box'. Frankly, I'd nuke the whole section - it's rather pointless, and will not be set on any normal machine.
(The comment is misleading.)
Bill