conf/163508: [rc.subr] [patch] Add "enable" and "disable" commands to rc.subr

Maxim Ignatenko gelraen.ua at gmail.com
Sat Dec 24 15:22:19 UTC 2011


On 24 December 2011 15:15, Chris Rees <crees at freebsd.org> wrote:
> On 24 December 2011 12:30, Maxim Ignatenko <gelraen.ua at gmail.com> wrote:
>> The following reply was made to PR conf/163508; it has been noted by GNATS.
>>
>> From: Maxim Ignatenko <gelraen.ua at gmail.com>
>> To: Doug Barton <dougb at freebsd.org>
>> Cc: bug-followup at freebsd.org
>> Subject: Re: conf/163508: [rc.subr] [patch] Add &quot;enable&quot; and
>>  &quot;disable&quot; commands to rc.subr
>> Date: Sat, 24 Dec 2011 14:20:19 +0200
>>
>>  On 24 December 2011 04:15, Doug Barton <dougb at freebsd.org> wrote:
>>  > This idea has been considered before and rejected because it's too
>>  > difficult to catch all the corner cases, and actually editing a config
>>  > file is not really all that hard of a thing to do.
>>  >
>>
>>  The idea was to make enabling/disabling services less error-prone. It
>>  don't need to catch _all_ corner cases, because if administrator do
>>  something unusual with startup configuration he should be able to
>>  manipulate it in proper way, or even have tools that do something
>>  similar.
>>  Proposed patch handles /etc/rc.conf, /etc/rc.conf.local and
>>  /etc/rc.conf.d/* properly (I hope), so it should fit nicely in 95% of
>>  cases.
>>  Doing `service someserive enable` is much faster and less error-prone
>>  that `service someservice rcvar ; echo someservicercvar_enable=YES >>
>>  /etc/rc.conf`
>
> Disagree, sorry.
>
> If we're going to implement these ideas we should do it properly, not
> for 95% of cases.
>

It's impossible to handle all cases. For example, how this can be
detected and properly altered without bloating code:

for c in n a m e d _ e n a b l e; do
var=${var}${c}
done
for c in y e s; do
val=${val}${c}
done
eval ${var}=\$${val}

Since proposed patch adds variable to last included file, it will not
actually work only if user changed /etc/rc.subr to include one more
file after /etc/rc.conf.d/${name}. So, while /etc/rc.subr is
unmdified, it will do the job.


More information about the freebsd-rc mailing list