rc.subr for older FreeBSD systems

Scot W. Hetzel hetzels at westbend.net
Mon Jul 7 09:17:53 PDT 2003


For a while, I had been looking at converting my ports scripts to rcNG and
to allow them to run on older rcOLD systems.  I started using the NetBSD
approach of including both rcNG and rcOLD in the same script (see
security/cyrus-sasl and www/apache13-fp).  While this works, it requires
both the port maintainer and port commiter to ensure that the rc.d script
functions correctly on both rcNG and rcOLD systems.

I propose that we get rid of the rcOLD syntax in the rc.d scripts, so that
by the time FreeBSD 4.9 and 5.2 Releases, our rc.d scripts are completely
converted to rcNG.  In order for this to happen, we need to support older
releases that don't have rc.subr.  This can be accomplished by creating a
port for rc.subr.  And then setting a RUN_DEPENDS on the rc.subr port for
these older systems.

 This port for rc_subr has been created and tested on FreeBSD 4.8-STABLE
(see PR 54116) using fully converted rcNG scripts for the
security/cyrus-sasl port.

    http://www.freebsd.org/cgi/query-pr.cgi?pr=54116

To use the rc_subr port we need to patch bsd.port.mk, so that we can set
USE_RC_SUBR variable in the ports Makefile which have been converted to
rcNG.  This is used to determine if the rc_subr port is needed and where
rc.subr is located (/etc or LOCALBASE/etc).

Then all a port maintainer needs to do is to convert their scripts to rcNG
syntax:

#!/bin/sh
#
# $FreeBSD: ports/security/cyrus-sasl/files/saslauthd.sh,v 1.3 2003/05/09
12:41:21 arved Exp $
#

# PROVIDE: saslauthd1
# REQUIRE: DAEMON
# BEFORE: mail imap
# KEYWORD: FreeBSD shutdown
#
# NOTE for FreeBSD 5.0+:
# If you want this script to start with the base rc scripts
# move saslauthd1.sh to /etc/rc.d/saslauthd1

prefix=%%PREFIX%%

# Define these saslauthd1_* variables in one of these files:
#       /etc/rc.conf
#       /etc/rc.conf.local
#       /etc/rc.conf.d/saslauthd1
#
# DO NOT CHANGE THESE DEFAULT VALUES HERE
#
saslauthd1_enable="%%ENABLE_SASLAUTHD%%"                # Enable saslauthd
#saslauthd1_program="${prefix}/sbin/saslauthd1" # Location of saslauthd1
saslauthd1_flags="-a pam"                       # Flags to saslauthd program

. %%RC_SUBR%%

name="saslauthd1"
rcvar=`set_rcvar`
command="${prefix}/sbin/${name}"
pidfile="/var/state/${name}/mux.pid"

load_rc_config $name
run_rc_command "$1"

Then the port maintainers will need to change their ports Makefile to set
USE_RC_SUBR, and to substitute the correct location of rc.subr in their rc.d
scripts.:

USE_RC_SUBR=    YES
:
RC_SCRIPTS_SUB= PREFIX=${PREFIX} \
                RC_SUBR=${RC_SUBR} \
                PWCHECK=${PWCHECK} \
                ENABLE_PWCHECK=${ENABLE_PWCHECK} \
                ENABLE_SASLAUTHD=${ENABLE_SASLAUTHD} \
                MYSQL_REQ=${MYSQL_REQ}
:
post-install:
            @${SED} ${RC_SCRIPTS_SUB:S/$/!g/:S/^/ -e s!%%/:S/=/%%!/} \
                ${FILESDIR}/pwcheck.sh > ${PREFIX}/etc/rc.d/cyrus_pwcheck.sh
            @${CHMOD} 755 ${PREFIX}/etc/rc.d/cyrus_pwcheck.sh

Could a portmgr have a look at this port.

Thanks,

Scot W. Hetzel



More information about the freebsd-ports mailing list