Greetings. Just for note.
Some time ago i thought about the same problem. I started something then had delayed it forever in favour of fast wrong way. So, the aim was: --- NAME modcfg - modify configuration SYNOPSIS modcfg -f config_file -t config_type {-s param=val | -u param} modcfg -l modcfg -i plugin DESCRIPTION The modcfg utility modifies configuration file in accordance to parameters. The following options are available: -f config_file - the file itself which to be modified -t config_type - type of config_file. Type specifies the internal structure of config_file, or, more roughly, program which this file belongs to. To list available types see -l option. -s param=val - set configuration parameter 'param' to value 'val'. -u param - unset configuration parameter 'param' (or set it to default). -l - list all supported types of config files. -i plugin - install plugin 'plugin' for modcfg utility. Plugin is used to support additional configuration file type. EXAMPLES The command modcfg -f /etc/rc.conf -t rc -s keymap=ru.cp1251 sets parameter 'keymap' to value 'ru.cp1251'in file rc.conf. The command modcfg -f /etc/rc.conf -t rc -u keymap resets parameter 'keymap' to default value. To install obtained plugin 'samba.mcfg' use modcfg -i samba.mcfg After that configuration type 'samba' will be supported. --- INTERNALLY modcfg itself is very simple. It parse command line options, then load plugin (module) for specified 'config_type', then call _set(file,param, value) or _unset(file,param) function from this module. So, plugin (module) should have functions such as: _set(file, param, value) or, better name, {$type}_set. rc_set, for example. _unset(file, param) _description - for display in module list. FUTURE Of course, better way is to run modcfg as: modcfg rc {-s ... | -u ...} i.e. reduce "-f /etc/rc.conf -t rc" to the key "rc", i.e. add another call scheme modcfg subsystem {-s ... | -u ...} For rc it is trivial. But in general, for all installed programs and they instances, it is not possible now. Wednesday, October 13, 2010, 3:06:25 AM, you wrote: DT> 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...@? >> | >> |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. DT> This thread is moving over to the -rc@ list. DT> New thread: sysrc(8) -- a sysctl(8)-like utility for managing rc.conf(5) DT> The first post to the -rc@ list will be version 2.0 of the script which DT> attempts to address the following (which were discussed in this thread DT> here on -hackers@): DT> 1. Style -- remove some personal styles in favor of standardized styles. DT> (the FreeBSD environment doesn't need all the extra things that are DT> required to run in an embedded environment -- which the first version DT> was coded for) DT> 2. Remove a disgusting-amount of comments (the first release of the DT> script had a hurdle to climb in that it had to establish rapport with DT> the targeted audience -- y'all). DT> 3. Remove shell inheritance of SUCCESS/FAILURE (this was silly for a DT> finished product). DT> 4. Remove unnecessary code-sense (some things just don't need to be DT> tested for in a known environment -- such as FreeBSD vs. embedded). DT> 5. Remove dependency checks (have(), depend(), and show_deps() are DT> gone). DT> 6. Remove fake "function" keywords (public objections win) DT> 7. Rename sysrc() function to sysrc_get() to: DT> a. prevent confusion between the script and the internal function DT> b. to coincide with the remainder of related functions (sysrc_get, DT> sysrc_set, sysrc_find, and sysrc_desc). DT> 8. Fix sysrc_get() function to mask positional parameters (don't expand DT> "1", "2", etc.) DT> 9. Fix sysrc_get() function to clean the environment prior to sourcing DT> rc.conf(5) files (preventing expansion of normals such as PS1, TERM, DT> etc.) DT> 10. New function: `sysrc_find $varname' DT> Find which file holds the effective last-assignment to a given variable DT> within the rc.conf(5) file(s). If the variable is found in any of the DT> rc.conf(5) files, the function prints the filename it was found in and DT> then returns success. Otherwise output is NULL and the function returns DT> with error status. DT> 11. Fix sysrc_set() function to use mktemp(1) (prevent race-conditions DT> where sysrc(8) could be executing in concurrence, possibly whacking the DT> output-file in an unexpected manner). DT> 12. New function: `sysrc_desc $varname' DT> Attempts to return the comments associated with varname from the rc.conf DT> (5) defaults file `/etc/defaults/rc.conf' (or whatever RC_DEFAULTS DT> points to). Multi-line comments are joined together. Results are NULL if DT> no description could be found. DT> 13. Use getopts(1) to parse command-line options rather than manually DT> parsing (now we can support grouping of flags -- i.e. "-avN"). DT> 14. Remove `--help' option (using getopts(1) now ... that was the only DT> long-option we had, and we don't need it). DT> 15. Remove `-d' as we know it. No longer dump internal dependency list, DT> but mimick `-d' from sysctl(8) -- Print a description of the given DT> variable. DT> 16. Remove `SYSRC_SHOW_DEPS' environment variable. DT> 17. Add `SYSRC_VERBOSE' environment variable (inheritable from the DT> shell, so that folks whom don't want to always pass `-v' can plop DT> `SYSRC_VERBOSE=1' into their shell startup scripts, `~/.bash_profile' DT> and `~/.profile' for example). DT> 18. Add `-f file' option. DT> Operate on the specified file(s) instead of rc_conf_files. DT> 19. Add `-a' option. DT> Dump a list of non-default configuration variables. DT> 20. Add `-A' option. DT> Dump a list of all configuration variables (incl. defaults). DT> 21. Add `-v' option. DT> Verbose. Print the pathname of the specific rc.conf(5) file where the DT> directive was found. DT> 22. Add `-i' option. DT> Ignore unknown variables. DT> 23. Add `-N' option. DT> Show only variable names, not their values. DT> And, here's the new usage: DT> Usage: sysrc [OPTIONS] name[=value] ... DT> OPTIONS: DT> -h Print this message to stderr and exit. DT> -f file Operate on the specified file(s) instead of rc_conf_files. DT> -a Dump a list of non-default configuration variables. DT> -A Dump a list of all configuration variables (incl. defaults). DT> -d Print a description of the given variable. DT> -e Print query results as `var=value' (useful for producing DT> output to be fed back in). Ignored if -n is specified. DT> -v Verbose. Print the pathname of the specific rc.conf(5) DT> file where the directive was found. DT> -i Ignore unknown variables. DT> -n Show only variable values, not their names. DT> -N Show only variable names, not their values. DT> ENVIRONMENT: DT> RC_DEFAULTS Location of `/etc/defaults/rc.conf' file. DT> SYSRC_VERBOSE Default verbosity. Set to non-NULL to enable. DT> See you all on the -rc@ list. -- Best regards, Anthony mailto:a...@mail.ru _______________________________________________ freebsd-hackers@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/freebsd-hackers To unsubscribe, send any mail to "freebsd-hackers-unsubscr...@freebsd.org"