Date: Wed, 6 Oct 2010 18:09:48 -0500 From: Brandon Gooch <jamesbrandongooch@gmail.com> 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: <AANLkTikoohMo5ng-RM3tctTH__P6cqhQpm=FPhSE9mMg@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 3: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[=value] ... > OPTIONS: > -h --help Print this message to stderr and exit. > -d Print list of internal dependencies before exit. > -e Print query results as `var=value' (useful for producing > output to be fed back in). Ignored if -n is specified. > -n Show only variable values, not their names. > > ENVIRONMENT: > SYSCONF_SHOW_DEPS Dump list of dependencies. Must be zero or one > (default: `0') > RC_DEFAULTS Location of `/etc/defaults/rc.conf' file. > > Examples: > > root@mymachine ~ $ sysconf hostname > hostname: mymachine.localdomain > root@mymachine ~ $ sysconf hostname=foomaster.deluxe.com > hostname: mymachine.localdomain -> foomaster.deluex.com > root@mymachine ~ $ sysconf -e hostname > hostname="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. It seems the list ate the attachment :( Also, take a look at sysconf(3). I think there may be a certain amount of hesitation to welcome a utility with the same name as a POSIX-compliant C library function... ...how about a name like 'sysrc' or 'rcconfig' or something indicating a relationship with the rc.conf file or rc system? Anyway, sounds cool, as I've had a need recently to do some automated configuring of several rc.conf files -- my method was very hackish, and will never see the light of public scrutiny :) -Brandon
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTikoohMo5ng-RM3tctTH__P6cqhQpm=FPhSE9mMg>
