From owner-freebsd-hackers@FreeBSD.ORG Mon Oct 11 20:36:32 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 E411B1065670 for ; Mon, 11 Oct 2010 20:36:32 +0000 (UTC) (envelope-from raj@csub.edu) Received: from mh0.csub.edu (mh0.csub.edu [136.168.1.94]) by mx1.freebsd.org (Postfix) with ESMTP id C10CB8FC12 for ; Mon, 11 Oct 2010 20:36:32 +0000 (UTC) Received: from [136.168.65.65] (strider.csub.edu [136.168.65.65]) (authenticated bits=0) by mh0.csub.edu (8.14.3/8.14.3) with ESMTP id o9BKaVbN096500 (version=TLSv1/SSLv3 cipher=AES256-SHA bits=256 verify=NO) for ; Mon, 11 Oct 2010 13:36:32 -0700 (PDT) (envelope-from raj@csub.edu) X-DKIM: Sendmail DKIM Filter v2.8.3 mh0.csub.edu o9BKaVbN096500 DKIM-Signature: v=1; a=rsa-sha1; c=simple/simple; d=csub.edu; s=mailhub.csub.edu; t=1286829392; bh=r8JvE4SGlnHgG4DvQUGBOu2YNB4=; h=Message-ID:Date:From:MIME-Version:To:Subject:References: In-Reply-To:Content-Type:Content-Transfer-Encoding; b=Rd5pOrl0XNwiszNT3sKON1sUNtsXsoDjbMu7dtNcsKWrBMZOBKOcqQNs5UYoCEJPN rOdLoP8cROlDKcT0uAjc13dcQkRp6xB/+pP1YQx2DH7Pkpf+tsizpuos3/3+Gy7E6B LyVcSSNSVrf/QfCtL7qq1fkRZEUXzF9jArOOrXiU= Message-ID: <4CB3749C.1040000@csub.edu> Date: Mon, 11 Oct 2010 13:33:32 -0700 From: Russell Jackson Organization: California State University Bakersfield User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; en-US; rv:1.9.2.11) Gecko/20101007 Thunderbird/3.1.5 MIME-Version: 1.0 To: freebsd-hackers@freebsd.org References: <1286397912.27308.40.camel@localhost.localdomain> In-Reply-To: <1286397912.27308.40.camel@localhost.localdomain> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit 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: Mon, 11 Oct 2010 20:36:33 -0000 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 Network Analyst California State University, Bakersfield