From owner-freebsd-hackers@FreeBSD.ORG Wed Oct 6 22:12:36 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 24199106566B for ; Wed, 6 Oct 2010 22:12:36 +0000 (UTC) (envelope-from yanegomi@gmail.com) Received: from mail-iw0-f182.google.com (mail-iw0-f182.google.com [209.85.214.182]) by mx1.freebsd.org (Postfix) with ESMTP id DD33D8FC20 for ; Wed, 6 Oct 2010 22:12:35 +0000 (UTC) Received: by iwn8 with SMTP id 8so87522iwn.13 for ; Wed, 06 Oct 2010 15:12:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:sender:received :in-reply-to:references:date:x-google-sender-auth:message-id:subject :from:to:cc:content-type:content-transfer-encoding; bh=yKRAcAUe2yBXlP4nxy79KVeO+D2l/JwFprfWyapA/zU=; b=n0G5KjP5vBBxg4PNbONOkz2uSj8E92yA3Yiu3qExcZYQ+VORVbxq2oI7QN1yHydZ38 fx2giQEZkjWk7n9cF4rNwv14dnjoFZct/XcRnSAbKPQ8g8TcgqCmsMM5lvuO9RCETPAu CpN3wo9zJOnmo4BoXgTYnj1UeCZrvwVdN6rek= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:in-reply-to:references:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type :content-transfer-encoding; b=Sy2DFqD8one/Yjh8bxUci6ov8YumM30auu7v5VU4G8kFfbXAlIf28+2eBj0V2toKhP pXEuekB6vjfiD/3zBJClkC0BC6kVn/BMcLUQe2DubjNqiPyWyzHMds4ABoqdaOuTAfDv Dc8DfhK2m7/U1z2be1NNwizXsVhYbvS/JcEN4= MIME-Version: 1.0 Received: by 10.42.99.3 with SMTP id u3mr1641450icn.124.1286403154995; Wed, 06 Oct 2010 15:12:34 -0700 (PDT) Sender: yanegomi@gmail.com Received: by 10.231.184.3 with HTTP; Wed, 6 Oct 2010 15:12:34 -0700 (PDT) In-Reply-To: <1286397912.27308.40.camel@localhost.localdomain> References: <1286397912.27308.40.camel@localhost.localdomain> Date: Wed, 6 Oct 2010 15:12:34 -0700 X-Google-Sender-Auth: vorfeRJ15IzHk4FSdT4ruQnaHu8 Message-ID: From: Garrett Cooper To: Devin Teske Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-hackers@freebsd.org Subject: Re: sysconf -- a sysctl(8)-like utility for managing /etc/rc.conf et. al. X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 06 Oct 2010 22:12:36 -0000 On Wed, Oct 6, 2010 at 1: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. > > 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