Current-Users archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Re: Proposed new /etc/rc.d/drvctl script



On Thu, Apr 10, 2025 at 01:20:09AM +0700, Robert Elz wrote:
>     Date:        Wed, 9 Apr 2025 10:01:01 -0700 (PDT)
>     From:        Paul Goyette <paul%whooppee.com@localhost>
>     Message-ID:  <Pine.NEB.4.64.2504090958500.20455%speedy.whooppee.com@localhost>
> 
>   | Thanks this works fine with the precmd defined in rc.d/modules.  Now I
>   | just gotta figure out the syntax for putting it in the rc.conf file.
> 
> There's no syntax for that.

Excuse me?  It's a simple shell variable assignment.  At least in
rc.conf.d/$service.  I never tested that in rc.conf.

> pre (and post) commands aren't designed for
> user config, they're for the scripts to use to do something which is
> needed to be done, usually so that the rc system's default start command
> can then be used (eg: rc.d/yppasswd uses it to check the YP (NIS) domainname
> is set, and has no specific start command function, other scripts use
> it to migrate old configs to new, or set up chroot environments).

What makes you think that?

Specifically rc.conf(5) says:

     rc.d(8) scripts that use load_rc_config from rc.subr(8) also support
     sourcing an optional end-user provided per-script override file
     /etc/rc.conf.d/service, (where service is the contents of the name
     variable in the rc.d(8) script).  This may contain variable overrides,
     including allowing the end-user to override various run_rc_command
     rc.d(8) control variables, and thus changing the operation of the script
     without requiring editing of the script.

It specifically mentions overriding run_rc_command control variables and
${service_precmd is one of them.

> Using it for this is no better (and no reason in this case to do it that
> way) that just modifying the rc.d/modules start command to include a
> drvctl line before the loop reading its config file.

It's clearly better to separate your local customizations in a separate
file that doesn't need to be manually merged when a new etc set is
installed.

> Either way (adding a precmd or just modifying the start command) is
> truly a gross hack, not nearly as clean as the rc.d/drvctl script
> idea.

Au contraire!  Being able to "wrap" existing functions with instructions
to be executed before and after them is a powerful concept.  It's one of
the good ideas that we have implemented in the rc.d framework. 

It's essential for automating system configuration and running things at
scale.  Even the systemd developers noticed that.

--chris


Home | Main Index | Thread Index | Old Index