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

Russell Jackson raj at csub.edu
Mon Oct 11 20:36:33 UTC 2010


On 10/06/2010 01:45 PM, Devin Teske wrote:
> Hello fellow freebsd-hackers,
>
> Long-time hacker, first-time poster.
>
> I'd like to share a shell script that I wrote for FreeBSD system
> administration.
>
> The attached shell script works similar to sysctl(8), but rather than
> querying or working on sysctl MIBs, it instead works on the /etc/rc.conf
> (and /etc/rc.conf.local) files.
>

Have you looked at textproc/augeas? It's a more generic and extensible 
way to edit plain text configuration files programmatically using an 
xpath like syntax.

Example

# augtool get /files/etc/rc.conf/sshd_enable
/files/etc/rc.conf/sshd_enable = YES
# printf 'set /files/etc/rc.conf/sshd_enable NO\nsave\n' | augtool
# augtool get /files/etc/rc.conf/sshd_enable
/files/etc/rc.conf/sshd_enable = NO


The tool itself is written in C and has no external dependencies. It is 
taught file grammar via "lenses" which are like formal language specs 
written in BNF.

http://augeas.net/

-- 
Russell A Jackson <raj at csub.edu>
Network Analyst
California State University, Bakersfield


More information about the freebsd-hackers mailing list