From owner-freebsd-hackers@FreeBSD.ORG Sat Oct 9 18:02:02 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 C8A3F1065673 for ; Sat, 9 Oct 2010 18:02:02 +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 863D18FC12 for ; Sat, 9 Oct 2010 18:02:02 +0000 (UTC) Received: by iwn8 with SMTP id 8so2631393iwn.13 for ; Sat, 09 Oct 2010 11:02:01 -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=jJiQFbjRCz3Uu7lE1CeponxLmseX3+hZV0MlU6A43fI=; b=c+CAO1yQzfZZvhh/B3XyeMqIA/am2elnn78NXmuKx/0zjpinyn/Puboje+g5O7yToM ggpbGdQcuEwH/VC8x8NnqbPgmproRdzNDqXSBo1ZyKfyN+YUUgSaMg4DFDG8031r79d3 CpFsMTmQMLO0Imqkf3vy0ytLpydgUAGs96WLU= 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=GWf7hW9+v4DgiqqBsCPFLhnhmlFvA4gNjiuTEEAh9LQiq//BxE3fStv3S+wiAH5DbO riI5EK2hOvwecXo1TZ5ko59Egx93RH9TGAJ0UY7NdHvYqAOyICRf7isRP41BGLGqpb8T ueusSIzHgbQj3wnaBQ8BZT8xOK4J8qgWxnLs4= MIME-Version: 1.0 Received: by 10.42.215.134 with SMTP id he6mr777960icb.527.1286647321731; Sat, 09 Oct 2010 11:02:01 -0700 (PDT) Sender: yanegomi@gmail.com Received: by 10.231.184.3 with HTTP; Sat, 9 Oct 2010 11:02:01 -0700 (PDT) In-Reply-To: <0206CB74-6E83-4762-B26D-F95E024C90F0@vicor.com> References: <1286397912.27308.40.camel@localhost.localdomain> <51B4504F-5AA4-47C5-BF23-FA51DE5BC8C8@vicor.com> <4CAD513F.3010903@DataIX.net> <4CAD7563.1070706@DataIX.net> <4CAD7CA1.4050202@freebsd.org> <0206CB74-6E83-4762-B26D-F95E024C90F0@vicor.com> Date: Sat, 9 Oct 2010 11:02:01 -0700 X-Google-Sender-Auth: yYkpLGhQRHLKAb1qQmrc_ktaJv8 Message-ID: From: Garrett Cooper To: Devin Teske Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: Brandon Gooch , freebsd-hackers@freebsd.org Subject: Re: sysrc -- 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: Sat, 09 Oct 2010 18:02:02 -0000 On Sat, Oct 9, 2010 at 10:36 AM, Devin Teske wrote: > > On Oct 9, 2010, at 10:03 AM, Garrett Cooper wrote: > >> On Thu, Oct 7, 2010 at 12:54 AM, Julian Elischer wr= ote: >>> =A0On 10/7/10 12:23 AM, jhell wrote: >>>> >>>> Alright thank you for your explanation. I do not normally see this usa= ge >>>> and this just sort of stood out at me and I did not want to assume wha= t >>>> you were trying to accomplish, without asking. >>> >>> three useage cases come to mind immediately. >>> >>> 1/ use within other scripts.. >>> =A0instead of the dozens of homegrown solutions people have written for= puting >>> something >>> into /etc/rc.conf =A0one can use this. >>> >>> 2/ what is the value of X on machines a,b,c >>> =A0foreach machine in a b c >>> =A0do >>> =A0 =A0 =A0ssh $machine sysrc X >>> =A0done >>> >>> =A0 =A0you may well say "you could have used grep" bu tgrep doesn't giv= e the >>> default value vie the >>> =A0 hierachy of .rc files. >>> 2A is of course to correc teh values found to be wrong with (2) >>> >>> 3/ on a really small system, without an editor this may do a cleaner jo= b >>> than the usual >>> =A0"grep -v X /etc/rc.conf >/tmp/x;echo X >> /tmp/x; mv /tmp/x /etc/rc.= conf" >> >> =A0 =A0I was going to say... >> >> 3A On a system where you're logged in via singleuser, sometimes >> terminal settings don't work correctly with editors (these days it's >> mostly because /usr isn't available so it can't load ncurses apps, >> some libs, termcap, etc). That would be a lifesaver in this case. > > I hadn't realized that. That's stupendous! > > Though I do believe that `/rescue/vi' exists these days as a statically-l= inked binary (built using crunchgen(1) via `rescue/rescue/Makefile' in the = FreeBSD source tree). Yeah, but unfortunately if some filesystems aren't mounted [ /usr, /var, etc ] back in the 5.x days (that's when I got into FreeBSD) [until recently after ed@'s work on syscons and libteken?], most utilities like vi and ee are braindead when it comes to printing characters on the screen. I've screwed up and forgot to put down nfs shares as noauto a few times, and also tinkered around with ata <-> ahci within the past couple months, so until I learned enough sed to comment out lines in fstab, booting up my system didn't work out too well :/. >> =A0 =A0But then I realized that this command probably would live in >> /usr/sbin and would probably need other apps in /usr/bin // /usr/sbin >> to run this command :). > > I envisioned it living in `/sbin' and it's actually free of dependencies = to external executables. If you execute it with the "-d" option ('d' for 'd= ependencies'), you can see that it uses only shell internals. The only thin= g this script truly depends on is `/bin/sh'. So it sounds like it would fit= the ability of working within single-user mode quite well (remember, I dev= eloped it for embedded systems -- where things like grep/sed/awk may even b= e missing). Guess it goes to show that I should review the code :). Thanks! -Garrett