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

Re: service helper package



Hallo C.J.,

C.J. Adams-Collier <cjcollier@gmail.com> wrote:
> On Mon, 2007-11-26 at 12:32 +0000, Jörg Sommer wrote:
>> C.J. Adams-Collier <cjcollier@gmail.com> wrote:
>> > # Fully qualified paths to required programs
>> > START_STOP_DAEMON=/sbin/start-stop-daemon
>> > CAT=/bin/cat
>> > ECHO=/bin/echo
>> 
>> Why not use echo and cat? Calling echo this way the shell can't use the
>> builtin echo command and must spawn a new process.
>
> Is there a test to determine whether there is a builtin for a given
> command?

Try to call it with the prefix builtin and test if it fails.

% builtin echo

% builtin ls
zsh: no such builtin: ls

>> > if [ -z "$SERVICE_NAME" ] || \
>> >    [ -z "$SERVICE_DESC" ] || \
>> >    [ -z "$SERVICE_DAEMON" ]; then
>> >   fatal( "Environment not configured correctly.\n\tService requires
>> > definition of the following variables:\nSERVICE_NAME\nSERVICE_DESC\n
>> > SERVICE_DAEMON" )
>> > fi
>> 
>> Why you want to test these values everytime? If the maintainer forgot
>> them one time, they are missing everytime.
>
> Maybe they exist one time but get removed before the next run?

Who should remove them? They are in the init script? This looks more
like a check for lintian.

>> > # We do not want to be affected by PATH tampering.  All calls to
>> > # external programs will be fully qualified
>> > PATH=""
>> 
>> You know what you are doing here? PATH is necessary for the daemon to
>> find subcommands.
>
> Yep.  I don't want to execute any but the fully qualified commands.

Did you really understood that your daemon can't restart itself or run
another program.

>> > # Check whether we were configured to not start the services.
>> > check_for_no_start() {
>> >     if [ "$SERVICE_DISABLED" = "yes" ]; then
>> 
>> This is such a broken behavior. Initscripts are enabled and disabled in
>> the configuration of the init system.
>
> I agree... but existing scripts use such a beast,

Doing one thing often doesn't make it right. What you want is to disable
the start of the daemon. It's started by init. So tell init it shouldn't
start it. This leaves the possibilities to start it by hand via
/etc/init.d/FOO start or run it only in some run levels, e.g. in 3 but
not in 2.

Bye, Jörg.
-- 
“Science is the game we play with God to find out what his rules are.”



Reply to: