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

LSB init scripts (was: should an init-script print output, if verbose is set to no in /etc/default/rcS or by /lib/init/vars.sh?)

On Sat, 28 Apr 2007 14:35:57 -0700, Russ Allbery <rra@debian.org>
>Marc Haber <mh+debian-devel@zugschlus.de> writes:
>> Steve Langasek <vorlon@debian.org> wrote:
>>> Further, why should individual init scripts that are already going to
>>> all the effort of using the LSB interfaces be expected to handle
>>> VERBOSE individually?  Why isn't this part of the log_* implementation?
>> The LSB init script stuff is a red herring anyway since the Interface is
>> badly designed and utterly incomplete. Init scripts are therefore forced
>> to abuse the provided functions if something "special" is needed.
>Is there any way that we can fix this?  I *really* like the basic idea and
>would be quite happy to never again write an "echo -n" in an init script.

I really like the idea as well. I do not feel very comfortable with
using the interface yet. I have only migrated two packages, exim4 and
nagios2, to LSB init scripts, and for both packages I needed a generic
log function which was kindly contributed by madduck on IRC:
|# this is from madduck on IRC, 2006-07-06
|# There should be a better possibility to give daemon error messages
|# and/or to log things
|  case "$1" in
|    [[:digit:]]*) success=$1; shift;;
|    *) :;;
|  esac
|  log_action_begin_msg "$1"; shift
|  log_action_end_msg ${success:-0} "$*"

I use this, for example, to give error messages that need to be given
before the daemon is even being started.

I am also mildly confused that the init script functions made
available by our lsb-base are so radically different from what's
mentioned in the LSB standard.

After reviewing my init scripts again, there is really only missing a
generic output function. Especially exim4 was quite hard to LSBize
since the package offers so many different configuration schemes, some
of them starting only one daemon and some others starting multiple
daemons. I don't really know how to handle this situation, and what,
for example, the "status" option is supposed to return.

Maybe someone can comment on the two init scripts and say whether I
did it right or wrong:

>To take one of the most obvious, they don't deal with failure at all well.
>If you try to start something and it fails with an error message, you end
>up with the error message plastered after the starting message without any
>blank line (and therefore often going over 80 columns), then a newline and
>a space, and then the failed message.
>They also don't deal at all well with programs that produce console output
>when they start (fairly common when loading kernel modules, for instance).
>I need some way to tell the output system that I'm about to do something
>that's going to produce output and they should do something reasonable
>with the formatting rather than just tack it on to the end of whatever
>line happens to be on the screen.

I'd like to have all output that is not written by log_foo functions
to be captured in a buffer, while having a log_foo function which will
print the buffer's contents and one that deletes the buffer. That way,
the init script can decide when printing the accumulated output would
be appropriate, and with reasonable implementations of the log_foo
functions even the current behavior can be emulated.

>And maybe it's just me, but having a library of convenience functions
>that, if used according to directions, end up having you write code like
>this seems rather silly:
>    [ "$VERBOSE" != no ] && log_daemon_msg "Starting $DESC" "$NAME"
>    do_start_kdc
>    case "$?" in
>      0|1)
>        if [ "x$RUN_KRB524D" = "xtrue" ] ; then
>            [ "$VERBOSE" != no ] && log_progress_msg "krb524d"
>            do_start_krb524d
>            case "$?" in
>              0|1) [ "$VERBOSE" != no ] && log_end_msg 0 ;;
>              2)   [ "$VERBOSE" != no ] && log_end_msg 1 ;;
>            esac
>        else
>            [ "$VERBOSE" != no ] && log_end_msg 0
>        fi
>        ;;
>      2)
>        [ "$VERBOSE" != no ] && log_end_msg 1
>        ;;
>Surely the library should be dealing with some of this sort of thing.

Absolutely agreed.

This is also a "sales" issue. I have seen to many faces darken when
people see a Debian system boot for the first time. People get
reminded of the old DOS days and decide that this Linux thing is too
ugly to use.


-------------------------------------- !! No courtesy copies, please !! -----
Marc Haber         |   " Questions are the         | Mailadresse im Header
Mannheim, Germany  |     Beginning of Wisdom "     | http://www.zugschlus.de/
Nordisch by Nature | Lt. Worf, TNG "Rightful Heir" | Fon: *49 621 72739834

Reply to: