Date: Wed, 6 Oct 2010 15:12:34 -0700 From: Garrett Cooper <gcooper@FreeBSD.org> To: Devin Teske <dteske@vicor.com> Cc: freebsd-hackers@freebsd.org Subject: Re: sysconf -- a sysctl(8)-like utility for managing /etc/rc.conf et. al. Message-ID: <AANLkTikHW_9WKiZHH=Ci=m7qm9OgJ5DpS=d7Aa6NY51g@mail.gmail.com> In-Reply-To: <1286397912.27308.40.camel@localhost.localdomain> References: <1286397912.27308.40.camel@localhost.localdomain>
next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Oct 6, 2010 at 1:45 PM, Devin Teske <dteske@vicor.com> 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. > > Syntax shown below (available by running the script without arguments): > > Usage: sysconf [OPTIONS] name[=3Dvalue] ... > OPTIONS: > =A0 =A0 =A0 =A0-h --help =A0 Print this message to stderr and exit. > =A0 =A0 =A0 =A0-d =A0 =A0 =A0 =A0 =A0Print list of internal dependencies = before exit. > =A0 =A0 =A0 =A0-e =A0 =A0 =A0 =A0 =A0Print query results as `var=3Dvalue'= (useful for producing > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0output to be fed back in). Ignored= if -n is specified. > =A0 =A0 =A0 =A0-n =A0 =A0 =A0 =A0 =A0Show only variable values, not their= names. > > ENVIRONMENT: > =A0 =A0 =A0 =A0SYSCONF_SHOW_DEPS =A0 =A0 Dump list of dependencies. Must = be zero or one > =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0(default: `0') > =A0 =A0 =A0 =A0RC_DEFAULTS =A0 =A0 =A0 =A0 =A0 Location of `/etc/defaults= /rc.conf' file. > > Examples: > > root@mymachine ~ $ sysconf hostname > hostname: mymachine.localdomain > root@mymachine ~ $ sysconf hostname=3Dfoomaster.deluxe.com > hostname: mymachine.localdomain -> foomaster.deluex.com > root@mymachine ~ $ sysconf -e hostname > hostname=3D"foomaster.deluxe.com" > root@mymachine ~ $ sysconf -n hostname > foomaster.deluxe.com > > The script has zero external dependencies. None. Period. It will use > grep(1) if installed, but it is not required. > > Tested extensively on FreeBSD-4.8, FreeBSD-4.11, FreeBSD-8.0, and > FreeBSD-8.1. I haven't looked at this yet, but this will result in user confusion as it differs in purpose from sysconf(3) (which is a POSIX API that helps determine system configuration tunable variables)... Thanks, -Garrett
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTikHW_9WKiZHH=Ci=m7qm9OgJ5DpS=d7Aa6NY51g>