Subject: Re: Summary: Third-party rc.d scripts
To: Amitai Schlair <>
From: Johnny C. Lam <>
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

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

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/
and sysutils/ups-nut/files/ 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.


	-- Johnny Lam <>