Can you give me real life examples please where it would be useful. I don’t want to add configuration knob for a couple of obscur use cases.
Thanks. — Antoine > On 21 May 2022, at 22:26, Aaron Bieber <[email protected]> wrote: > > > >> On Sat, May 21, 2022, at 10:56 AM, aisha wrote: >>> On 5/21/2022 12:24 PM, Antoine Jacoutot wrote: >>> On Sat, May 21, 2022 at 12:04:03PM -0400, A Tammy wrote: >>>> On 5/21/2022 10:53 AM, Antoine Jacoutot wrote: >>>>> Hi. >>>>> >>>>> This diff allows to configure an directory from which we run rc.d >>>>> commands. >>>>> This can be useful for daemons that must cd into a specific directory prio >>>>> launching. >>>>> >>>>> Here's an example for the automounter. >>>>> Some rc.d scripts in ports can benefit from this as well (so we can remove >>>>> handcrafted rc_start function and use the default). >>>>> >>>>> Comments / OK? >>>>> >>>>> Index: amd >>>>> =================================================================== >>>>> RCS file: /cvs/src/etc/rc.d/amd,v >>>>> retrieving revision 1.9 >>>>> diff -u -p -r1.9 amd >>>>> --- amd 11 Jan 2018 21:09:26 -0000 1.9 >>>>> +++ amd 21 May 2022 14:52:07 -0000 >>>>> @@ -7,16 +7,13 @@ daemon="/usr/sbin/amd" >>>>> . /etc/rc.d/rc.subr >>>>> pexp="${daemon}.*" >>>>> +rc_execdir=/etc/amd >>>>> rc_reload=NO >>>>> rc_stop=NO >>>>> rc_pre() { >>>>> [[ -e ${amd_master} ]] || return 1 >>>>> daemon_flags="${daemon_flags} $(print -rn -- $(< ${amd_master}))" >>>>> -} >>>>> - >>>>> -rc_start() { >>>>> - ${rcexec} "cd /etc/amd; ${daemon} ${daemon_flags}" >>>>> } >>>>> rc_cmd $1 >>>>> >>>>> >>>>> >>>>> Index: etc/rc.d/rc.subr >>>>> =================================================================== >>>>> RCS file: /cvs/src/etc/rc.d/rc.subr,v >>>>> retrieving revision 1.153 >>>>> diff -u -p -r1.153 rc.subr >>>>> --- etc/rc.d/rc.subr 21 May 2022 10:50:09 -0000 1.153 >>>>> +++ etc/rc.d/rc.subr 21 May 2022 14:49:17 -0000 >>>>> @@ -164,8 +164,11 @@ rc_exec() { >>>>> [ "${daemon_rtable}" -eq "$(id -R)" ] || >>>>> _rcexec="route -T ${daemon_rtable} exec ${_rcexec}" >>>>> - ${_rcexec} "${daemon_logger:+set -o pipefail; }$@${daemon_logger:+ >>>>> 2>&1 | >>>>> - logger -ip ${daemon_logger} -t ${_name}}" >>>>> + ${_rcexec} "${daemon_logger:+set -o pipefail; } \ >>>>> + ${rc_execdir:+cd ${rc_execdir} && } \ >>>>> + $@ \ >>>>> + ${daemon_logger:+ 2>&1 | >>>>> + logger -ip ${daemon_logger} -t ${_name}}" >>>>> } >>>>> rc_start() { >>>>> Index: share/man/man8/rc.subr.8 >>>>> =================================================================== >>>>> RCS file: /cvs/src/share/man/man8/rc.subr.8,v >>>>> retrieving revision 1.43 >>>>> diff -u -p -r1.43 rc.subr.8 >>>>> --- share/man/man8/rc.subr.8 21 May 2022 14:11:39 -0000 1.43 >>>>> +++ share/man/man8/rc.subr.8 21 May 2022 14:49:17 -0000 >>>>> @@ -194,9 +194,10 @@ Execute process using >>>>> according to >>>>> .Va daemon_class , >>>>> .Va daemon_user , >>>>> -.Va daemon_rtable >>>>> -and >>>>> +.Va daemon_rtable , >>>>> .Va daemon_logger >>>>> +and >>>>> +.Va rc_execdir >>>> Is there a reason why you've chosen it to be rc_execdir instead of >>>> daemon_execdir? >>>> Calling it `daemon_execdir` (and possibly allowing it to be modified from >>>> /etc/rc.conf.local) >>>> would be inline with other daemon_* variables. >>>> The first thing that comes to my mind would be people who want to start >>>> multiple copies of >>>> a daemon, e.g. navidrome or calibre-web, create libraries in the start >>>> directory. >>>> I personally don't have anything except calibre-web, so no strong opinions >>>> on this. >>> I wondered the same but came to the conclusion there where not that many use >>> cases and implementing rc_ is easier. >>> Going for daemon_ will mean changing rcctl as well. >>> >>> I have no strong preference honestly. >>> If people think it will be handy to change this in rc.conf.local, I will >>> change the implementation. >> In that case, my vote is for it to be called daemon_execdir :) > > Mine too! :D > >>>> Also, if it is decided to keep it rc_execdir, does it need to be added to >>>> the man page? >>>> It is not something thats going to be exposed user side. >>> Yes it is needed. >>> It is exposed to people creating rc.d scripts; which is exactly what >>> rc.subr(8) is for. >>> Users will read rc.d(8). >>> Also that kind of contradicts your point for using daemon_ >>> >>> >>>>> values. >>>>> .It Ic rc_reload >>>>> Send the >>>>> @@ -305,6 +306,9 @@ in an >>>>> .Nm rc.d >>>>> script to force starting the daemon in background when using the default >>>>> .Ic rc_start . >>>>> +.It Va rc_execdir >>>>> +Change to this directory before running >>>>> +.Ic rc_exec . >>>>> .It Va rc_reload >>>>> Can be set to >>>>> .Dq NO >>>>> >>>>> >
