Re: git: c9be47b34dd8 - main - rc: add ${name}_setup script support
- Go to: [ bottom of page ] [ top of archives ] [ this month ]
Date: Mon, 15 Aug 2022 15:27:17 UTC
Thats a good point.
cc the author
On Mon, 15 Aug 2022 at 17:19, Colin Percival <cperciva@tarsnap.com> wrote:
> Can we have rc.subr(8) updated to reflect this change? It's not at all
> clear
> to me how foo_setup is different from start_precmd.
>
> Colin Percival
>
> On 8/15/22 07:42, Mariusz Zaborski wrote:
> > The branch main has been updated by oshogbo:
> >
> > URL:
> https://cgit.FreeBSD.org/src/commit/?id=c9be47b34dd847da1d4ab0feee4a6100b2c5ea0d
> >
> > commit c9be47b34dd847da1d4ab0feee4a6100b2c5ea0d
> > Author: Franco Fichtner <franco@opnsense.org>
> > AuthorDate: 2022-08-15 14:41:31 +0000
> > Commit: Mariusz Zaborski <oshogbo@FreeBSD.org>
> > CommitDate: 2022-08-15 14:43:12 +0000
> >
> > rc: add ${name}_setup script support
> >
> > Run a service-based setup script before running the start command.
> > Useful for automatic configuration file generation.
> >
> > Reviewed by: https://reviews.freebsd.org/D36006
> > ---
> > libexec/rc/rc.subr | 14 +++++++++++---
> > 1 file changed, 11 insertions(+), 3 deletions(-)
> >
> > diff --git a/libexec/rc/rc.subr b/libexec/rc/rc.subr
> > index 612ee12883ec..9ae93dc391a2 100644
> > --- a/libexec/rc/rc.subr
> > +++ b/libexec/rc/rc.subr
> > @@ -804,6 +804,8 @@ startmsg()
> > #
> > # ${name}_prepend n Command added before ${command}.
> > #
> > +# ${name}_setup n Command executed before ${command}.
> > +#
> > # ${name}_login_class n Login class to use, else "daemon".
> > #
> > # ${name}_limits n limits(1) to apply to ${command}.
> > @@ -993,8 +995,8 @@ run_rc_command()
> > _group=\$${name}_group _groups=\$${name}_groups \
> > _fib=\$${name}_fib _env=\$${name}_env \
> > _prepend=\$${name}_prepend
> _login_class=\${${name}_login_class:-daemon} \
> > - _limits=\$${name}_limits _oomprotect=\$${name}_oomprotect \
> > - _env_file=\$${name}_env_file
> > + _limits=\$${name}_limits _oomprotect=\$${name}_oomprotect \
> > + _setup=\$${name}_setup _env_file=\$${name}_env_file
> >
> > if [ -n "$_env_file" ] && [ -r "${_env_file}" ]; then # load env
> from file
> > set -a
> > @@ -1149,6 +1151,12 @@ $command $rc_flags $command_args"
> > fi
> > fi
> >
> > + if [ -n "$_setup" ]; then
> > + if ! _run_rc_doit "$_setup"; then
> > + warn "failed to setup ${name}"
> > + fi
> > + fi
> > +
> > # Prepend default limits
> > _doit="$_cd limits -C $_login_class $_limits
> $_doit"
> >
> > @@ -2187,7 +2195,7 @@ check_kern_features()
> > # check_namevarlist var
> > # Return "0" if ${name}_var is reserved in rc.subr.
> >
> > -_rc_namevarlist="program chroot chdir env flags fib nice user group
> groups prepend"
> > +_rc_namevarlist="program chroot chdir env flags fib nice user group
> groups prepend setup"
> > check_namevarlist()
> > {
> > local _v
> >
>
> --
> Colin Percival
> Security Officer Emeritus, FreeBSD | The power to serve
> Founder, Tarsnap | www.tarsnap.com | Online backups for the truly paranoid
>