Skip site navigation (1)Skip section navigation (2)
Date:      Mon, 11 Feb 2002 22:38:55 -0600
From:      "Scot W. Hetzel" <hetzels@westbend.net>
To:        "Sean Chittenden" <sean@chittenden.org>, <freebsd-ports@FreeBSD.ORG>
Subject:   Re: Site wide daemon startup policy for ports ala ${PREFIX}/etc/(rc.conf|defaults/)...
Message-ID:  <00ec01c1b37f$2ec58680$11fd2fd8@westbend.net>
References:  <20020210131643.D43813@ninja1.internal>

next in thread | previous in thread | raw e-mail | index | archive | help
From: "Sean Chittenden" <sean@chittenden.org>
> Hypothetical situation: let's say that with SNMP I like to use syslog,
> which requires the -s flag to snmpd.  No biggie, I can hack
> etc/rc.d/snmpd.sh.  With many machines, however, this is a tad
> tiresome, esp if I don't have SNMP installed on every box.  What I'd
> like to do is be able to use a system similar to what's in /etc with
> its rc.conf and defaults/rc.conf that way I could specify something
> akin to:
>
> snmpd_flags="-s"
>
> Just like one does with /etc/rc.conf.

>
> A port that has configuration options would install its default
> parameters in ${PREFIX}/etc/defaults in a .conf file, using SNMP as an
> example, in ${PREFIX}/etc/defaults/snmpd.conf).  When the host
> administrator wants to tweak a setting, such as adding the -s flag to
> snmpd, they tweak the settings in ${PREFIX}/etc/rc.conf.
>
> Now, when the system boots or the administrator kicks the port via
> ${PREFIX}/etc/snmpd.sh, it'd source a global "integrate with FreeBSD's
> rc/ports startup foo" function which sets the default and host
> specific parameters that way in snmpd.sh, you can see a nifty little
> line that looks something like:
>
>       ${PREFIX}/sbin/snmpd ${snmpd_flags}
>
> This'd apply to other ports/apps and would require their startup
> scripts to be adjusted, but seems like a nice way of centralizing a
> lot of this configuration goo (mailman's default hostname comes to
> mind as another quick and easy win, same with postfix UIDs).
>
> A follow up win would also come in documenting application specific
> CLI tunables though ${PREFIX}/etc/defaults/${app_name}.conf.  This
> could be a huge win for administrators.
>
> Sources of Discussion:
>
> The one bit of this that I'm a little torn about is the situation for
> NFS mounting /usr or /usr/local.  That said, ${PREFIX}/etc/rc.conf
> could also be /etc/rc.conf because /etc/rc.conf shouldn't be NFS
> mounted.  What I think would be the ideal situation would be to
> sourcing all three defaults in this order: defaults,
> ${PREFIX}/etc/rc.conf, then /etc/rc.conf.
>
> Thoughts?  -sc

I think this is a good ideal and have started implementing rc.conf support
with the last update to the cyrus-sasl port due to the need to select which
pwcheck[_pam] program to use when the ${PREFIX}/etc/rc.d/pwcheck.sh script
is run.

The cyrus-sasl2 port will have a few more variables
(saslauthd_[enable|program|mech|remote_host|socket]).

Currently the pwcheck.sh & saslauthd.sh scripts are used to document the
variables, and set default values for the variables using:

if [ -z "${sasl_pwcheck_program}" ] ; then
    sasl_pwcheck_program=${PREFIX}/sbin/pwcheck
fi

How about adding the following warning to the top of
${PREFIX}/etc/defaults/rc.conf file:

#!/bin/sh
#

# This is rc.conf- a file used to source ${script_conf} which is a file
# full of useful variables that you can set to change the default startup
# behavior of your system.  You should not edit this file!  Put any
# overrides into ${ports_rc_conf_files} and # you will be able to
# update these defaults later without spamming your local configuration
# information.
#
# The ${ports_rc_conf_files} files should only contain values which
# override values set in this file.  This eases the upgrade path when
# defaults are changed and new features are added.
#
# If you are NFS mounting {$PREFIX} to other systems, you should place
# system specific overrides into /etc/rc.conf.
#
# All arguments must be in double or single quotes.
#
ports_rc_conf_files="${PREFIX}/etc/rc.conf /etc/rc.conf /etc/rc.conf.local"

# Bring in port's script specific variables from ${script_conf}

if [ ! -z "${script_conf}" -a -r ${PREFIX}/etc/default/${script_conf} ];
then
    . ${PREFIX}/etc/default/${script_conf}
fi

##############################################################
### Define source_ports_rc_confs, the mechanism used by port ##
### scripts to source rc_conf_files overrides safely.       ##
##############################################################

eval source_ports_rc_conf_defined=\$source_${script_conf%%.conf}_defined

if [ -z "${source_ports_rc_conf_defined}" ]; then
        eval source_${script_conf}_defined=yes
        source_ports_rc_confs () {
                local i sourced_files
                for i in ${ports_rc_conf_files}; do
                        case ${sourced_files} in
                        *:$i:*)
                                ;;
                        *)
                                sourced_files="${sourced_files}:$i:"
                                if [ -r $i ]; then
                                        . $i
                                fi
                                ;;
                        esac
                done
        }
fi
-----

Scot




To Unsubscribe: send mail to majordomo@FreeBSD.org
with "unsubscribe freebsd-ports" in the body of the message




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?00ec01c1b37f$2ec58680$11fd2fd8>