Subject: Re: Summary: Third-party rc.d scripts
To: Amitai Schlair <schmonz@schmonz.com>
From: Johnny C. Lam <jlam@netbsd.org>
List: tech-pkg
Date: 02/08/2002 12:24:40
On Thu, Feb 07, 2002 at 11:48:37PM -0500, Amitai Schlair wrote:
> 
> 1) Some people want all rc.d scripts in /etc/rc.d.
> 
>      Lubomir pointed out that pkgsrc can already accommodate an admin's
>      preference for where to install rc.d scripts, and can install them
>      there automatically. Frederick suggested that we can enable this
>      behavior by default if we append foo=NO to /etc/defaults/rc.pkg.conf
>      (which gets sourced by /etc/defaults/rc.conf).

Here is rough cut of something that implements what Frederick suggests.
We add something like the following to the package INSTALL scripts (the
template is in pkgsrc/mk/install/install):

RCD_SCRIPTS="$*"		# this is automatically set in the script
RCD_SCRIPTS_DIR="/etc/rc.d"	# this is automatically set in the script

rc_pkg_conf=/etc/defaults/rc.pkg.conf
eval set -- ${RCD_SCRIPTS}
while [ $# -gt 0 ]
do
        script=${RCD_SCRIPTS_DIR}/$1; shift
        if [ -x $script ]; then
                rcvar=`( $script rcvar 2>/dev/null ) | \
                        grep "=" | sed "s/^\$\([^=]*\)=.*/\1/"`
                if [ -n "${rcvar}" ]
                then
                        touch $rc_pkg_conf
                        if ! grep -q "^$rcvar=" $rc_pkg_conf
                        then
                                echo $rcvar=NO >> $rc_pkg_conf
                        fi
                fi
        fi
done

This fragment asks each rc.d script that is installed by the package what
it's rcvar is (some scripts don't have one, e.g. net/samba/files/samba.sh
and sysutils/ups-nut/files/ups.sh) and appends a "foo=NO" to rc.pkg.conf
if a value isn't already present.

We can have similar code the DEINSTALL script to remove the lines from
$rc_pkg_conf when a package is deinstalled.

	Cheers,

	-- Johnny Lam <jlam@netbsd.org>