Subject: Re: rc.d scripts and there variable settings (was: CVS commit: sharesrc/share/man/man5)
To: None <tech-pkg@netbsd.org>
From: Robert Elz <kre@munnari.OZ.AU>
List: tech-pkg
Date: 09/05/2002 19:07:20
    Date:        Tue, 3 Sep 2002 22:33:18 +0200
    From:        Bernd Ernesti <netbsd@lists.veego.de>
    Message-ID:  <20020903203318.GA5600@arresum.veego.de>

  | This is what I don't like about the current installation of a package.
  | 
  | I want to use a package package in the future, but not right now, so
  | I install it and then I get a lot of warnings about unconfigured variables
  | during the next boot.

The last time this was discussed, I thought the final conclusion was
that pkgsrc installed rc.d scripts should all be something like:
(using the uninstalled script from openldap as an example)

#! /bin/sh
#
# $NetBSD: slapd.sh,v 1.1 2002/01/30 07:34:01 jlam Exp $
#
# OpenLDAP standalone LDAP daemon
#
# PROVIDE: slapd
# REQUIRE: DAEMON

if [ -f /etc/rc.subr ]
then
        . /etc/rc.subr
fi

name="slapd"
rcvar=${name}
command="@PREFIX@/libexec/${name}"
pidfile="/var/openldap/slapd.pid"
required_files="@PKG_SYSCONFDIR@/${name}.conf"
extra_commands="reload"

# Add a line containing slapd=YES to /etc/rc.conf to enable slapd
# Do not alter the following line.
eval "\$$rcvar=NO"

if [ -f /etc/rc.subr ]
then
        load_rc_config $name
        run_rc_command "$1"
else
        @ECHO@ -n " ${name}"
        ${command} ${slapd_flags} ${command_args}
fi


The "eval" (which is probably overkill, as the value of $rcvar is known...)
is essentially the script carrying around its own little piece of
/etc/defaults/rc.conf.

With this, the warnings will go away, and without you having to remember to
add thing=NO to rc.conf whenever one of the daemon type packages is installed.

A warning in a MESSAGE file that the daemon won't start until enabled in 
rc.conf would be a good idea.

So would a rc.conf variable that enables rc.subr to list all the things
that aren't being started, as well as all the things that are, and when
possible why ("disabled", "prerequisite file X not found", ...)

kre

ps: for the script above, for old systems, with no rc.conf. from where is
the script supposed to obtain command_args ?   (I believe I saw a checkin
that set a value for slapd_flags in the script, that one belongs there).
If "nowhere" is the answer (for command_args) why bother including it
on the command line (just to create confusion) ?