sysconf -- a sysctl(8)-like utility for managing /etc/rc.conf et. al.

Devin Teske devin.teske at fisglobal.com
Tue Oct 12 23:07:48 UTC 2010


On Tue, 2010-10-12 at 12:10 -0700, Doug Barton wrote:
> On 2010-10-11 at 10:40 -0700, Doug Barton wrote: 
> | So to summarize, the general idea is a good one and needed, and an area
> | that I'd like to see more work in. Perhaps it might be a good idea to
> | move the discussion about that to freebsd-rc@?
> |
> |On 2010-10-11 at 12:22 -0700, Devin Teske wrote: 
> |> I'll look into signing up for the rc mailing list (didn't see that when
> |> I checked last -- I'll have to look again). Maybe I'll post v2.0 to
> |> there (but will cc back hackers cause I know folks may not be part of
> |> both).
> 
> The canonical way to deal with that is to post the message to the proper
> list (-rc@), then post a brief note to the other list (-hackers@) saying
> where the discussion is being continued. We discourage people from
> cc'ing multiple FreeBSD lists.


This thread is moving over to the -rc@ list.
New thread: sysrc(8) -- a sysctl(8)-like utility for managing rc.conf(5)

The first post to the -rc@ list will be version 2.0 of the script which
attempts to address the following (which were discussed in this thread
here on -hackers@):

1. Style -- remove some personal styles in favor of standardized styles.
(the FreeBSD environment doesn't need all the extra things that are
required to run in an embedded environment -- which the first version
was coded for)

2. Remove a disgusting-amount of comments (the first release of the
script had a hurdle to climb in that it had to establish rapport with
the targeted audience -- y'all).

3. Remove shell inheritance of SUCCESS/FAILURE (this was silly for a
finished product).

4. Remove unnecessary code-sense (some things just don't need to be
tested for in a known environment -- such as FreeBSD vs. embedded).

5. Remove dependency checks (have(), depend(), and show_deps() are
gone).

6. Remove fake "function" keywords (public objections win)

7. Rename sysrc() function to sysrc_get() to:
a. prevent confusion between the script and the internal function
b. to coincide with the remainder of related functions (sysrc_get,
sysrc_set, sysrc_find, and sysrc_desc).

8. Fix sysrc_get() function to mask positional parameters (don't expand
"1", "2", etc.)

9. Fix sysrc_get() function to clean the environment prior to sourcing
rc.conf(5) files (preventing expansion of normals such as PS1, TERM,
etc.)

10. New function: `sysrc_find $varname'
Find which file holds the effective last-assignment to a given variable
within the rc.conf(5) file(s). If the variable is found in any of the
rc.conf(5) files, the function prints the filename it was found in and
then returns success. Otherwise output is NULL and the function returns
with error status.

11. Fix sysrc_set() function to use mktemp(1) (prevent race-conditions
where sysrc(8) could be executing in concurrence, possibly whacking the
output-file in an unexpected manner).

12. New function: `sysrc_desc $varname'
Attempts to return the comments associated with varname from the rc.conf
(5) defaults file `/etc/defaults/rc.conf' (or whatever RC_DEFAULTS
points to). Multi-line comments are joined together. Results are NULL if
no description could be found.

13. Use getopts(1) to parse command-line options rather than manually
parsing (now we can support grouping of flags -- i.e. "-avN").

14. Remove `--help' option (using getopts(1) now ... that was the only
long-option we had, and we don't need it).

15. Remove `-d' as we know it. No longer dump internal dependency list,
but mimick `-d' from sysctl(8) -- Print a description of the given
variable.

16. Remove `SYSRC_SHOW_DEPS' environment variable.

17. Add `SYSRC_VERBOSE' environment variable (inheritable from the
shell, so that folks whom don't want to always pass `-v' can plop
`SYSRC_VERBOSE=1' into their shell startup scripts, `~/.bash_profile'
and `~/.profile' for example).

18. Add `-f file' option.
Operate on the specified file(s) instead of rc_conf_files.

19. Add `-a' option.
Dump a list of non-default configuration variables.

20. Add `-A' option.
Dump a list of all configuration variables (incl. defaults).

21. Add `-v' option.
Verbose. Print the pathname of the specific rc.conf(5) file where the
directive was found.

22. Add `-i' option.
Ignore unknown variables.

23. Add `-N' option.
Show only variable names, not their values.



And, here's the new usage:

Usage: sysrc [OPTIONS] name[=value] ...
OPTIONS:
        -h         Print this message to stderr and exit.
        -f file    Operate on the specified file(s) instead of rc_conf_files.
        -a         Dump a list of non-default configuration variables.
        -A         Dump a list of all configuration variables (incl. defaults).
        -d         Print a description of the given variable.
        -e         Print query results as `var=value' (useful for producing
                   output to be fed back in). Ignored if -n is specified.
        -v         Verbose. Print the pathname of the specific rc.conf(5)
                   file where the directive was found.
        -i         Ignore unknown variables.
        -n         Show only variable values, not their names.
        -N         Show only variable names, not their values.

ENVIRONMENT:
        RC_DEFAULTS      Location of `/etc/defaults/rc.conf' file.
        SYSRC_VERBOSE    Default verbosity. Set to non-NULL to enable.


See you all on the -rc@ list.
-- 
Cheers,
Devin Teske

-> CONTACT INFORMATION <-
Business Solutions Consultant II
FIS - fisglobal.com
510-735-5650 Mobile
510-621-2038 Office
510-621-2020 Office Fax
909-477-4578 Home/Fax
devin.teske at fisglobal.com

-> LEGAL DISCLAIMER <-
This message  contains confidential  and proprietary  information
of the sender,  and is intended only for the person(s) to whom it
is addressed. Any use, distribution, copying or disclosure by any
other person  is strictly prohibited.  If you have  received this
message in error,  please notify  the e-mail sender  immediately,
and delete the original message without making a copy.

-> FUN STUFF <-
-----BEGIN GEEK CODE BLOCK-----
Version 3.1
GAT/CS d(+) s: a- C++(++++) UB++++$ P++(++++) L++(++++) !E--- W++ N? o? K- w O
M+ V- PS+ PE Y+ PGP- t(+) 5? X+(++) R>++ tv(+) b+(++) DI+(++) D(+) G+>++ e>+ h
r>++ y+ 
------END GEEK CODE BLOCK------
http://www.geekcode.com/

-> END TRANSMISSION <-

_____________

The information contained in this message is proprietary and/or confidential. If you are not the intended recipient, please: (i) delete the message and all copies; (ii) do not disclose, distribute or use the message in any manner; and (iii) notify the sender immediately. In addition, please be aware that any message addressed to our domain is subject to archiving and review by persons other than the intended recipient. Thank you.
_____________


More information about the freebsd-hackers mailing list