From owner-freebsd-rc@FreeBSD.ORG Sun Oct 10 04:05:22 2010 Return-Path: Delivered-To: freebsd-rc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id EE8F11065673 for ; Sun, 10 Oct 2010 04:05:21 +0000 (UTC) (envelope-from jhellenthal@gmail.com) Received: from mail-yw0-f54.google.com (mail-yw0-f54.google.com [209.85.213.54]) by mx1.freebsd.org (Postfix) with ESMTP id 9FB218FC0A for ; Sun, 10 Oct 2010 04:05:21 +0000 (UTC) Received: by ywh2 with SMTP id 2so456359ywh.13 for ; Sat, 09 Oct 2010 21:05:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:message-id:date:from :organization:user-agent:mime-version:to:cc:subject:references :in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; bh=hjTy1wQlDKdLEW8lPlR6s1kZE9AuVSruc9raenrfxrw=; b=vSUWMT2gwba53YnGLOipetnfahgPDy7hJSeedVPMkEp73YX9v4yXbiDojc72SSUlwI IhwEuvSTE+PaLE4ptZ0frFnFSdPH7ovyCicRAGXWfSqeQH78TBtHeuZpK+yqjU+I/8TT nKzn7CAFUmHymgNz5WVOTSslBCD//mCBikOHw= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:message-id:date:from:organization:user-agent:mime-version:to :cc:subject:references:in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; b=Gsm8HlUSlJFnSykdQMZ8SGfRteKE2LaaeWxTce34Oyo2KTyT/IUNy69zNYMCGqWKpl H+lmCIQ3oU7U0yctEWpBdaYTvTQuOBCp/QcBxoekhwki3Vds9jLjcmuv6VLO+Z2mixIV v4/2WdwdVSe3Vqyrp6+gRJ0yTM66G+/JN2siY= Received: by 10.150.201.18 with SMTP id y18mr5049945ybf.329.1286682106252; Sat, 09 Oct 2010 20:41:46 -0700 (PDT) Received: from centel.dataix.local ([99.181.144.115]) by mx.google.com with ESMTPS id v9sm4519174yba.3.2010.10.09.20.41.43 (version=SSLv3 cipher=RC4-MD5); Sat, 09 Oct 2010 20:41:44 -0700 (PDT) Sender: "J. Hellenthal" Message-ID: <4CB135F5.20804@DataIX.net> Date: Sat, 09 Oct 2010 23:41:41 -0400 From: jhell Organization: http://www.DataIX.net User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.9.2.9) Gecko/20100917 Lightning/1.0b1 Thunderbird MIME-Version: 1.0 To: pluknet References: <4C76CA06.5010001@FreeBSD.org> In-Reply-To: X-Enigmail-Version: 1.1.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: Doug Barton , freebsd-rc@freebsd.org, FreeBSD Current Subject: Re: [RFC] ifconfig description support in rc.d X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Oct 2010 04:05:22 -0000 On 08/27/2010 05:17, pluknet wrote: > On 27 August 2010 00:09, Doug Barton wrote: >> On 08/26/2010 12:53 PM, pluknet wrote: >>> >>> [cc'ing current@ as rc@ looks too quite] >>> >>> Hi. >>> >>> Since ifconfig has grown to label interfaces with >>> ifconfig $ifname description "foobar", what about >>> to give it more life and store i/face descriptions >>> semi-permanently, so they will survive between reboots? >>> >>> This patch adds a functionality to rc.d to label >>> interfaces at boot time. >>> >>> Comments are welcome. >> >> This seems like a good addition, thanks. Please also write a patch for >> rc.conf.5 to describe this new functionality and I'll be happy to commit it. > > Xin Li helped me with updating rc.conf.5 (thanks!). > It's included in attached patch. > >> One note below. >> >> >>> --- etc/network.subr (revision 211280) >>> +++ etc/network.subr (working copy) >>> @@ -1187,6 +1187,24 @@ >>> return 0 >>> } >>> >>> +# ifnet_descr >>> +# Add description to all requested interfaces. >>> +# >>> +ifnet_descr() >>> +{ >>> + local _if _ifdescr >>> + >>> + # ifconfig_IF_descr >>> + for _if in `ifconfig -l`; do >>> + _ifdescr="`get_if_var $_if ifconfig_IF_descr`" >>> + if [ ! -z "$_ifdescr" ]; then >> >> This is probably better as [ -n "$_ifdescr" ] >> > > This was blindly copy&pasted after ifnet_rename(). > So, it makes sense probably to change test expression there as well. > [see ifnet_rename() proposed change below inline] > This change to ifnet_rename() is not included in attached patch > to not complicate things unnecessarily for now. > > Index: etc/network.subr > =================================================================== > --- etc/network.subr (revision 211280) > +++ etc/network.subr (working copy) > @@ -1179,7 +1179,7 @@ > # ifconfig_IF_name > for _if in `ifconfig -l`; do > _ifname=`get_if_var $_if ifconfig_IF_name` > - if [ ! -z "$_ifname" ]; then > + if [ -n "$_ifname" ]; then > ifconfig $_if name $_ifname > fi > done Was this ever committed ? If so does anyone have any referring svn revisions ? Also if this is committed or planned to be committed is there a chance it could be MFC'd ? Would be awesome if this was available on a production release without patching ;) Thanks in advance, -- jhell,v From owner-freebsd-rc@FreeBSD.ORG Sun Oct 10 06:57:16 2010 Return-Path: Delivered-To: freebsd-rc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4D0EA1065672; Sun, 10 Oct 2010 06:57:16 +0000 (UTC) (envelope-from pluknet@gmail.com) Received: from mail-qw0-f54.google.com (mail-qw0-f54.google.com [209.85.216.54]) by mx1.freebsd.org (Postfix) with ESMTP id E2BEB8FC0A; Sun, 10 Oct 2010 06:57:15 +0000 (UTC) Received: by qwe4 with SMTP id 4so912239qwe.13 for ; Sat, 09 Oct 2010 23:57:15 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:received:in-reply-to :references:date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=QXXFFsNT2JMqeFbsuwxQZUmACRdgtbZ5YdIupnPP17I=; b=NsKMmXCvXwBmIJfL4UKTkqKwTv3jHK1+uEq/mx4vbLF0hPcNp+QRmvEaGAetaDwKGD ZwSbhOoF9+ZfGTSGWUBgATnG143EzrH4ntmq5/eUlRq0fAqv9AYm6vpc6Tz5Z9ZALhuN e7vMjYH1ohmXzGt9gRG2kPEQyHNzLg3WuesmY= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=Vnqm1WzqxfB2mxLvFrFsDva422WpvP21R6fduP+zeaQETV6pt1+T63CiUjVNDQLch8 sly0RhEnrCt70pgJ1J6fVU4E5tCFhZE+VHZnnOCj/cvR58npqcOvFgkvcBrL+xu/Itav p9ofFwKKHqoSzaRuxw/jH0q5nIeVPBFCMso/o= MIME-Version: 1.0 Received: by 10.224.49.72 with SMTP id u8mr3282269qaf.9.1286692180461; Sat, 09 Oct 2010 23:29:40 -0700 (PDT) Received: by 10.229.61.29 with HTTP; Sat, 9 Oct 2010 23:29:40 -0700 (PDT) In-Reply-To: <4CB135F5.20804@DataIX.net> References: <4C76CA06.5010001@FreeBSD.org> <4CB135F5.20804@DataIX.net> Date: Sun, 10 Oct 2010 10:29:40 +0400 Message-ID: From: Sergey Kandaurov To: jhell Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: Doug Barton , freebsd-rc@freebsd.org, FreeBSD Current Subject: Re: [RFC] ifconfig description support in rc.d X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Oct 2010 06:57:16 -0000 On 10 October 2010 07:41, jhell wrote: > On 08/27/2010 05:17, pluknet wrote: >> On 27 August 2010 00:09, Doug Barton wrote: >>> On 08/26/2010 12:53 PM, pluknet wrote: >>>> >>>> [cc'ing current@ as rc@ looks too quite] >>>> >>>> Hi. >>>> >>>> Since ifconfig has grown to label interfaces with >>>> ifconfig $ifname description "foobar", what about >>>> to give it more life and store i/face descriptions >>>> semi-permanently, so they will survive between reboots? >>>> >>>> This patch adds a functionality to rc.d to label >>>> interfaces at boot time. >>>> >>>> Comments are welcome. >>> >>> This seems like a good addition, thanks. Please also write a patch for >>> rc.conf.5 to describe this new functionality and I'll be happy to commi= t it. >> >> Xin Li helped me with updating rc.conf.5 (thanks!). >> It's included in attached patch. >> >>> =A0One note below. >>> >>> >>>> --- etc/network.subr =A0 =A0(revision 211280) >>>> +++ etc/network.subr =A0 =A0(working copy) >>>> @@ -1187,6 +1187,24 @@ >>>> =A0 =A0 =A0 =A0 return 0 >>>> =A0} >>>> >>>> +# ifnet_descr >>>> +# =A0 =A0 =A0Add description to all requested interfaces. >>>> +# >>>> +ifnet_descr() >>>> +{ >>>> + =A0 =A0 =A0 local _if _ifdescr >>>> + >>>> + =A0 =A0 =A0 # ifconfig_IF_descr >>>> + =A0 =A0 =A0 for _if in `ifconfig -l`; do >>>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 _ifdescr=3D"`get_if_var $_if ifconfig_IF= _descr`" >>>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if [ ! -z "$_ifdescr" ]; then >>> >>> This is probably better as [ -n "$_ifdescr" ] >>> >> >> This was blindly copy&pasted after ifnet_rename(). >> So, it makes sense probably to change test expression there as well. >> [see ifnet_rename() proposed change below inline] >> This change to ifnet_rename() is not included in attached patch >> to not complicate things unnecessarily for now. >> >> Index: etc/network.subr >> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >> --- etc/network.subr =A0 =A0(revision 211280) >> +++ etc/network.subr =A0 =A0(working copy) >> @@ -1179,7 +1179,7 @@ >> =A0 =A0 =A0 =A0 # ifconfig_IF_name >> =A0 =A0 =A0 =A0 for _if in `ifconfig -l`; do >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 _ifname=3D`get_if_var $_if ifconfig_IF_n= ame` >> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 if [ ! -z "$_ifname" ]; then >> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if [ -n "$_ifname" ]; then >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ifconfig $_if name $_ifn= ame >> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 fi >> =A0 =A0 =A0 =A0 done > > Was this ever committed ? If so does anyone have any referring svn > revisions ? > > Also if this is committed or planned to be committed is there a chance > it could be MFC'd ? > > Would be awesome if this was available on a production release without > patching ;) > Hi. I'm going to commit this after a proper review. --=20 wbr, pluknet From owner-freebsd-rc@FreeBSD.ORG Sun Oct 10 17:45:03 2010 Return-Path: Delivered-To: freebsd-rc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id BCE12106566B for ; Sun, 10 Oct 2010 17:45:03 +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 7D4E28FC08 for ; Sun, 10 Oct 2010 17:45:03 +0000 (UTC) Received: by iwn8 with SMTP id 8so3574154iwn.13 for ; Sun, 10 Oct 2010 10:45:02 -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=d7g4DoVKRWMbEIFdnmlUlgbeCBw1Co15pK/o6HMWNnM=; b=sygAbuTnT5MXLfF0rP7FuyPdQ+612wmr+aTjQ5au3CI6TgK+LN2GFZxyB0ZcBmFxTh P7YdN/xjSYomYZoohQAuonSGZCdqFE0lbsvaOtUtcMI+q5Q5KQmQsQCauBNo8GoKuB2c PwmlSxLcmEZlVHTHItJ/rZCunCkqXghAAV/DI= 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=l0Yc5ZVsI2jIidmBpMlxp+6twome9JutXKeh8ENm4aqGAcdYSClLrIihFhgKgbb69D Jgq6D1Fntl2w4tCA1kUqMGpa/uUOQCQ6OfTMHAH/F2D5KHyCUFFe6lvGiK4rMqUpnft9 oEApApUbAxRXerGIo1qkHKlZShjm0ByxA2RU4= MIME-Version: 1.0 Received: by 10.231.12.11 with SMTP id v11mr2224140ibv.13.1286731385016; Sun, 10 Oct 2010 10:23:05 -0700 (PDT) Sender: yanegomi@gmail.com Received: by 10.231.184.3 with HTTP; Sun, 10 Oct 2010 10:23:04 -0700 (PDT) In-Reply-To: References: <4C76CA06.5010001@FreeBSD.org> <4CB135F5.20804@DataIX.net> Date: Sun, 10 Oct 2010 10:23:04 -0700 X-Google-Sender-Auth: MLEfSXI5xQ9R6uf-VpTNILAmtPM Message-ID: From: Garrett Cooper To: Sergey Kandaurov Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: jhell , Doug Barton , freebsd-rc@freebsd.org, FreeBSD Current Subject: Re: [RFC] ifconfig description support in rc.d X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 10 Oct 2010 17:45:03 -0000 On Sat, Oct 9, 2010 at 11:29 PM, Sergey Kandaurov wrote= : > On 10 October 2010 07:41, jhell wrote: >> On 08/27/2010 05:17, pluknet wrote: >>> On 27 August 2010 00:09, Doug Barton wrote: >>>> On 08/26/2010 12:53 PM, pluknet wrote: >>>>> >>>>> [cc'ing current@ as rc@ looks too quite] >>>>> >>>>> Hi. >>>>> >>>>> Since ifconfig has grown to label interfaces with >>>>> ifconfig $ifname description "foobar", what about >>>>> to give it more life and store i/face descriptions >>>>> semi-permanently, so they will survive between reboots? >>>>> >>>>> This patch adds a functionality to rc.d to label >>>>> interfaces at boot time. >>>>> >>>>> Comments are welcome. >>>> >>>> This seems like a good addition, thanks. Please also write a patch for >>>> rc.conf.5 to describe this new functionality and I'll be happy to comm= it it. >>> >>> Xin Li helped me with updating rc.conf.5 (thanks!). >>> It's included in attached patch. >>> >>>> =A0One note below. >>>> >>>> >>>>> --- etc/network.subr =A0 =A0(revision 211280) >>>>> +++ etc/network.subr =A0 =A0(working copy) >>>>> @@ -1187,6 +1187,24 @@ >>>>> =A0 =A0 =A0 =A0 return 0 >>>>> =A0} >>>>> >>>>> +# ifnet_descr >>>>> +# =A0 =A0 =A0Add description to all requested interfaces. >>>>> +# >>>>> +ifnet_descr() >>>>> +{ >>>>> + =A0 =A0 =A0 local _if _ifdescr >>>>> + >>>>> + =A0 =A0 =A0 # ifconfig_IF_descr >>>>> + =A0 =A0 =A0 for _if in `ifconfig -l`; do >>>>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 _ifdescr=3D"`get_if_var $_if ifconfig_I= F_descr`" >>>>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if [ ! -z "$_ifdescr" ]; then >>>> >>>> This is probably better as [ -n "$_ifdescr" ] >>>> >>> >>> This was blindly copy&pasted after ifnet_rename(). >>> So, it makes sense probably to change test expression there as well. >>> [see ifnet_rename() proposed change below inline] >>> This change to ifnet_rename() is not included in attached patch >>> to not complicate things unnecessarily for now. >>> >>> Index: etc/network.subr >>> =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D >>> --- etc/network.subr =A0 =A0(revision 211280) >>> +++ etc/network.subr =A0 =A0(working copy) >>> @@ -1179,7 +1179,7 @@ >>> =A0 =A0 =A0 =A0 # ifconfig_IF_name >>> =A0 =A0 =A0 =A0 for _if in `ifconfig -l`; do >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 _ifname=3D`get_if_var $_if ifconfig_IF_= name` >>> - =A0 =A0 =A0 =A0 =A0 =A0 =A0 if [ ! -z "$_ifname" ]; then >>> + =A0 =A0 =A0 =A0 =A0 =A0 =A0 if [ -n "$_ifname" ]; then >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 ifconfig $_if name $_if= name >>> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 fi >>> =A0 =A0 =A0 =A0 done >> >> Was this ever committed ? If so does anyone have any referring svn >> revisions ? >> >> Also if this is committed or planned to be committed is there a chance >> it could be MFC'd ? >> >> Would be awesome if this was available on a production release without >> patching ;) >> > > Hi. > > I'm going to commit this after a proper review. I'm not sure it would get resolved after this commit, but one minor annoyance is that restarting the netif rc.d script purges all gateways set, so I have to do and restart the routing rc.d script (if my connectivity doesn't get whacked). I think there was something else with natd and ipfw that I've run into in the past where I've restarted those scripts and things weren't all puppydogs and rainbows on my CURRENT systems. Thanks, -Garrett From owner-freebsd-rc@FreeBSD.ORG Mon Oct 11 04:20:02 2010 Return-Path: Delivered-To: rc@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 655A2106564A for ; Mon, 11 Oct 2010 04:20: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 29DDE8FC0C for ; Mon, 11 Oct 2010 04:20:01 +0000 (UTC) Received: by iwn8 with SMTP id 8so4059509iwn.13 for ; Sun, 10 Oct 2010 21:20: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:date :x-google-sender-auth:message-id:subject:from:to:content-type; bh=HNrVmcVeiUSQ/H1P4t4J4j2VGzF4cBpBaZ829M677XA=; b=w9tD2HNsUFGMUL1B/VlSoSvDDS22vkbLXk77RKSgcbm2hJkjtj7vtv33z376GL8R8/ X3VvMZVGZU7lFV3F8OMRTaOgXQtoOrufVeCXLhoMp7P6EfZlX0qxC/IrsmDTb/DtZjpy QqZst6ZXs40cHglg95d6k3f4VDPs3kFme55Zc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:content-type; b=bDUs6A3utIZSZH5kUgQa1Vqn6tYBQNzNmS7RMXYxustQonZ2PVHxNTAO8ri4H2B7wL cgReTjngp45LSucglmqA9zh7ykw6VxYTDTZJ/7cFbGT9Z9s1MWiHAqzk3YdTzZ3LoDZD QzuXCtVp3wMtzixlKU6cJkQwsnvbHim2gyJ8A= MIME-Version: 1.0 Received: by 10.231.36.8 with SMTP id r8mr4125004ibd.128.1286768904447; Sun, 10 Oct 2010 20:48:24 -0700 (PDT) Sender: yanegomi@gmail.com Received: by 10.231.184.3 with HTTP; Sun, 10 Oct 2010 20:48:24 -0700 (PDT) Date: Sun, 10 Oct 2010 20:48:24 -0700 X-Google-Sender-Auth: _zh6OFpMqauLnxYztfGMBwXt4JM Message-ID: From: Garrett Cooper To: rc@FreeBSD.org Content-Type: multipart/mixed; boundary=0021cc0224d275283604924f3b27 Cc: Subject: [PATCH] /etc/rc.d/mdconfig improvements X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Oct 2010 04:20:02 -0000 --0021cc0224d275283604924f3b27 Content-Type: text/plain; charset=ISO-8859-1 Hi RC folks, I was looking at /etc/rc.d/mdconfig* recently, and I thought of two improvements that could be done to the scripts: 1. It's not overly intuitive from the rc.conf manpage that the memory disks need to be defined in /etc/fstab, so I added an error to coach people on what to do 2. There was also a missing guard for around a ${_file} reference where if I did... /dev/md0 /scratch cd9660 rw 0 0 /dev/md1 /scratch2 ufs rw 0 0 mdconfig_md0="-f /scratch/disk.img -t vnode" mdconfig_md1="-t swap -s 1M" ... it would check test for ${_file} twice and fail the second time. The check is benign in most cases, but for completeness it should be fixed as shown above. Could someone please commit the attached patch for me, if no one objects to the change proposed? Thanks, -Garrett --0021cc0224d275283604924f3b27 Content-Type: application/octet-stream; name="etc-rc.d-mdconfig-improvements.diff" Content-Disposition: attachment; filename="etc-rc.d-mdconfig-improvements.diff" Content-Transfer-Encoding: base64 X-Attachment-Id: f_gf4simyp0 SW5kZXg6IGV0Yy9yYy5kL21kY29uZmlnCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIGV0Yy9yYy5kL21kY29uZmln CShyZXZpc2lvbiAyMTM2ODApCisrKyBldGMvcmMuZC9tZGNvbmZpZwkod29ya2luZyBjb3B5KQpA QCAtMTQ2LDYgKzE0Niw4IEBACiAJCQlpZiBtb3VudCAtZCAke19kZXZ9IDI+JjEgPi9kZXYvbnVs bDsgdGhlbgogCQkJCWVjaG8gIk1vdW50aW5nICR7X2Rldn0uIgogCQkJCW1vdW50ICR7X2Rldn0K KwkJCWVsc2UKKwkJCQllcnIgMSAiTW91bnRwb2ludCBmb3IgJHtfZGV2fSBub3QgZGVmaW5lZCBp biAvZXRjL2ZzdGFiIgogCQkJZmkKIAkJZmkKIAlkb25lCkluZGV4OiBldGMvcmMuZC9tZGNvbmZp ZzIKPT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PQotLS0gZXRjL3JjLmQvbWRjb25maWcyCShyZXZpc2lvbiAyMTM2ODApCisr KyBldGMvcmMuZC9tZGNvbmZpZzIJKHdvcmtpbmcgY29weSkKQEAgLTExMyw5ICsxMTMsMTEgQEAK IAogCWZvciBfbWQgaW4gJHtfbWRjb25maWcyX2xpc3R9OyBkbwogCQlpbml0X3ZhcmlhYmxlcyAk e19tZH0KLQkJaWYgWyAhIC1yICR7X2ZpbGV9IF07IHRoZW4KLQkJCWVyciAzICIke19maWxlfSBk b2Vzbid0IGV4aXN0IgotCQkJY29udGludWUKKwkJaWYgWyAiJHt0eXBlfSIgPSAidm5vZGUiIF07 IHRoZW4KKwkJCWlmIFsgISAtciAiJHtfZmlsZX0iIF07IHRoZW4KKwkJCQllcnIgMyAiJHtfZmls ZX0gZG9lc24ndCBleGlzdCIKKwkJCQljb250aW51ZQorCQkJZmkKIAkJZmkKIAkJIyBGaXJzdCBw YXNzOiBjcmVhdGUgbWQoNCkgdm5vZGUgZGV2aWNlcyBmcm9tIGZpbGVzIHN0b3JlZCBvbgogCQkj IG5vbi1yb290IHBhcnRpdGlvbi4gU3dhcCBhbmQgbWFsbG9jIG1kKDQpIGRldmljZXMgaGF2ZSBh bHJlYWR5Cg== --0021cc0224d275283604924f3b27-- From owner-freebsd-rc@FreeBSD.ORG Mon Oct 11 04:43:37 2010 Return-Path: Delivered-To: rc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 4B00A106566B; Mon, 11 Oct 2010 04:43:37 +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 02D468FC13; Mon, 11 Oct 2010 04:43:36 +0000 (UTC) Received: by iwn8 with SMTP id 8so4077986iwn.13 for ; Sun, 10 Oct 2010 21:43:36 -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:date :x-google-sender-auth:message-id:subject:from:to:cc:content-type; bh=V0J5YrYhksNORxxDeb4xtiTegjCQ6/jkru/OZfNLmso=; b=pbjsBK3SEfPY8iDHbPtV7hVsFHv3YLMcuL1RA3xwp9YfOn3DAD3BizWEwRpy7iALW2 n6uUgnS41SLASUEHG14fVnvFgSI+1i2nqJa9hcZKJWDmu5AULV/EbsZsuvoOnhmHagnX FLl+2G6V7tCHPFUJEgr/CKEaP+DegGbQh8aqc= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:sender:date:x-google-sender-auth:message-id:subject :from:to:cc:content-type; b=tJnki1laab/69Pus8e1CDC8AeZML8oWa/qMe/li7ZDEOBoRFfDvkrO80xfIt1NULqr baDENn0FizTZ9b8wkg1l+n32OpAHvFiYGyngu7DAjg5YLapMzaznjyhRPjXqat31Yrii rVX0XUI7UWuC2WlMnA2rWLOIzdojpVGW+9wLE= MIME-Version: 1.0 Received: by 10.42.104.206 with SMTP id s14mr1603255ico.141.1286772216348; Sun, 10 Oct 2010 21:43:36 -0700 (PDT) Sender: yanegomi@gmail.com Received: by 10.231.184.3 with HTTP; Sun, 10 Oct 2010 21:43:36 -0700 (PDT) Date: Sun, 10 Oct 2010 21:43:36 -0700 X-Google-Sender-Auth: AJl5v1g-dBkzuDZuwuj1ebR4Cyk Message-ID: From: Garrett Cooper To: bug-followup@FreeBSD.org, j.unger@jpru.de Content-Type: multipart/mixed; boundary=20cf303bfef0dcc1720492500002 Cc: rc@freebsd.org Subject: Re: conf/122477: [patch] /etc/rc.d/mdconfig and mdconfig2 are ignoring additional parameter in some cases X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Oct 2010 04:43:37 -0000 --20cf303bfef0dcc1720492500002 Content-Type: text/plain; charset=ISO-8859-1 IMO, the problem with this feature is lack of documentation when it was converted from ramdisk_* to mdconfig_md*. How does this patch work for you (you get the support you like via mdconfig_units)? This also removes all of the outdated documentation for ramdisk_* because it's no longer used by rc(8). Thanks, -Garrett --20cf303bfef0dcc1720492500002 Content-Type: application/octet-stream; name="conf-122477.diff" Content-Disposition: attachment; filename="conf-122477.diff" Content-Transfer-Encoding: base64 X-Attachment-Id: f_gf4us6ts0 SW5kZXg6IGV0Yy9yYy5kL21kY29uZmlnCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIGV0Yy9yYy5kL21kY29uZmln CShyZXZpc2lvbiAyMTM2ODApCisrKyBldGMvcmMuZC9tZGNvbmZpZwkod29ya2luZyBjb3B5KQpA QCAtMTc0LDEwICsxNzQsMTEgQEAKIH0KIAogX21kY29uZmlnX2NtZD0iJDEiCitldmFsIF9tZGNv bmZpZ19saXN0PVwkbWRjb25maWdfdW5pdHMKIGlmIFsgJCMgLWd0IDAgXTsgdGhlbgogICAgICAg ICBzaGlmdAogZmkKLVsgLW4gIiQqIiBdICYmIF9tZGNvbmZpZ19saXN0PSIkKiIKK1sgLW4gIiRf bWRjb25maWdfbGlzdCIgLWEgLW4gIiQqIiBdICYmIF9tZGNvbmZpZ19saXN0PSIkKiIKIAogbG9h ZF9yY19jb25maWcgJG5hbWUKIApJbmRleDogZXRjL3JjLmQvbWRjb25maWcyCj09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0K LS0tIGV0Yy9yYy5kL21kY29uZmlnMgkocmV2aXNpb24gMjEzNjgwKQorKysgZXRjL3JjLmQvbWRj b25maWcyCSh3b3JraW5nIGNvcHkpCkBAIC0yMDQsMTAgKzIwNCwxMSBAQAogfQogCiBfbWRjb25m aWcyX2NtZD0iJDEiCitldmFsIF9tZGNvbmZpZzJfbGlzdD1cJG1kY29uZmlnX3VuaXRzCiBpZiBb ICQjIC1ndCAwIF07IHRoZW4KICAgICAgICAgc2hpZnQKIGZpCi1bIC1uICIkKiIgXSAmJiBfbWRj b25maWcyX2xpc3Q9IiQqIgorWyAtbiAiJF9tZGNvbmZpZzJfbGlzdCIgLWEgLW4gIiQqIiBdICYm IF9tZGNvbmZpZzJfbGlzdD0iJCoiCiAKIGxvYWRfcmNfY29uZmlnICRuYW1lCiAKSW5kZXg6IHNo YXJlL21hbi9tYW41L3JjLmNvbmYuNQo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBzaGFyZS9tYW4vbWFuNS9yYy5j b25mLjUJKHJldmlzaW9uIDIxMzY4MCkKKysrIHNoYXJlL21hbi9tYW41L3JjLmNvbmYuNQkod29y a2luZyBjb3B5KQpAQCAtMzk5Nyw2ICszOTk3LDIzIEBACiB3aGljaCBjYXVzZXMgbG9nIGZpbGVz IGZsYWdnZWQgd2l0aCBhCiAuQ20gQwogdG8gYmUgY3JlYXRlZC4KKy5JdCBWYSBtZGNvbmZpZ191 bml0cworLlBxIFZ0IHN0cgorQSBsaXN0IG9mIG9uZSBvciBtb3JlCisuWHIgbWQgNAordW5pdHMg dG8gY29uZmlndXJlIHdpdGgKKy5YciBtZGNvbmZpZyA4CithbmQKKy5YciBuZXdmcyA4CitpbiB0 aW1lIHRvIGJlIG1vdW50ZWQgd2l0aAorLlhyIGZzdGFiIDUgLgorSWYgdW5zcGVjaWZpZWQsIHRo ZQorLlZhIG1kY29uZmlnX21kIE5zIEFxIEFyIFgKK3ZhcmlhYmxlcyBhcmUgZXZhbHVhdGVkIGlu IGNvbnNlY3V0aXZlIG9yZGVyIGZyb20gbWQwLCB1bnRpbCBvbmUgdmFyaWFibGUgaXMKK3Vuc2V0 IG9yIG51bGwuCitTZWUgdGhlCisuVmEgbWRjb25maWdfbWQgTnMgQXEgQXIgWAordmFyaWFibGUg ZGVzY3JpcHRpb25zIGJlbG93IGZvciBtb3JlIGRldGFpbHMuCiAuSXQgVmEgbWRjb25maWdfbWQg TnMgQXEgQXIgWAogLlBxIFZ0IHN0cgogQXJndW1lbnRzIHRvCkBAIC00MDE1LDEwICs0MDMyLDEy IEBACiAuRmwgZiBBciBmaWxlCiBmb3Igdm5vZGUgYmFja2VkCiAuWHIgbWQgNAotZGV2aWNlcy4K LU5vdGUgdGhhdAorZGV2aWNlcy4gRWFjaAogLlZhIG1kY29uZmlnX21kIE5zIEFxIEFyIFgKLXZh cmlhYmxlcyBhcmUgZXZhbHVhdGVkIHVudGlsIG9uZSB2YXJpYWJsZSBpcyB1bnNldCBvciBudWxs LgorZW50cnkgbGlzdGVkIGluCisuVmEgbWRjb25maWdfdW5pdHMKK211c3QgYmUgZGVmaW5lZCBp bgorLlhyIGZzdGFiIDUgLgogLkl0IFZhIG1kY29uZmlnX21kIE5zIEFvIEFyIFggQWMgTnMgVmEg X25ld2ZzCiAuUHEgVnQgc3RyCiBPcHRpb25hbCBhcmd1bWVudHMgcGFzc2VkIHRvCkBAIC00MDgy LDY1ICs0MTAxLDYgQEAKIC5CZCAtbGl0ZXJhbAogbWRjb25maWdfbWQwX2NtZD0idGFyIHhmekMg L3Zhci9maWxlLnRneiBcZSR7X21wfSIKIC5FZAotLkl0IFZhIHJhbWRpc2tfdW5pdHMKLS5QcSBW dCBzdHIKLUEgbGlzdCBvZiBvbmUgb3IgbW9yZSByYW1kaXNrIHVuaXRzIHRvIGNvbmZpZ3VyZSB3 aXRoCi0uWHIgbWRjb25maWcgOAotYW5kCi0uWHIgbmV3ZnMgOAotaW4gdGltZSB0byBiZSBtb3Vu dGVkIGZyb20KLS5YciBmc3RhYiA1IC4KLUVhY2ggbGlzdGVkIHVuaXQKLS5BciBYCi1tdXN0IHNw ZWNpZnkgYXQgbGVhc3QgYQotLkFyIHR5cGUKLWluIGEKLS5WYSByYW1kaXNrXyBOcyBBbyBBciBY IEFjIE5zIFZhIF9jb25maWcKLXZhcmlhYmxlLgotTm90ZSB0aGF0IHRoaXMgd2F5IHRvIGNvbmZp Z3VyZSByYW1kaXNrcyBoYXMgYmVlbiBkZXByZWNhdGVkCi1pbiBmYXZvciBvZiBuZXcKLS5WYSBt ZGNvbmZpZ19tZCoKLXZhcmlhYmxlcyAoc2VlIGFib3ZlKS4KLS5JdCBWYSByYW1kaXNrXyBOcyBB byBBciBYIEFjIE5zIFZhIF9jb25maWcKLS5QcSBWdCBzdHIKLUFyZ3VtZW50cyB0bwotLlhyIG1k Y29uZmlnIDgKLWZvciByYW1kaXNrCi0uQXIgWCAuCi1BdCBtaW5pbXVtIGEKLS5GbCB0IEFyIHR5 cGUKLW11c3QgYmUgc3BlY2lmaWVkLCB3aGVyZQotLkFyIHR5cGUKLW11c3QgYmUgb25lIG9mCi0u Q20gbWFsbG9jCi1vcgotLkNtIHN3YXAgLgotLkl0IFZhIHJhbWRpc2tfIE5zIEFvIEFyIFggQWMg TnMgVmEgX25ld2ZzCi0uUHEgVnQgc3RyCi1PcHRpb25hbCBhcmd1bWVudHMgcGFzc2VkIHRvCi0u WHIgbmV3ZnMgOAotdG8gaW5pdGlhbGl6ZSByYW1kaXNrCi0uQXIgWCAuCi0uSXQgVmEgcmFtZGlz a18gTnMgQW8gQXIgWCBBYyBOcyBWYSBfb3duZXIKLS5QcSBWdCBzdHIKLUFuIG93bmVyc2hpcCBz cGVjaWZpY2F0aW9uIHBhc3NlZCB0bwotLlhyIGNob3duIDgKLWFmdGVyIHRoZSBzcGVjaWZpZWQg cmFtZGlzayB1bml0Ci0uQXIgWAotaGFzIGJlZW4gbW91bnRlZC4KLUJvdGggdGhlCi0uWHIgbWQg NAotZGV2aWNlIGFuZCB0aGUgbW91bnQgcG9pbnQgd2lsbCBiZSBjaGFuZ2VkLgotLkl0IFZhIHJh bWRpc2tfIE5zIEFvIEFyIFggQWMgTnMgVmEgX3Blcm1zCi0uUHEgVnQgc3RyCi1BIG1vZGUgc3Ry aW5nIHBhc3NlZCB0bwotLlhyIGNobW9kIDEKLWFmdGVyIHRoZSBzcGVjaWZpZWQgcmFtZGlzayB1 bml0Ci0uQXIgWAotaGFzIGJlZW4gbW91bnRlZC4KLUJvdGggdGhlCi0uWHIgbWQgNAotZGV2aWNl IGFuZCB0aGUgbW91bnQgcG9pbnQgd2lsbCBiZSBjaGFuZ2VkLgogLkl0IFZhIGF1dG9icmlkZ2Vf aW50ZXJmYWNlcwogLlBxIFZ0IHN0cgogU2V0IHRvIHRoZSBsaXN0IG9mIGJyaWRnZSBpbnRlcmZh Y2VzIHRoYXQgd2lsbCBoYXZlIG5ld2x5IGFycml2aW5nIGludGVyZmFjZXMK --20cf303bfef0dcc1720492500002-- From owner-freebsd-rc@FreeBSD.ORG Mon Oct 11 04:50:03 2010 Return-Path: Delivered-To: freebsd-rc@hub.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E0B4E106566C for ; Mon, 11 Oct 2010 04:50:03 +0000 (UTC) (envelope-from gnats@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id CF0378FC0C for ; Mon, 11 Oct 2010 04:50:03 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o9B4o3JU005060 for ; Mon, 11 Oct 2010 04:50:03 GMT (envelope-from gnats@freefall.freebsd.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o9B4o3qN005058; Mon, 11 Oct 2010 04:50:03 GMT (envelope-from gnats) Date: Mon, 11 Oct 2010 04:50:03 GMT Message-Id: <201010110450.o9B4o3qN005058@freefall.freebsd.org> To: freebsd-rc@FreeBSD.org From: Garrett Cooper Cc: Subject: Re: conf/122477: [patch] /etc/rc.d/mdconfig and mdconfig2 are ignoring additional parameter in some cases X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: Garrett Cooper List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Oct 2010 04:50:04 -0000 The following reply was made to PR conf/122477; it has been noted by GNATS. From: Garrett Cooper To: bug-followup@FreeBSD.org, j.unger@jpru.de Cc: rc@freebsd.org Subject: Re: conf/122477: [patch] /etc/rc.d/mdconfig and mdconfig2 are ignoring additional parameter in some cases Date: Sun, 10 Oct 2010 21:43:36 -0700 --20cf303bfef0dcc1720492500002 Content-Type: text/plain; charset=ISO-8859-1 IMO, the problem with this feature is lack of documentation when it was converted from ramdisk_* to mdconfig_md*. How does this patch work for you (you get the support you like via mdconfig_units)? This also removes all of the outdated documentation for ramdisk_* because it's no longer used by rc(8). Thanks, -Garrett --20cf303bfef0dcc1720492500002 Content-Type: application/octet-stream; name="conf-122477.diff" Content-Disposition: attachment; filename="conf-122477.diff" Content-Transfer-Encoding: base64 X-Attachment-Id: f_gf4us6ts0 SW5kZXg6IGV0Yy9yYy5kL21kY29uZmlnCj09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0KLS0tIGV0Yy9yYy5kL21kY29uZmln CShyZXZpc2lvbiAyMTM2ODApCisrKyBldGMvcmMuZC9tZGNvbmZpZwkod29ya2luZyBjb3B5KQpA QCAtMTc0LDEwICsxNzQsMTEgQEAKIH0KIAogX21kY29uZmlnX2NtZD0iJDEiCitldmFsIF9tZGNv bmZpZ19saXN0PVwkbWRjb25maWdfdW5pdHMKIGlmIFsgJCMgLWd0IDAgXTsgdGhlbgogICAgICAg ICBzaGlmdAogZmkKLVsgLW4gIiQqIiBdICYmIF9tZGNvbmZpZ19saXN0PSIkKiIKK1sgLW4gIiRf bWRjb25maWdfbGlzdCIgLWEgLW4gIiQqIiBdICYmIF9tZGNvbmZpZ19saXN0PSIkKiIKIAogbG9h ZF9yY19jb25maWcgJG5hbWUKIApJbmRleDogZXRjL3JjLmQvbWRjb25maWcyCj09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT0K LS0tIGV0Yy9yYy5kL21kY29uZmlnMgkocmV2aXNpb24gMjEzNjgwKQorKysgZXRjL3JjLmQvbWRj b25maWcyCSh3b3JraW5nIGNvcHkpCkBAIC0yMDQsMTAgKzIwNCwxMSBAQAogfQogCiBfbWRjb25m aWcyX2NtZD0iJDEiCitldmFsIF9tZGNvbmZpZzJfbGlzdD1cJG1kY29uZmlnX3VuaXRzCiBpZiBb ICQjIC1ndCAwIF07IHRoZW4KICAgICAgICAgc2hpZnQKIGZpCi1bIC1uICIkKiIgXSAmJiBfbWRj b25maWcyX2xpc3Q9IiQqIgorWyAtbiAiJF9tZGNvbmZpZzJfbGlzdCIgLWEgLW4gIiQqIiBdICYm IF9tZGNvbmZpZzJfbGlzdD0iJCoiCiAKIGxvYWRfcmNfY29uZmlnICRuYW1lCiAKSW5kZXg6IHNo YXJlL21hbi9tYW41L3JjLmNvbmYuNQo9PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09 PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09PT09Ci0tLSBzaGFyZS9tYW4vbWFuNS9yYy5j b25mLjUJKHJldmlzaW9uIDIxMzY4MCkKKysrIHNoYXJlL21hbi9tYW41L3JjLmNvbmYuNQkod29y a2luZyBjb3B5KQpAQCAtMzk5Nyw2ICszOTk3LDIzIEBACiB3aGljaCBjYXVzZXMgbG9nIGZpbGVz IGZsYWdnZWQgd2l0aCBhCiAuQ20gQwogdG8gYmUgY3JlYXRlZC4KKy5JdCBWYSBtZGNvbmZpZ191 bml0cworLlBxIFZ0IHN0cgorQSBsaXN0IG9mIG9uZSBvciBtb3JlCisuWHIgbWQgNAordW5pdHMg dG8gY29uZmlndXJlIHdpdGgKKy5YciBtZGNvbmZpZyA4CithbmQKKy5YciBuZXdmcyA4CitpbiB0 aW1lIHRvIGJlIG1vdW50ZWQgd2l0aAorLlhyIGZzdGFiIDUgLgorSWYgdW5zcGVjaWZpZWQsIHRo ZQorLlZhIG1kY29uZmlnX21kIE5zIEFxIEFyIFgKK3ZhcmlhYmxlcyBhcmUgZXZhbHVhdGVkIGlu IGNvbnNlY3V0aXZlIG9yZGVyIGZyb20gbWQwLCB1bnRpbCBvbmUgdmFyaWFibGUgaXMKK3Vuc2V0 IG9yIG51bGwuCitTZWUgdGhlCisuVmEgbWRjb25maWdfbWQgTnMgQXEgQXIgWAordmFyaWFibGUg ZGVzY3JpcHRpb25zIGJlbG93IGZvciBtb3JlIGRldGFpbHMuCiAuSXQgVmEgbWRjb25maWdfbWQg TnMgQXEgQXIgWAogLlBxIFZ0IHN0cgogQXJndW1lbnRzIHRvCkBAIC00MDE1LDEwICs0MDMyLDEy IEBACiAuRmwgZiBBciBmaWxlCiBmb3Igdm5vZGUgYmFja2VkCiAuWHIgbWQgNAotZGV2aWNlcy4K LU5vdGUgdGhhdAorZGV2aWNlcy4gRWFjaAogLlZhIG1kY29uZmlnX21kIE5zIEFxIEFyIFgKLXZh cmlhYmxlcyBhcmUgZXZhbHVhdGVkIHVudGlsIG9uZSB2YXJpYWJsZSBpcyB1bnNldCBvciBudWxs LgorZW50cnkgbGlzdGVkIGluCisuVmEgbWRjb25maWdfdW5pdHMKK211c3QgYmUgZGVmaW5lZCBp bgorLlhyIGZzdGFiIDUgLgogLkl0IFZhIG1kY29uZmlnX21kIE5zIEFvIEFyIFggQWMgTnMgVmEg X25ld2ZzCiAuUHEgVnQgc3RyCiBPcHRpb25hbCBhcmd1bWVudHMgcGFzc2VkIHRvCkBAIC00MDgy LDY1ICs0MTAxLDYgQEAKIC5CZCAtbGl0ZXJhbAogbWRjb25maWdfbWQwX2NtZD0idGFyIHhmekMg L3Zhci9maWxlLnRneiBcZSR7X21wfSIKIC5FZAotLkl0IFZhIHJhbWRpc2tfdW5pdHMKLS5QcSBW dCBzdHIKLUEgbGlzdCBvZiBvbmUgb3IgbW9yZSByYW1kaXNrIHVuaXRzIHRvIGNvbmZpZ3VyZSB3 aXRoCi0uWHIgbWRjb25maWcgOAotYW5kCi0uWHIgbmV3ZnMgOAotaW4gdGltZSB0byBiZSBtb3Vu dGVkIGZyb20KLS5YciBmc3RhYiA1IC4KLUVhY2ggbGlzdGVkIHVuaXQKLS5BciBYCi1tdXN0IHNw ZWNpZnkgYXQgbGVhc3QgYQotLkFyIHR5cGUKLWluIGEKLS5WYSByYW1kaXNrXyBOcyBBbyBBciBY IEFjIE5zIFZhIF9jb25maWcKLXZhcmlhYmxlLgotTm90ZSB0aGF0IHRoaXMgd2F5IHRvIGNvbmZp Z3VyZSByYW1kaXNrcyBoYXMgYmVlbiBkZXByZWNhdGVkCi1pbiBmYXZvciBvZiBuZXcKLS5WYSBt ZGNvbmZpZ19tZCoKLXZhcmlhYmxlcyAoc2VlIGFib3ZlKS4KLS5JdCBWYSByYW1kaXNrXyBOcyBB byBBciBYIEFjIE5zIFZhIF9jb25maWcKLS5QcSBWdCBzdHIKLUFyZ3VtZW50cyB0bwotLlhyIG1k Y29uZmlnIDgKLWZvciByYW1kaXNrCi0uQXIgWCAuCi1BdCBtaW5pbXVtIGEKLS5GbCB0IEFyIHR5 cGUKLW11c3QgYmUgc3BlY2lmaWVkLCB3aGVyZQotLkFyIHR5cGUKLW11c3QgYmUgb25lIG9mCi0u Q20gbWFsbG9jCi1vcgotLkNtIHN3YXAgLgotLkl0IFZhIHJhbWRpc2tfIE5zIEFvIEFyIFggQWMg TnMgVmEgX25ld2ZzCi0uUHEgVnQgc3RyCi1PcHRpb25hbCBhcmd1bWVudHMgcGFzc2VkIHRvCi0u WHIgbmV3ZnMgOAotdG8gaW5pdGlhbGl6ZSByYW1kaXNrCi0uQXIgWCAuCi0uSXQgVmEgcmFtZGlz a18gTnMgQW8gQXIgWCBBYyBOcyBWYSBfb3duZXIKLS5QcSBWdCBzdHIKLUFuIG93bmVyc2hpcCBz cGVjaWZpY2F0aW9uIHBhc3NlZCB0bwotLlhyIGNob3duIDgKLWFmdGVyIHRoZSBzcGVjaWZpZWQg cmFtZGlzayB1bml0Ci0uQXIgWAotaGFzIGJlZW4gbW91bnRlZC4KLUJvdGggdGhlCi0uWHIgbWQg NAotZGV2aWNlIGFuZCB0aGUgbW91bnQgcG9pbnQgd2lsbCBiZSBjaGFuZ2VkLgotLkl0IFZhIHJh bWRpc2tfIE5zIEFvIEFyIFggQWMgTnMgVmEgX3Blcm1zCi0uUHEgVnQgc3RyCi1BIG1vZGUgc3Ry aW5nIHBhc3NlZCB0bwotLlhyIGNobW9kIDEKLWFmdGVyIHRoZSBzcGVjaWZpZWQgcmFtZGlzayB1 bml0Ci0uQXIgWAotaGFzIGJlZW4gbW91bnRlZC4KLUJvdGggdGhlCi0uWHIgbWQgNAotZGV2aWNl IGFuZCB0aGUgbW91bnQgcG9pbnQgd2lsbCBiZSBjaGFuZ2VkLgogLkl0IFZhIGF1dG9icmlkZ2Vf aW50ZXJmYWNlcwogLlBxIFZ0IHN0cgogU2V0IHRvIHRoZSBsaXN0IG9mIGJyaWRnZSBpbnRlcmZh Y2VzIHRoYXQgd2lsbCBoYXZlIG5ld2x5IGFycml2aW5nIGludGVyZmFjZXMK --20cf303bfef0dcc1720492500002-- From owner-freebsd-rc@FreeBSD.ORG Mon Oct 11 05:30:26 2010 Return-Path: Delivered-To: freebsd-rc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 55654106564A; Mon, 11 Oct 2010 05:30:26 +0000 (UTC) (envelope-from jhellenthal@gmail.com) Received: from mail-yx0-f182.google.com (mail-yx0-f182.google.com [209.85.213.182]) by mx1.freebsd.org (Postfix) with ESMTP id D05568FC20; Mon, 11 Oct 2010 05:30:25 +0000 (UTC) Received: by yxe42 with SMTP id 42so663172yxe.13 for ; Sun, 10 Oct 2010 22:30:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:message-id:date:from :organization:user-agent:mime-version:to:cc:subject:references :in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; bh=DKf1Q7/+zFcDbnky3Y/efslqtwxCJ4gju8gIpJ1Xsqg=; b=Pungeoh6NH2SnTTg9ME9A9LwfshJTge/8xd2CkwXLL3MVbCdiBjIK0erVICz3pdXW4 VmbQCGtQYszwS1K1f0PIvrJqrTpBxhw274bz/87h7+d2wHWoGR9dbHEaXxhPC/T+KHpq vbr+AkEq6zlSULi/XFvnmG3Sev7RIm+RjFIu0= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:message-id:date:from:organization:user-agent:mime-version:to :cc:subject:references:in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; b=L9ZGWS1IZbJOw+OGab9q2Rh7v7I5Pzr6kyI+Vix8iacIICs+fOCxsRXf4KVQkxQcrl LBHqlJRVR6mzChNjLpFwz/aGCWa/ww6j9Z8LeRArfSrcmpbJY5iJwZTNM9QAmnI2WeQS 7HmmdWu/KuCSyslwQhnWVgenOh9sFxm2Yo4r4= Received: by 10.151.8.8 with SMTP id l8mr6125156ybi.251.1286775024931; Sun, 10 Oct 2010 22:30:24 -0700 (PDT) Received: from centel.dataix.local (adsl-99-181-144-115.dsl.klmzmi.sbcglobal.net [99.181.144.115]) by mx.google.com with ESMTPS id q5sm2425962ybe.6.2010.10.10.22.30.18 (version=SSLv3 cipher=RC4-MD5); Sun, 10 Oct 2010 22:30:19 -0700 (PDT) Sender: "J. Hellenthal" Message-ID: <4CB2A0E9.50108@DataIX.net> Date: Mon, 11 Oct 2010 01:30:17 -0400 From: jhell Organization: http://www.DataIX.net User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.9.2.9) Gecko/20100917 Lightning/1.0b1 Thunderbird MIME-Version: 1.0 To: Garrett Cooper References: <4C76CA06.5010001@FreeBSD.org> <4CB135F5.20804@DataIX.net> In-Reply-To: X-Enigmail-Version: 1.1.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: Doug Barton , FreeBSD Current , Sergey Kandaurov , freebsd-rc@FreeBSD.org Subject: Re: [RFC] ifconfig description support in rc.d X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Oct 2010 05:30:26 -0000 On 10/10/2010 13:23, Garrett Cooper wrote: > > I'm not sure it would get resolved after this commit, but one > minor annoyance is that restarting the netif rc.d script purges all > gateways set, so I have to do and restart the routing rc.d script (if > my connectivity doesn't get whacked). I think there was something else > with natd and ipfw that I've run into in the past where I've restarted > those scripts and things weren't all puppydogs and rainbows on my > CURRENT systems. > > Thanks, > -Garrett Is that the dynamic routes only or also the static routes ? Either or if it would be any of the above it would be nice if these were kept if it was only a restart of the interface, but offhand nothing comes to mind that could prevent this from happening since the routes are acting according to when the interface becomes inactive then the route becomes meaningless. Maybe if the action of 'restart' to etc/rc.d/netif could also call etc/rc.d/routing with 'restart' if the configuration of the interface happens to match one of the recorded routes in rc.conf(5). Just a thought. Regards, -- jhell,v From owner-freebsd-rc@FreeBSD.ORG Mon Oct 11 05:34:25 2010 Return-Path: Delivered-To: freebsd-rc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 33863106566C; Mon, 11 Oct 2010 05:34:25 +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 CBCD28FC19; Mon, 11 Oct 2010 05:34:24 +0000 (UTC) Received: by iwn8 with SMTP id 8so4121114iwn.13 for ; Sun, 10 Oct 2010 22:34:24 -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=PqOYSSeXvVolNAgpkvRhqbTUYaXP1pSokAmbhdPxdlc=; b=KAmLNkJc4qKx1Re5vaYCZGbhQgNGYjuaFSO/4chRo/zFSoRiFJHgZKc2vAVxrih9KQ 91srXtv+7R1GrAQ5jTiZMU8/crm2a1WzME7DGGCAOR0sBQTwD2qEHwPVRrSbfN/iTcuC I5BF1S/5eLGnETImEwNObUBj+MizEccx3kZq8= 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=CGIMBqnHNEqhz4i6ub/Nf52aTIaf/v74wla0gdPbyKbUDX3Rud5AzpsMa19vgvXLKn qDcksaGnegXYxvPGqCGIZC8rtvSk29GCrwrabdr0cw/xpdSdtvQNNRYZbyDlKnUYEfSD YAVkz7i+7WYLY4h8eMF6HV9Akj58y3nkKFM60= MIME-Version: 1.0 Received: by 10.231.150.139 with SMTP id y11mr4316284ibv.80.1286775263870; Sun, 10 Oct 2010 22:34:23 -0700 (PDT) Sender: yanegomi@gmail.com Received: by 10.231.184.3 with HTTP; Sun, 10 Oct 2010 22:34:23 -0700 (PDT) In-Reply-To: <4CB2A0E9.50108@DataIX.net> References: <4C76CA06.5010001@FreeBSD.org> <4CB135F5.20804@DataIX.net> <4CB2A0E9.50108@DataIX.net> Date: Sun, 10 Oct 2010 22:34:23 -0700 X-Google-Sender-Auth: sldb57rLgku4d62xtQZeOnSL-wQ Message-ID: From: Garrett Cooper To: jhell Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: Doug Barton , freebsd-rc@freebsd.org, Sergey Kandaurov , FreeBSD Current Subject: Re: [RFC] ifconfig description support in rc.d X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Oct 2010 05:34:25 -0000 On Sun, Oct 10, 2010 at 10:30 PM, jhell wrote: > On 10/10/2010 13:23, Garrett Cooper wrote: >> >> =A0 =A0 I'm not sure it would get resolved after this commit, but one >> minor annoyance is that restarting the netif rc.d script purges all >> gateways set, so I have to do and restart the routing rc.d script (if >> my connectivity doesn't get whacked). I think there was something else >> with natd and ipfw that I've run into in the past where I've restarted >> those scripts and things weren't all puppydogs and rainbows on my >> CURRENT systems. >> >> Thanks, >> -Garrett > > Is that the dynamic routes only or also the static routes ? > > Either or if it would be any of the above it would be nice if these were > kept if it was only a restart of the interface, but offhand nothing > comes to mind that could prevent this from happening since the routes > are acting according to when the interface becomes inactive then the > route becomes meaningless. > > Maybe if the action of 'restart' to etc/rc.d/netif could also call > etc/rc.d/routing with 'restart' if the configuration of the interface > happens to match one of the recorded routes in rc.conf(5). I just tested it on my test machine and it happens with static routes; dynamic routes automatically get reset by dhclient, et all. It used to be for both though in earlier versions of FreeBSD, IIRC. Thanks! -Garrett From owner-freebsd-rc@FreeBSD.ORG Mon Oct 11 05:45:07 2010 Return-Path: Delivered-To: freebsd-rc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 61319106566B; Mon, 11 Oct 2010 05:45:07 +0000 (UTC) (envelope-from jhellenthal@gmail.com) Received: from mail-yw0-f54.google.com (mail-yw0-f54.google.com [209.85.213.54]) by mx1.freebsd.org (Postfix) with ESMTP id C4C558FC0A; Mon, 11 Oct 2010 05:45:06 +0000 (UTC) Received: by ywh2 with SMTP id 2so643705ywh.13 for ; Sun, 10 Oct 2010 22:45:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:sender:message-id:date:from :organization:user-agent:mime-version:to:cc:subject:references :in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; bh=Cgxm1YPkfHfacz3m6SHMdChw7/wpp6LTodaw1xgbV5g=; b=YnzziOcGNr8di/wJkGJJKLXKSB1jNgA9Jphsl7HmJjCH8n2W4cL/MpWrQltsdWDudO RWkMapRl2rgVfoxXZo42plgIY327BJca7lLMyBFjRifO1Q7VN9NODjB6d7AgqOR48/3p q2YNTeWFIeTXf5AcQIWlBUe27jfUVTDQWcEXs= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=sender:message-id:date:from:organization:user-agent:mime-version:to :cc:subject:references:in-reply-to:x-enigmail-version:content-type :content-transfer-encoding; b=E2BD4OKad/ElsiArcFUIWx2KJzl48R9JGy52Fql3NWkBIOoa7MBB+vEV0AieFN0jCy Uwnd24cPpIc5SGeBOrYcB+3jZcjgFxpwIYrVCNGLZ4LkV2ocLfusUL0JFlpiCeCEYYhg HjllIySeHF41BeBGpUrmpeWVPFZn95tgNaBNo= Received: by 10.236.108.34 with SMTP id p22mr10795856yhg.72.1286775905834; Sun, 10 Oct 2010 22:45:05 -0700 (PDT) Received: from centel.dataix.local (adsl-99-181-144-115.dsl.klmzmi.sbcglobal.net [99.181.144.115]) by mx.google.com with ESMTPS id f43sm4817742yhc.26.2010.10.10.22.45.03 (version=SSLv3 cipher=RC4-MD5); Sun, 10 Oct 2010 22:45:04 -0700 (PDT) Sender: "J. Hellenthal" Message-ID: <4CB2A45E.8070602@DataIX.net> Date: Mon, 11 Oct 2010 01:45:02 -0400 From: jhell Organization: http://www.DataIX.net User-Agent: Mozilla/5.0 (X11; U; FreeBSD i386; en-US; rv:1.9.2.9) Gecko/20100917 Lightning/1.0b1 Thunderbird MIME-Version: 1.0 To: Garrett Cooper References: <4C76CA06.5010001@FreeBSD.org> <4CB135F5.20804@DataIX.net> <4CB2A0E9.50108@DataIX.net> In-Reply-To: X-Enigmail-Version: 1.1.2 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Cc: FreeBSD Current , Doug Barton , freebsd-rc@FreeBSD.org, Sergey Kandaurov Subject: Re: [RFC] ifconfig description support in rc.d X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Oct 2010 05:45:07 -0000 On 10/11/2010 01:34, Garrett Cooper wrote: > On Sun, Oct 10, 2010 at 10:30 PM, jhell wrote: >> On 10/10/2010 13:23, Garrett Cooper wrote: >>> >>> I'm not sure it would get resolved after this commit, but one >>> minor annoyance is that restarting the netif rc.d script purges all >>> gateways set, so I have to do and restart the routing rc.d script (if >>> my connectivity doesn't get whacked). I think there was something else >>> with natd and ipfw that I've run into in the past where I've restarted >>> those scripts and things weren't all puppydogs and rainbows on my >>> CURRENT systems. >>> >>> Thanks, >>> -Garrett >> >> Is that the dynamic routes only or also the static routes ? >> >> Either or if it would be any of the above it would be nice if these were >> kept if it was only a restart of the interface, but offhand nothing >> comes to mind that could prevent this from happening since the routes >> are acting according to when the interface becomes inactive then the >> route becomes meaningless. >> >> Maybe if the action of 'restart' to etc/rc.d/netif could also call >> etc/rc.d/routing with 'restart' if the configuration of the interface >> happens to match one of the recorded routes in rc.conf(5). > > I just tested it on my test machine and it happens with static > routes; dynamic routes automatically get reset by dhclient, et all. It > used to be for both though in earlier versions of FreeBSD, IIRC. > Thanks! > -Garrett That has been something that has bugged me for a while. Ill take a look at some possibilities (with just the scripts in rc.d) that might be a solution to this soon as I get a chance over this next week. It might just be meaningful to merge the correct areas of the routing script into the netif scripts restart and relevant sections. Ill look at this as soon as I get a chance. Unless if someone has another theory about whether those routes should be deleted at all if the ifnet address still exists on the parent interface ?. Regards, -- jhell,v From owner-freebsd-rc@FreeBSD.ORG Mon Oct 11 10:29:44 2010 Return-Path: Delivered-To: freebsd-rc@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 92C3D106564A; Mon, 11 Oct 2010 10:29:44 +0000 (UTC) (envelope-from hrs@FreeBSD.org) Received: from mail.allbsd.org (gatekeeper-int.allbsd.org [IPv6:2001:2f0:104:e002::2]) by mx1.freebsd.org (Postfix) with ESMTP id 4FD2F8FC14; Mon, 11 Oct 2010 10:29:43 +0000 (UTC) Received: from alph.d.allbsd.org (p3165-ipbf2308funabasi.chiba.ocn.ne.jp [114.148.246.165]) (authenticated bits=128) by mail.allbsd.org (8.14.4/8.14.3) with ESMTP id o9BATO0F004040; Mon, 11 Oct 2010 19:29:35 +0900 (JST) (envelope-from hrs@FreeBSD.org) Received: from localhost (localhost [IPv6:::1]) (authenticated bits=0) by alph.d.allbsd.org (8.14.4/8.14.4) with ESMTP id o9BATMUK051667; Mon, 11 Oct 2010 19:29:24 +0900 (JST) (envelope-from hrs@FreeBSD.org) Date: Mon, 11 Oct 2010 19:29:14 +0900 (JST) Message-Id: <20101011.192914.82309657.hrs@allbsd.org> To: pluknet@gmail.com From: Hiroki Sato In-Reply-To: References: <4C76CA06.5010001@FreeBSD.org> X-PGPkey-fingerprint: BDB3 443F A5DD B3D0 A530 FFD7 4F2C D3D8 2793 CF2D X-Mailer: Mew version 6.3 on Emacs 23.1 / Mule 6.0 (HANACHIRUSATO) Mime-Version: 1.0 Content-Type: Multipart/Signed; protocol="application/pgp-signature"; micalg=pgp-sha1; boundary="--Security_Multipart(Mon_Oct_11_19_29_14_2010_564)--" Content-Transfer-Encoding: 7bit X-Virus-Scanned: clamav-milter 0.95.3 at gatekeeper.allbsd.org X-Virus-Status: Clean X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.3 (mail.allbsd.org [133.31.130.32]); Mon, 11 Oct 2010 19:29:38 +0900 (JST) X-Spam-Status: No, score=-96.6 required=13.0 tests=CONTENT_TYPE_PRESENT, FAKEDWORD_BACKQUOTE,FORGED_RCVD_IP,MIMEQENC,QENCPTR2,RCVD_IN_CHINA, RCVD_IN_CHINA_KR, RCVD_IN_PBL, RCVD_IN_TAIWAN, SPF_SOFTFAIL, USER_IN_WHITELIST, X_MAILER_PRESENT autolearn=no version=3.2.5 X-Spam-Checker-Version: SpamAssassin 3.2.5 (2008-06-10) on gatekeeper.allbsd.org Cc: freebsd-current@FreeBSD.org, dougb@FreeBSD.org, freebsd-rc@FreeBSD.org Subject: Re: [RFC] ifconfig description support in rc.d X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Oct 2010 10:29:44 -0000 ----Security_Multipart(Mon_Oct_11_19_29_14_2010_564)-- Content-Type: Text/Plain; charset=iso-8859-1 Content-Transfer-Encoding: quoted-printable Hi, pluknet wrote in : pl> On 27 August 2010 00:09, Doug Barton wrote: pl> > On 08/26/2010 12:53 PM, pluknet wrote: pl> >> pl> >> [cc'ing current@ as rc@ looks too quite] pl> >> pl> >> Hi. pl> >> pl> >> Since ifconfig has grown to label interfaces with pl> >> ifconfig $ifname description "foobar", what about pl> >> to give it more life and store i/face descriptions pl> >> semi-permanently, so they will survive between reboots? pl> >> pl> >> This patch adds a functionality to rc.d to label pl> >> interfaces at boot time. pl> >> pl> >> Comments are welcome. pl> > pl> > This seems like a good addition, thanks. Please also write a patc= h for pl> > rc.conf.5 to describe this new functionality and I'll be happy to= commit it. pl> = pl> Xin Li helped me with updating rc.conf.5 (thanks!). pl> It's included in attached patch. (snip) pl> >> + =A0 =A0 =A0 # ifconfig_IF_descr pl> >> + =A0 =A0 =A0 for _if in `ifconfig -l`; do I think using "ifconfig -l" here is not a good idea. Setting a description for each interface in a function invoked by ifn_start() would be better. This is beacuse the netif script can be run not only at boottime but also via devd or by hand for a specific interface. So, if the ifnet_descr is there, "/etc/rc.d/netif start IF" does not make it run. Since the description is a per-interface property, "/etc/rc.d/netif start IF" should set one, and "/etc/rc.d/netif stop IF" should clear one, IMHO. Also, "ifconfig -l" is not compatible with $network_interfaces, so you need to use list_net_interface() for that purpose instead (if you move ifnet_descr() into ifn_start() it is useless, though). -- Hiroki ----Security_Multipart(Mon_Oct_11_19_29_14_2010_564)-- Content-Type: application/pgp-signature Content-Transfer-Encoding: 7bit -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.9 (FreeBSD) iEYEABECAAYFAkyy5voACgkQTyzT2CeTzy3yDgCgwGGsv/3cH6Ayycz4Yi4hsaYw rmMAnjEngZlkiYgjmOr/t4m48P91GtYv =ilJ8 -----END PGP SIGNATURE----- ----Security_Multipart(Mon_Oct_11_19_29_14_2010_564)---- From owner-freebsd-rc@FreeBSD.ORG Mon Oct 11 11:07:02 2010 Return-Path: Delivered-To: freebsd-rc@FreeBSD.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 171CC1065674 for ; Mon, 11 Oct 2010 11:07:02 +0000 (UTC) (envelope-from owner-bugmaster@FreeBSD.org) Received: from freefall.freebsd.org (freefall.freebsd.org [IPv6:2001:4f8:fff6::28]) by mx1.freebsd.org (Postfix) with ESMTP id EFADC8FC1E for ; Mon, 11 Oct 2010 11:07:01 +0000 (UTC) Received: from freefall.freebsd.org (localhost [127.0.0.1]) by freefall.freebsd.org (8.14.4/8.14.4) with ESMTP id o9BB71H5037653 for ; Mon, 11 Oct 2010 11:07:01 GMT (envelope-from owner-bugmaster@FreeBSD.org) Received: (from gnats@localhost) by freefall.freebsd.org (8.14.4/8.14.4/Submit) id o9BB71NU037651 for freebsd-rc@FreeBSD.org; Mon, 11 Oct 2010 11:07:01 GMT (envelope-from owner-bugmaster@FreeBSD.org) Date: Mon, 11 Oct 2010 11:07:01 GMT Message-Id: <201010111107.o9BB71NU037651@freefall.freebsd.org> X-Authentication-Warning: freefall.freebsd.org: gnats set sender to owner-bugmaster@FreeBSD.org using -f From: FreeBSD bugmaster To: freebsd-rc@FreeBSD.org Cc: Subject: Current problem reports assigned to freebsd-rc@FreeBSD.org X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 11 Oct 2010 11:07:02 -0000 Note: to view an individual PR, use: http://www.freebsd.org/cgi/query-pr.cgi?pr=(number). The following is a listing of current problems submitted by FreeBSD users. These represent problem reports covering all versions including experimental development code and obsolete releases. S Tracker Resp. Description -------------------------------------------------------------------------------- o conf/151063 rc [rc.subr] Verify network link and packet flow before s o conf/150752 rc [rc.subr] [patch] be not needed to eval $_pidcmd on re o conf/150474 rc [patch] rc.d/accounting: Add ability to set location o o conf/149867 rc [PATCH] rc.d script to manage multiple FIBS (kern opti o conf/149831 rc [PATCH] add support to /etc/rc.d/jail for delegating Z o conf/148961 rc [PATCH] netstart and network_ipv6 contains references o conf/148656 rc rc.firewall(8): {oip} and {iip} variables in rc.firewa o conf/147685 rc [rc.d] [patch] new feature for /etc/rc.d/fsck o conf/147444 rc [rc.d] [patch] /etc/rc.d/zfs stop not called on reboot o conf/146053 rc [patch] [request] shutdown of jails breaks inter-jail o conf/145445 rc [rc.d] error in /etc/rc.d/jail (bad logic) o conf/145440 rc [rc.d] [patch] add multiple fib support (setfib) in /e o conf/145399 rc [patch] rc.d scripts are unable to start/stop programs o conf/145344 rc [patch] Fix kitchen sink approach for rc.d scripts ins o conf/145009 rc [patch] rc.subr(8): rc.conf should allow mac label con o conf/144213 rc [rc.d] [patch] Disappearing zvols on reboot o conf/143637 rc [patch] ntpdate(8) support for ntp-servers supplied by o conf/143085 rc [patch] ftp-proxy(8) rc(8) with multiple instances o conf/143084 rc [jail] [patch]: fix rc.d/jail creating stray softlinks o conf/142973 rc [jail] [patch] Strange counter init value in jail rc o conf/142434 rc [patch] Add cpuset(1) support to rc.subr(8) o conf/142304 rc rc.conf(5): mdconfig and mdconfig2 rc.d scripts lack e o conf/141909 rc rc.subr(8): [patch] add rc.conf.d support to /usr/loca o conf/141907 rc [rc.d] Bug if mtu (maybe others?) is set as first argu o conf/141678 rc [patch] A minor enhancement to how /etc/rc.d/jail dete o conf/141275 rc [request] dhclient(8) rc script should print something o conf/140440 rc [patch] allow local command files in rc.{suspend,resum o conf/140261 rc [patch] Improve flexibility of mdconfig2 startup scrip o conf/138208 rc [rc.d] [patch] Making rc.firewall (workstation) IPv6 a o conf/137629 rc [rc.d] background_dhclient rc.conf option causing doub o conf/137470 rc [PATCH] /etc/rc.d/mdconfig2 : prioritize cli parameter o conf/137271 rc [rc.d] Cannot update /etc/host.conf when root filesyst o conf/136875 rc [request] _flags appending o conf/136624 rc [rc.d] sysctl variables for ipnat are not applied on b o conf/135338 rc [rc.d] pf startup order seems broken [regression] o conf/134918 rc [patch] rc.subr fails to detect perl daemons o conf/134660 rc [patch] rc-script for initializing ng_netflow+ng_ipfw o conf/134333 rc PPP configuration problem in the rc.d scripts in combi o conf/134006 rc [patch] Unload console screensaver kernel modules if s o conf/133987 rc [rc.d] defaultroute broken with DHCP in some cases o conf/133890 rc [patch] sshd(8): add multiple profiles to the rc.d scr o conf/132483 rc rc.subr(8) [patch] setfib(1) support for rc.subr o conf/132476 rc [rc.d] [patch] add support setfib(1) in rc.d/routing o conf/128299 rc [patch] /etc/rc.d/geli does not mount partitions using o conf/127917 rc [patch] dumpon rejects on start with physmem>swap even o bin/126562 rc rcorder(8) fails to run unrelated startup scripts when o conf/126392 rc [patch] rc.conf ifconfig_xx keywords cannot be escaped p bin/126324 rc [patch] rc.d/tmp: Prevent mounting /tmp in second tim o conf/124747 rc [patch] savecore can't create dump from encrypted swap o conf/124248 rc [jail] [patch] add support for nice value for rc.d/jai o conf/123734 rc [patch] Chipset VIA CX700 requires extra initializatio o conf/123222 rc [patch] Add rtprio(1)/idprio(1) support to rc.subr(8). o conf/122968 rc [rc.d] /etc/rc.d/addswap: md swapfile multiplication a o conf/122477 rc [patch] /etc/rc.d/mdconfig and mdconfig2 are ignoring o conf/122170 rc [patch] [request] New feature: notify admin via page o o kern/121566 rc [nfs] [request] [patch] ethernet iface should be broug o conf/120431 rc [patch] devfs.rules are not initialized under certain o conf/120406 rc [devd] [patch] Handle newly attached pcm devices (eg. o conf/119874 rc [patch] "/etc/rc.d/pf reload" fails if there are macro o conf/119076 rc [patch] [rc.d] /etc/rc.d/netif tries to remove alias a o bin/118325 rc [patch] [request] new periodic script to test statuses o conf/118255 rc savecore never finding kernel core dumps (rcorder prob o conf/117935 rc [patch] ppp fails to start at boot because of missing o conf/113915 rc [patch] ndis wireless driver fails to associate when i o conf/109980 rc /etc/rc.d/netif restart doesn't destroy cloned_interfa o conf/109562 rc [rc.d] [patch] [request] Make rc.d/devfs usable from c o conf/108589 rc rtsol(8) fails due to default ipfw rules o conf/106009 rc [ppp] [patch] [request] Fix pppoed startup script to p o conf/105689 rc [ppp] [request] syslogd starts too late at boot o conf/105568 rc [patch] [request] Add more flexibility to rc.conf, to o conf/105145 rc [ppp] [patch] [request] add redial function to rc.d/pp o conf/104549 rc [patch] rc.d/nfsd needs special _find_processes functi o conf/102700 rc [geli] [patch] Add encrypted /tmp support to GELI/GBDE o conf/99721 rc [patch] /etc/rc.initdiskless problem copy dotfile in s o conf/99444 rc [patch] Enhancement: rc.subr could easily support star o conf/96343 rc [patch] rc.d order change to start inet6 before pf o conf/93815 rc [patch] Adds in the ability to save ipfw rules to rc.d o conf/92523 rc [patch] allow rc scripts to kill process after a timeo o conf/89870 rc [patch] [request] make netif verbose rc.conf toggle o conf/89061 rc [patch] IPv6 6to4 auto-configuration enhancement o conf/88913 rc [patch] wrapper support for rc.subr o conf/85819 rc [patch] script allowing multiuser mode in spite of fsc o kern/81006 rc ipnat not working with tunnel interfaces on startup o conf/77663 rc Suggestion: add /etc/rc.d/addnetswap after addcritremo o conf/73677 rc [patch] add support for powernow states to power_profi o conf/58939 rc [patch] dumb little hack for /etc/rc.firewall{,6} o conf/56934 rc [patch] rc.firewall rules for natd expect an interface o conf/45226 rc [patch] Fix for rc.network, ppp-user annoyance o conf/44170 rc [patch] Add ability to run multiple pppoed(8) on start 89 problems total. From owner-freebsd-rc@FreeBSD.ORG Tue Oct 12 23:13:04 2010 Return-Path: Delivered-To: freebsd-rc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id E7A4C1065672 for ; Tue, 12 Oct 2010 23:13:04 +0000 (UTC) (envelope-from Devin.Teske@fisglobal.com) Received: from mailoutltc.fnis.com (mailoutltc.fnis.com [199.200.24.190]) by mx1.freebsd.org (Postfix) with ESMTP id AF7248FC12 for ; Tue, 12 Oct 2010 23:13:04 +0000 (UTC) Received: from sbhfislrext02.fnfis.com ([192.168.249.140]) by SCSFISLTC01 (8.14.3/8.14.3) with ESMTP id o9CND4pp012526 for ; Tue, 12 Oct 2010 18:13:04 -0500 Received: from sbhfisltcgw02.FNFIS.COM (Not Verified[10.132.248.122]) by sbhfislrext02.fnfis.com with MailMarshal (v6, 5, 4, 7535) id ; Tue, 12 Oct 2010 18:12:58 -0500 Received: from sbhfisltcgw02.FNFIS.COM ([10.132.248.122]) by sbhfisltcgw02.FNFIS.COM with Microsoft SMTPSVC(6.0.3790.4675); Tue, 12 Oct 2010 18:13:03 -0500 Received: from dt.vicor.com ([10.14.152.1]) by sbhfisltcgw02.FNFIS.COM over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Tue, 12 Oct 2010 18:13:03 -0500 From: Devin Teske To: freebsd-rc@freebsd.org Content-Type: text/plain Date: Tue, 12 Oct 2010 16:13:02 -0700 Message-Id: <1286925182.32724.18.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 (2.0.2-41.el4) Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 12 Oct 2010 23:13:03.0460 (UTC) FILETIME=[055EDA40:01CB6A63] Subject: sysrc(8) -- a sysctl(8)-like utility for managing rc.conf(5) X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Oct 2010 23:13:05 -0000 Hey all, Long-time user, first-time poster (to this list at least). Over on the -hackers@ mailing-list, I posted the first version of a script I've written named sysrc(8), designed to ease management of the rc.conf(5) files. There were a lot of great discussions about this over on -hackers@: http://lists.freebsd.org/pipermail/freebsd-hackers/2010- October/thread.html I'm now happy to post the second version of this script which attempts to address all of the concerns that -hackers@ brought-up. Behold... sysrc(8) v2.0 NOTE: just scroll down a little to the INFORMATION section for an easy- to-read usage statement. #!/bin/sh # -*- tab-width: 4 -*- ;; Emacs # vi: set tabstop=4 :: Vi/ViM # # Revision: 2.0 # Last Modified: October 12th, 2010 ############################################################ COPYRIGHT # # (c)2010. Devin Teske. All Rights Reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # AUTHOR DATE DESCRIPTION # dteske 2010.10.12 Updates per freebsd-hackers thread. # dteske 2010.09.29 Initial version. # ############################################################ INFORMATION # # Command Usage: # # sysrc [OPTIONS] name[=value] ... # # OPTIONS: # -h Print this message to stderr and exit. # -f file Operate on the specified file(s) instead of rc_conf_files. # -a Dump a list of non-default configuration variables. # -A Dump a list of all configuration variables (incl. defaults). # -d Print a description of the given variable. # -e Print query results as `var=value' (useful for producing # output to be fed back in). Ignored if -n is specified. # -v Verbose. Print the pathname of the specific rc.conf(5) # file where the directive was found. # -i Ignore unknown variables. # -n Show only variable values, not their names. # -N Show only variable names, not their values. # # ENVIRONMENT: # RC_DEFAULTS Location of `/etc/defaults/rc.conf' file. # SYSRC_VERBOSE Default verbosity. Set to non-NULL to enable. # ############################################################ CONFIGURATION # # Default verbosity. # : ${SYSRC_VERBOSE:=} # # Default location of the rc.conf(5) defaults configuration file. # : ${RC_DEFAULTS:="/etc/defaults/rc.conf"} ############################################################ GLOBALS # # Global exit status variables # SUCCESS=0 FAILURE=1 # # Program name # progname="${0##*/}" # # Options # DESCRIBE= RC_CONFS= IGNORE_UNKNOWNS= SHOW_ALL= SHOW_EQUALS= SHOW_NAME=1 SHOW_VALUE=1 ############################################################ FUNCTION # fprintf $fd $fmt [ $opts ... ] # # Like printf, except allows you to print to a specific file-descriptor. Useful # for printing to stderr (fd=2) or some other known file-descriptor. # fprintf() { local fd=$1 [ $# -gt 1 ] || return $FAILURE shift 1 printf "$@" >&$fd } # eprintf $fmt [ $opts ... ] # # Print a message to stderr (fd=2). # eprintf() { fprintf 2 "$@" } # die [ $fmt [ $opts ... ]] # # Optionally print a message to stderr before exiting with failure status. # die() { local fmt="$1" [ $# -gt 0 ] && shift 1 [ "$fmt" ] && eprintf "$fmt\n" "$@" exit $FAILURE } # usage # # Prints a short syntax statement and exits. # usage() { local optfmt="\t%-11s%s\n" local envfmt="\t%-17s%s\n" eprintf "Usage: %s [OPTIONS] name[=value] ...\n" "$progname" eprintf "OPTIONS:\n" eprintf "$optfmt" "-h" \ "Print this message to stderr and exit." eprintf "$optfmt" "-f file" \ "Operate on the specified file(s) instead of rc_conf_files." eprintf "$optfmt" "-a" \ "Dump a list of non-default configuration variables." eprintf "$optfmt" "-A" \ "Dump a list of all configuration variables (incl. defaults)." eprintf "$optfmt" "-d" \ "Print a description of the given variable." eprintf "$optfmt" "-e" \ "Print query results as \`var=value' (useful for producing" eprintf "$optfmt" "" \ "output to be fed back in). Ignored if -n is specified." eprintf "$optfmt" "-v" \ "Verbose. Print the pathname of the specific rc.conf(5)" eprintf "$optfmt" "" \ "file where the directive was found." eprintf "$optfmt" "-i" \ "Ignore unknown variables." eprintf "$optfmt" "-n" \ "Show only variable values, not their names." eprintf "$optfmt" "-N" \ "Show only variable names, not their values." eprintf "\n" eprintf "ENVIRONMENT:\n" eprintf "$envfmt" "RC_DEFAULTS" \ "Location of \`/etc/defaults/rc.conf' file." eprintf "$envfmt" "SYSRC_VERBOSE" \ "Default verbosity. Set to non-NULL to enable." die } # clean_env [ --except $varname ... ] # # Unset all environment variables in the current scope. An optional list of # arguments can be passed, indicating which variables to avoid unsetting; the # `--except' is required to enabled the exclusion-list as the remainder of # positional arguments. # # Be careful not to call this in a shell that you still except to perform # $PATH expansion in, because this will blow $PATH away. This is best used # within a sub-shell block "(...)" or "$(...)" or "`...`". # clean_env() { local var arg except= # # Should we process an exclusion-list? # if [ "$1" = "--except" ]; then except=1 shift 1 fi # # Loop over a list of variable names from set(1) built-in. # for var in $( set | awk -F= \ '/^[[:alpha:]_][[:alnum:]_]*=/ {print $1}' \ | grep -v '^except$' ); do # # In POSIX bourne-shell, attempting to unset(1) OPTIND results # in "unset: Illegal number:" and causes abrupt termination. # [ "$var" = OPTIND ] && continue # # Process the exclusion-list? # if [ "$except" ]; then for arg in "$@" ""; do [ "$var" = "$arg" ] && break done [ "$arg" ] && continue fi unset "$var" done } # sysrc_get $varname # # Get a system configuration setting from the collection of system- # configuration files (in order: /etc/defaults/rc.conf /etc/rc.conf # and /etc/rc.conf). # # NOTE: Additional shell parameter-expansion formats are supported. For # example, passing an argument of "hostname%%.*" (properly quoted) will # return the hostname up to (but not including) the first `.' (see sh(1), # "Parameter Expansion" for more information on additional formats). # sysrc_get() { # Sanity check [ -f "$RC_DEFAULTS" -a -r "$RC_DEFAULTS" ] || return $FAILURE # Taint-check variable name case "$1" in [0-9]*) # Don't expand possible positional parameters return $FAILURE;; *) [ "$1" ] || return $FAILURE esac ( # Execute within sub-shell to protect parent environment # # Clear the environment of all variables, preventing the # expansion of normals such as `PS1', `TERM', etc. # clean_env --except RC_CONFS RC_DEFAULTS . "$RC_DEFAULTS" # # If `-f file' was passed, set $rc_conf_files to an explicit # value, modifying the default behavior of source_rc_confs(). # [ "$RC_CONFS" ] && rc_conf_files="$RC_CONFS" unset RC_CONFS # no longer needed source_rc_confs # # This must be the last functional line for both the sub-shell, # and the function to preserve the return status from formats # such as "${varname?}" and "${varname:?}" (see "Parameter # Expansion" in sh(1) for more information). # eval echo '"${'"$1"'}"' 2> /dev/null ) } # sysrc_find $varname # # Find which file holds the effective last-assignment to a given variable # within the rc.conf(5) file(s). # # If the variable is found in any of the rc.conf(5) files, the function prints # the filename it was found in and then returns success. Otherwise output is # NULL and the function returns with error status. # sysrc_find() { local varname="$1" local rc_conf_files="$( sysrc_get rc_conf_files )" local conf_files= local file # Check parameters [ "$varname" ] || return $FAILURE # # If `-f file' was passed, set $rc_conf_files to an explicit # value, modifying the default behavior of source_rc_confs(). # [ "$RC_CONFS" ] && rc_conf_files="$RC_CONFS" # # Reverse the order of files in rc_conf_files (the boot process sources # these in order, so we will search them in reverse-order to find the # last-assignment -- the one that ultimately effects the environment). # for file in $rc_conf_files; do conf_files="$file${conf_files:+ }$conf_files" done # # Append the defaults file (since directives in the defaults file # indeed affect the boot process, we'll want to know when a directive # is found there). # conf_files="$conf_files${conf_files:+ }$RC_DEFAULTS" # # Find which file matches assignment to the given variable name. # for file in $conf_files; do if grep -q "^[[:space:]]*$varname=" $file; then echo $file return $SUCCESS fi done return $FAILURE # Not found } # ... | lrev # lrev $file ... # # Reverse lines of input. Unlike rev(1) which reverses the ordering of # characters on a single line, this function instead reverses the line # sequencing. # # For example, the following input: # # Line 1 # Line 2 # Line 3 # # Becomes reversed in the following manner: # # Line 3 # Line 2 # Line 1 # lrev() { local stdin_rev= if [ $# -gt 0 ]; then # # Reverse lines from files passed as positional arguments. # while [ $# -gt 0 ]; do local file="$1" [ -f "$file" ] && lrev < "$file" shift 1 done else # # Reverse lines from standard input # while read -r LINE; do stdin_rev="$LINE $stdin_rev" done fi echo -n "$stdin_rev" } # sysrc_set $varname $new_value # # Change a setting in the system configuration files (edits the files in-place # to change the value in the last assignment to the variable). If the variable # does not appear in the source file, it is appended to the end of the primary # system configuration file `/etc/rc.conf'. # sysrc_set() { local varname="$1" new_value="$2" # Check arguments [ "$varname" ] || return $FAILURE # # Find which rc.conf(5) file contains the last-assignment # local not_found= local file="$( sysrc_find "$varname" )" if [ "$file" = "$RC_DEFAULTS" -o ! "$file" ]; then # # We either got a null response (not found) or the variable # was only found in the rc.conf(5) defaults. In either case, # let's instead modify the first file from $rc_conf_files. # not_found=1 # # If `-f file' was passed, use $RC_CONFS # rather than $rc_conf_files. # if [ "$RC_CONFS" ]; then file="${RC_CONFS%%[$IFS]*}" else file="$( sysrc_get "rc_conf_files%%[$IFS]*" )" fi fi # # Perform sanity checks. # if [ ! -w $file ]; then eprintf "\n%s: cannot create %s: Permission denied\n" \ "$progname" "$file" return $FAILURE fi # # If not found, append new value to last file and return. # if [ "$not_found" ]; then echo "$varname=\"$new_value\"" >> "$file" return $SUCCESS fi # # Operate on the matching file, replacing only the last occurrence. # local new_contents="`lrev $file 2> /dev/null | \ ( found= while read -r LINE; do if [ ! "$found" ]; then match="$( echo "$LINE" | grep "$regex" )" if [ "$match" ]; then LINE="$varname"'="'"$new_value"'"' found=1 fi fi echo "$LINE" done ) | lrev`" [ "$new_contents" ] || return $FAILURE # # Create a new temporary file to write to. # local tmpfile="$( mktemp -t "$progname" )" [ "$tmpfile" ] || return $FAILURE # # Fixup permissions (else we're in for a surprise, as mktemp(1) creates # the temporary file with 0600 permissions, and if we simply mv(1) the # temporary file over the destination, the destination will inherit the # permissions from the temporary file). # chmod $( stat -f '%#Lp' "$file" ) "$tmpfile" 2> /dev/null # # Fixup ownerhsip. The destination file _is_ writable (we tested # earlier above). However, this will fail if we don't have sufficient # permissions (so we throw stderr into the bit-bucket). # chown $( stat -f '%u:%g' "$file" ) "$tmpfile" 2> /dev/null # # Write the temporary file contents and move it into place. # echo "$new_contents" > "$tmpfile" || return $FAILURE mv "$tmpfile" "$file" } # sysrc_desc $varname # # Attempts to return the comments associated with varname from the rc.conf(5) # defaults file `/etc/defaults/rc.conf' (or whatever RC_DEFAULTS points to). # # Multi-line comments are joined together. Results are NULL if no description # could be found. # sysrc_desc() { local varname="$1" ( buffer= while read LINE; do case "$LINE" in $varname=*) buffer="$LINE" break esac done # Return if the variable wasn't found [ "$buffer" ] || return $FAILURE regex='[[:alpha:]_][[:alnum:]_]*=' while read LINE; do # # Stop reading comments if we reach a new assignment # directive or if the line contains only whitespace # echo "$LINE" | grep -q "^[[:space:]]*$regex" && break echo "$LINE" | grep -q "^[[:space:]]*#$regex" && break echo "$LINE" | grep -q "^[[:space:]]*$" && break # Append new line to buffer buffer="$buffer $LINE" done # Return if the buffer is empty [ "$buffer" ] || return $FAILURE # # Clean up the buffer. # regex='^[^#]*\(#[[:space:]]*\)\{0,1\}' buffer="$( echo "$buffer" | sed -e "s/$regex//" )" buffer="$( echo "$buffer" | tr '\n' ' ' \ | sed -e 's/^[[:space:]]*//;s/[[:space:]]*$//' )" echo "$buffer" ) < "$RC_DEFAULTS" } ############################################################ MAIN SOURCE # # Perform sanity checks # [ $# -gt 0 ] || usage # # Process command-line options # while getopts hf:aAdevinN flag; do case "$flag" in h) usage;; f) RC_CONFS="$OPTARG";; a) SHOW_ALL=1;; A) SHOW_ALL=2;; d) DESCRIBE=1;; e) SHOW_EQUALS=1;; v) SYSRC_VERBOSE=1;; i) IGNORE_UNKNOWNS=1;; n) SHOW_NAME=;; N) SHOW_VALUE=;; \?) usage;; esac done shift $(( $OPTIND - 1 )) # # Process command-line options # SEP=': ' [ "$SHOW_EQUALS" ] && SEP='="' [ "$SHOW_NAME" ] || SHOW_EQUALS= [ "$SYSRC_VERBOSE" = "0" ] && SYSRC_VERBOSE= if [ ! "$SHOW_VALUE" ]; then SHOW_NAME=1 SHOW_EQUALS= fi if [ "$SHOW_ALL" ]; then # # Get a list of variables that are currently set in the rc.conf(5) # files (included `/etc/defaults/rc.conf') by performing a call to # source_rc_confs() in a clean environment. # ( # # Set which variables we want to preserve in the environment. # Append the pipe-character (|) to the list of internal field # separation (IFS) characters, allowing us to use the below # list both as an extended grep (-E) pattern and argument list # (required to first get clean_env() to preserve these in the # environment and then later to prune them from the list of # variables produced by set(1)). # IFS="$IFS|" EXCEPT="IFS|EXCEPT|PATH|RC_DEFAULTS|OPTIND|DESCRIBE|SEP" EXCEPT="$EXCEPT|SHOW_ALL|SHOW_EQUALS|SHOW_NAME|SHOW_VALUE" EXCEPT="$EXCEPT|SYSRC_VERBOSE|RC_CONFS" # # Clean the environment (except for our required variables) # and then source the required files. # clean_env --except $EXCEPT if [ -f "$RC_DEFAULTS" -a -r "$RC_DEFAULTS" ]; then . "$RC_DEFAULTS" # # If passed `-a' (rather than `-A'), re-purge the # environment, removing the rc.conf(5) defaults. # [ "$SHOW_ALL" = "1" ] \ && clean_env --except rc_conf_files $EXCEPT # # If `-f file' was passed, set $rc_conf_files to an # explicit value, modifying the default behavior of # source_rc_confs(). # [ "$RC_CONFS" ] && rc_conf_files="$RC_CONFS" source_rc_confs # # If passed `-a' (rather than `-A'), remove # `rc_conf_files' unless it was defined somewhere # other than rc.conf(5) defaults. # [ "$SHOW_ALL" = "1" -a \ "$( sysrc_find rc_conf_files )" = "$RC_DEFAULTS" \ ] \ && unset rc_conf_files fi for NAME in $( set | awk -F= \ '/^[[:alpha:]_][[:alnum:]_]*=/ {print $1}' \ | grep -Ev "^($EXCEPT)$" ); do # # If enabled, describe rather than expand value # if [ "$DESCRIBE" ]; then echo "$NAME: $( sysrc_desc "$NAME" )" continue fi [ "$SYSRC_VERBOSE" ] && \ echo -n "$( sysrc_find "$NAME" ): " # # If `-N' is passed, simplify the output # if [ ! "$SHOW_VALUE" ]; then echo "$NAME" continue fi echo "${SHOW_NAME:+$NAME$SEP}$( sysrc_get "$NAME" )${SHOW_EQUALS:+\"}" done ) # # Ignore the remainder of positional arguments. # exit $SUCCESS fi # # Process command-line arguments # while [ $# -gt 0 ]; do NAME="${1%%=*}" [ "$DESCRIBE" ] && \ echo "$NAME: $( sysrc_desc "$NAME" )" case "$1" in *=*) # # Like sysctl(8), if both `-d' AND "name=value" is passed, # first describe, then attempt to set # if [ "$SYSRC_VERBOSE" ]; then file="$( sysrc_find "$NAME" )" [ "$file" = "$RC_DEFAULTS" -o ! "$file" ] && \ file="$( sysrc_get "rc_conf_files%%[$IFS]*" )" echo -n "$file: " fi # # If `-N' is passed, simplify the output # if [ ! "$SHOW_VALUE" ]; then echo "$NAME" sysrc_set "$NAME" "${1#*}" else echo -n "${SHOW_NAME:+$NAME$SEP}$( sysrc_get "$NAME" )${SHOW_EQUALS:+\"}" if sysrc_set "$NAME" "${1#*=}"; then echo " -> $( sysrc_get "$NAME" )" fi fi ;; *) if ! IGNORED="$( sysrc_get "$NAME?" )"; then [ "$IGNORE_UNKNOWNS" ] \ || echo "$progname: unknown variable '$NAME'" shift 1 continue fi # # Like sysctl(8), when `-d' is passed, # desribe it rather than expanding it # if [ "$DESCRIBE" ]; then shift 1 continue fi [ "$SYSRC_VERBOSE" ] && \ echo -n "$( sysrc_find "$NAME" ): " # # If `-N' is passed, simplify the output # if [ ! "$SHOW_VALUE" ]; then echo "$NAME" else echo "${SHOW_NAME:+$NAME$SEP}$( sysrc_get "$NAME" )${SHOW_EQUALS:+\"}" fi esac shift 1 done -- Cheers, Devin Teske -> CONTACT INFORMATION <- Business Solutions Consultant II FIS - fisglobal.com 510-735-5650 Mobile 510-621-2038 Office 510-621-2020 Office Fax 909-477-4578 Home/Fax devin.teske@fisglobal.com -> LEGAL DISCLAIMER <- This message contains confidential and proprietary information of the sender, and is intended only for the person(s) to whom it is addressed. Any use, distribution, copying or disclosure by any other person is strictly prohibited. If you have received this message in error, please notify the e-mail sender immediately, and delete the original message without making a copy. -> FUN STUFF <- -----BEGIN GEEK CODE BLOCK----- Version 3.1 GAT/CS d(+) s: a- C++(++++) UB++++$ P++(++++) L++(++++) !E--- W++ N? o? K- w O M+ V- PS+ PE Y+ PGP- t(+) 5? X+(++) R>++ tv(+) b+(++) DI+(++) D(+) G+>++ e>+ h r>++ y+ ------END GEEK CODE BLOCK------ http://www.geekcode.com/ -> END TRANSMISSION <- _____________ The information contained in this message is proprietary and/or confidential. If you are not the intended recipient, please: (i) delete the message and all copies; (ii) do not disclose, distribute or use the message in any manner; and (iii) notify the sender immediately. In addition, please be aware that any message addressed to our domain is subject to archiving and review by persons other than the intended recipient. Thank you. _____________ From owner-freebsd-rc@FreeBSD.ORG Tue Oct 12 23:27:51 2010 Return-Path: Delivered-To: freebsd-rc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 75ADD1065674 for ; Tue, 12 Oct 2010 23:27:51 +0000 (UTC) (envelope-from Devin.Teske@fisglobal.com) Received: from mailoutltc.fnis.com (mailoutltc.fnis.com [199.200.24.190]) by mx1.freebsd.org (Postfix) with ESMTP id 3DC568FC14 for ; Tue, 12 Oct 2010 23:27:50 +0000 (UTC) Received: from sbhfislrext01.fnfis.com ([192.168.249.167]) by SCSFISLTC01 (8.14.3/8.14.3) with ESMTP id o9CMo0V6006156 for ; Tue, 12 Oct 2010 17:50:00 -0500 Received: from SBHFISLTCGW04.FNFIS.COM (Not Verified[10.132.248.123]) by sbhfislrext01.fnfis.com with MailMarshal (v6, 5, 4, 7535) id ; Tue, 12 Oct 2010 17:49:48 -0500 Received: from sbhfisltcgw02.FNFIS.COM ([10.132.248.122]) by SBHFISLTCGW04.FNFIS.COM with Microsoft SMTPSVC(6.0.3790.1830); Tue, 12 Oct 2010 17:49:59 -0500 Received: from dt.vicor.com ([10.14.152.1]) by sbhfisltcgw02.FNFIS.COM over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Tue, 12 Oct 2010 17:49:59 -0500 From: Devin Teske To: freebsd-rc@freebsd.org Content-Type: text/plain Date: Tue, 12 Oct 2010 15:49:58 -0700 Message-Id: <1286923798.32724.15.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 (2.0.2-41.el4) Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 12 Oct 2010 22:49:59.0475 (UTC) FILETIME=[CC738030:01CB6A5F] Cc: Subject: sysrc(8) -- a sysctl(8)-like utility for managing rc.conf(5) X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 12 Oct 2010 23:27:51 -0000 Hey all, Long-time user, first-time poster (to this list at least). Over on the -hackers@ mailing-list, I posted the first version of a script I've written named sysrc(8), designed to ease management of the rc.conf(5) files. There were a lot of great discussions about this over on -hackers@: http://lists.freebsd.org/pipermail/freebsd-hackers/2010- October/thread.html I'm now happy to post the second version of this script which attempts to address all of the concerns that -hackers@ brought-up. Behold... sysrc(8) v2.0 NOTE: just scroll down a little to the INFORMATION section for an easy- to-read usage statement. #!/bin/sh # -*- tab-width: 4 -*- ;; Emacs # vi: set tabstop=4 :: Vi/ViM # # Revision: 2.0 # Last Modified: October 12th, 2010 ############################################################ COPYRIGHT # # (c)2010. Devin Teske. All Rights Reserved. # # Redistribution and use in source and binary forms, with or without # modification, are permitted provided that the following conditions # are met: # 1. Redistributions of source code must retain the above copyright # notice, this list of conditions and the following disclaimer. # 2. Redistributions in binary form must reproduce the above copyright # notice, this list of conditions and the following disclaimer in the # documentation and/or other materials provided with the distribution. # # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # # AUTHOR DATE DESCRIPTION # dteske 2010.10.12 Updates per freebsd-hackers thread. # dteske 2010.09.29 Initial version. # ############################################################ INFORMATION # # Command Usage: # # sysrc [OPTIONS] name[=value] ... # # OPTIONS: # -h Print this message to stderr and exit. # -f file Operate on the specified file(s) instead of rc_conf_files. # -a Dump a list of non-default configuration variables. # -A Dump a list of all configuration variables (incl. defaults). # -d Print a description of the given variable. # -e Print query results as `var=value' (useful for producing # output to be fed back in). Ignored if -n is specified. # -v Verbose. Print the pathname of the specific rc.conf(5) # file where the directive was found. # -i Ignore unknown variables. # -n Show only variable values, not their names. # -N Show only variable names, not their values. # # ENVIRONMENT: # RC_DEFAULTS Location of `/etc/defaults/rc.conf' file. # SYSRC_VERBOSE Default verbosity. Set to non-NULL to enable. # ############################################################ CONFIGURATION # # Default verbosity. # : ${SYSRC_VERBOSE:=} # # Default location of the rc.conf(5) defaults configuration file. # : ${RC_DEFAULTS:="/etc/defaults/rc.conf"} ############################################################ GLOBALS # # Global exit status variables # SUCCESS=0 FAILURE=1 # # Program name # progname="${0##*/}" # # Options # DESCRIBE= RC_CONFS= IGNORE_UNKNOWNS= SHOW_ALL= SHOW_EQUALS= SHOW_NAME=1 SHOW_VALUE=1 ############################################################ FUNCTION # fprintf $fd $fmt [ $opts ... ] # # Like printf, except allows you to print to a specific file-descriptor. Useful # for printing to stderr (fd=2) or some other known file-descriptor. # fprintf() { local fd=$1 [ $# -gt 1 ] || return $FAILURE shift 1 printf "$@" >&$fd } # eprintf $fmt [ $opts ... ] # # Print a message to stderr (fd=2). # eprintf() { fprintf 2 "$@" } # die [ $fmt [ $opts ... ]] # # Optionally print a message to stderr before exiting with failure status. # die() { local fmt="$1" [ $# -gt 0 ] && shift 1 [ "$fmt" ] && eprintf "$fmt\n" "$@" exit $FAILURE } # usage # # Prints a short syntax statement and exits. # usage() { local optfmt="\t%-11s%s\n" local envfmt="\t%-17s%s\n" eprintf "Usage: %s [OPTIONS] name[=value] ...\n" "$progname" eprintf "OPTIONS:\n" eprintf "$optfmt" "-h" \ "Print this message to stderr and exit." eprintf "$optfmt" "-f file" \ "Operate on the specified file(s) instead of rc_conf_files." eprintf "$optfmt" "-a" \ "Dump a list of non-default configuration variables." eprintf "$optfmt" "-A" \ "Dump a list of all configuration variables (incl. defaults)." eprintf "$optfmt" "-d" \ "Print a description of the given variable." eprintf "$optfmt" "-e" \ "Print query results as \`var=value' (useful for producing" eprintf "$optfmt" "" \ "output to be fed back in). Ignored if -n is specified." eprintf "$optfmt" "-v" \ "Verbose. Print the pathname of the specific rc.conf(5)" eprintf "$optfmt" "" \ "file where the directive was found." eprintf "$optfmt" "-i" \ "Ignore unknown variables." eprintf "$optfmt" "-n" \ "Show only variable values, not their names." eprintf "$optfmt" "-N" \ "Show only variable names, not their values." eprintf "\n" eprintf "ENVIRONMENT:\n" eprintf "$envfmt" "RC_DEFAULTS" \ "Location of \`/etc/defaults/rc.conf' file." eprintf "$envfmt" "SYSRC_VERBOSE" \ "Default verbosity. Set to non-NULL to enable." die } # clean_env [ --except $varname ... ] # # Unset all environment variables in the current scope. An optional list of # arguments can be passed, indicating which variables to avoid unsetting; the # `--except' is required to enabled the exclusion-list as the remainder of # positional arguments. # # Be careful not to call this in a shell that you still except to perform # $PATH expansion in, because this will blow $PATH away. This is best used # within a sub-shell block "(...)" or "$(...)" or "`...`". # clean_env() { local var arg except= # # Should we process an exclusion-list? # if [ "$1" = "--except" ]; then except=1 shift 1 fi # # Loop over a list of variable names from set(1) built-in. # for var in $( set | awk -F= \ '/^[[:alpha:]_][[:alnum:]_]*=/ {print $1}' \ | grep -v '^except$' ); do # # In POSIX bourne-shell, attempting to unset(1) OPTIND results # in "unset: Illegal number:" and causes abrupt termination. # [ "$var" = OPTIND ] && continue # # Process the exclusion-list? # if [ "$except" ]; then for arg in "$@" ""; do [ "$var" = "$arg" ] && break done [ "$arg" ] && continue fi unset "$var" done } # sysrc_get $varname # # Get a system configuration setting from the collection of system- # configuration files (in order: /etc/defaults/rc.conf /etc/rc.conf # and /etc/rc.conf). # # NOTE: Additional shell parameter-expansion formats are supported. For # example, passing an argument of "hostname%%.*" (properly quoted) will # return the hostname up to (but not including) the first `.' (see sh(1), # "Parameter Expansion" for more information on additional formats). # sysrc_get() { # Sanity check [ -f "$RC_DEFAULTS" -a -r "$RC_DEFAULTS" ] || return $FAILURE # Taint-check variable name case "$1" in [0-9]*) # Don't expand possible positional parameters return $FAILURE;; *) [ "$1" ] || return $FAILURE esac ( # Execute within sub-shell to protect parent environment # # Clear the environment of all variables, preventing the # expansion of normals such as `PS1', `TERM', etc. # clean_env --except RC_CONFS RC_DEFAULTS . "$RC_DEFAULTS" # # If `-f file' was passed, set $rc_conf_files to an explicit # value, modifying the default behavior of source_rc_confs(). # [ "$RC_CONFS" ] && rc_conf_files="$RC_CONFS" unset RC_CONFS # no longer needed source_rc_confs # # This must be the last functional line for both the sub-shell, # and the function to preserve the return status from formats # such as "${varname?}" and "${varname:?}" (see "Parameter # Expansion" in sh(1) for more information). # eval echo '"${'"$1"'}"' 2> /dev/null ) } # sysrc_find $varname # # Find which file holds the effective last-assignment to a given variable # within the rc.conf(5) file(s). # # If the variable is found in any of the rc.conf(5) files, the function prints # the filename it was found in and then returns success. Otherwise output is # NULL and the function returns with error status. # sysrc_find() { local varname="$1" local rc_conf_files="$( sysrc_get rc_conf_files )" local conf_files= local file # Check parameters [ "$varname" ] || return $FAILURE # # If `-f file' was passed, set $rc_conf_files to an explicit # value, modifying the default behavior of source_rc_confs(). # [ "$RC_CONFS" ] && rc_conf_files="$RC_CONFS" # # Reverse the order of files in rc_conf_files (the boot process sources # these in order, so we will search them in reverse-order to find the # last-assignment -- the one that ultimately effects the environment). # for file in $rc_conf_files; do conf_files="$file${conf_files:+ }$conf_files" done # # Append the defaults file (since directives in the defaults file # indeed affect the boot process, we'll want to know when a directive # is found there). # conf_files="$conf_files${conf_files:+ }$RC_DEFAULTS" # # Find which file matches assignment to the given variable name. # for file in $conf_files; do if grep -q "^[[:space:]]*$varname=" $file; then echo $file return $SUCCESS fi done return $FAILURE # Not found } # ... | lrev # lrev $file ... # # Reverse lines of input. Unlike rev(1) which reverses the ordering of # characters on a single line, this function instead reverses the line # sequencing. # # For example, the following input: # # Line 1 # Line 2 # Line 3 # # Becomes reversed in the following manner: # # Line 3 # Line 2 # Line 1 # lrev() { local stdin_rev= if [ $# -gt 0 ]; then # # Reverse lines from files passed as positional arguments. # while [ $# -gt 0 ]; do local file="$1" [ -f "$file" ] && lrev < "$file" shift 1 done else # # Reverse lines from standard input # while read -r LINE; do stdin_rev="$LINE $stdin_rev" done fi echo -n "$stdin_rev" } # sysrc_set $varname $new_value # # Change a setting in the system configuration files (edits the files in-place # to change the value in the last assignment to the variable). If the variable # does not appear in the source file, it is appended to the end of the primary # system configuration file `/etc/rc.conf'. # sysrc_set() { local varname="$1" new_value="$2" # Check arguments [ "$varname" ] || return $FAILURE # # Find which rc.conf(5) file contains the last-assignment # local not_found= local file="$( sysrc_find "$varname" )" if [ "$file" = "$RC_DEFAULTS" -o ! "$file" ]; then # # We either got a null response (not found) or the variable # was only found in the rc.conf(5) defaults. In either case, # let's instead modify the first file from $rc_conf_files. # not_found=1 # # If `-f file' was passed, use $RC_CONFS # rather than $rc_conf_files. # if [ "$RC_CONFS" ]; then file="${RC_CONFS%%[$IFS]*}" else file="$( sysrc_get "rc_conf_files%%[$IFS]*" )" fi fi # # Perform sanity checks. # if [ ! -w $file ]; then eprintf "\n%s: cannot create %s: Permission denied\n" \ "$progname" "$file" return $FAILURE fi # # If not found, append new value to last file and return. # if [ "$not_found" ]; then echo "$varname=\"$new_value\"" >> "$file" return $SUCCESS fi # # Operate on the matching file, replacing only the last occurrence. # local new_contents="`lrev $file 2> /dev/null | \ ( found= while read -r LINE; do if [ ! "$found" ]; then match="$( echo "$LINE" | grep "$regex" )" if [ "$match" ]; then LINE="$varname"'="'"$new_value"'"' found=1 fi fi echo "$LINE" done ) | lrev`" [ "$new_contents" ] || return $FAILURE # # Create a new temporary file to write to. # local tmpfile="$( mktemp -t "$progname" )" [ "$tmpfile" ] || return $FAILURE # # Fixup permissions (else we're in for a surprise, as mktemp(1) creates # the temporary file with 0600 permissions, and if we simply mv(1) the # temporary file over the destination, the destination will inherit the # permissions from the temporary file). # chmod $( stat -f '%#Lp' "$file" ) "$tmpfile" 2> /dev/null # # Fixup ownerhsip. The destination file _is_ writable (we tested # earlier above). However, this will fail if we don't have sufficient # permissions (so we throw stderr into the bit-bucket). # chown $( stat -f '%u:%g' "$file" ) "$tmpfile" 2> /dev/null # # Write the temporary file contents and move it into place. # echo "$new_contents" > "$tmpfile" || return $FAILURE mv "$tmpfile" "$file" } # sysrc_desc $varname # # Attempts to return the comments associated with varname from the rc.conf(5) # defaults file `/etc/defaults/rc.conf' (or whatever RC_DEFAULTS points to). # # Multi-line comments are joined together. Results are NULL if no description # could be found. # sysrc_desc() { local varname="$1" ( buffer= while read LINE; do case "$LINE" in $varname=*) buffer="$LINE" break esac done # Return if the variable wasn't found [ "$buffer" ] || return $FAILURE regex='[[:alpha:]_][[:alnum:]_]*=' while read LINE; do # # Stop reading comments if we reach a new assignment # directive or if the line contains only whitespace # echo "$LINE" | grep -q "^[[:space:]]*$regex" && break echo "$LINE" | grep -q "^[[:space:]]*#$regex" && break echo "$LINE" | grep -q "^[[:space:]]*$" && break # Append new line to buffer buffer="$buffer $LINE" done # Return if the buffer is empty [ "$buffer" ] || return $FAILURE # # Clean up the buffer. # regex='^[^#]*\(#[[:space:]]*\)\{0,1\}' buffer="$( echo "$buffer" | sed -e "s/$regex//" )" buffer="$( echo "$buffer" | tr '\n' ' ' \ | sed -e 's/^[[:space:]]*//;s/[[:space:]]*$//' )" echo "$buffer" ) < "$RC_DEFAULTS" } ############################################################ MAIN SOURCE # # Perform sanity checks # [ $# -gt 0 ] || usage # # Process command-line options # while getopts hf:aAdevinN flag; do case "$flag" in h) usage;; f) RC_CONFS="$OPTARG";; a) SHOW_ALL=1;; A) SHOW_ALL=2;; d) DESCRIBE=1;; e) SHOW_EQUALS=1;; v) SYSRC_VERBOSE=1;; i) IGNORE_UNKNOWNS=1;; n) SHOW_NAME=;; N) SHOW_VALUE=;; \?) usage;; esac done shift $(( $OPTIND - 1 )) # # Process command-line options # SEP=': ' [ "$SHOW_EQUALS" ] && SEP='="' [ "$SHOW_NAME" ] || SHOW_EQUALS= [ "$SYSRC_VERBOSE" = "0" ] && SYSRC_VERBOSE= if [ ! "$SHOW_VALUE" ]; then SHOW_NAME=1 SHOW_EQUALS= fi if [ "$SHOW_ALL" ]; then # # Get a list of variables that are currently set in the rc.conf(5) # files (included `/etc/defaults/rc.conf') by performing a call to # source_rc_confs() in a clean environment. # ( # # Set which variables we want to preserve in the environment. # Append the pipe-character (|) to the list of internal field # separation (IFS) characters, allowing us to use the below # list both as an extended grep (-E) pattern and argument list # (required to first get clean_env() to preserve these in the # environment and then later to prune them from the list of # variables produced by set(1)). # IFS="$IFS|" EXCEPT="IFS|EXCEPT|PATH|RC_DEFAULTS|OPTIND|DESCRIBE|SEP" EXCEPT="$EXCEPT|SHOW_ALL|SHOW_EQUALS|SHOW_NAME|SHOW_VALUE" EXCEPT="$EXCEPT|SYSRC_VERBOSE|RC_CONFS" # # Clean the environment (except for our required variables) # and then source the required files. # clean_env --except $EXCEPT if [ -f "$RC_DEFAULTS" -a -r "$RC_DEFAULTS" ]; then . "$RC_DEFAULTS" # # If passed `-a' (rather than `-A'), re-purge the # environment, removing the rc.conf(5) defaults. # [ "$SHOW_ALL" = "1" ] \ && clean_env --except rc_conf_files $EXCEPT # # If `-f file' was passed, set $rc_conf_files to an # explicit value, modifying the default behavior of # source_rc_confs(). # [ "$RC_CONFS" ] && rc_conf_files="$RC_CONFS" source_rc_confs # # If passed `-a' (rather than `-A'), remove # `rc_conf_files' unless it was defined somewhere # other than rc.conf(5) defaults. # [ "$SHOW_ALL" = "1" -a \ "$( sysrc_find rc_conf_files )" = "$RC_DEFAULTS" \ ] \ && unset rc_conf_files fi for NAME in $( set | awk -F= \ '/^[[:alpha:]_][[:alnum:]_]*=/ {print $1}' \ | grep -Ev "^($EXCEPT)$" ); do # # If enabled, describe rather than expand value # if [ "$DESCRIBE" ]; then echo "$NAME: $( sysrc_desc "$NAME" )" continue fi [ "$SYSRC_VERBOSE" ] && \ echo -n "$( sysrc_find "$NAME" ): " # # If `-N' is passed, simplify the output # if [ ! "$SHOW_VALUE" ]; then echo "$NAME" continue fi echo "${SHOW_NAME:+$NAME$SEP}$( sysrc_get "$NAME" )${SHOW_EQUALS:+\"}" done ) # # Ignore the remainder of positional arguments. # exit $SUCCESS fi # # Process command-line arguments # while [ $# -gt 0 ]; do NAME="${1%%=*}" [ "$DESCRIBE" ] && \ echo "$NAME: $( sysrc_desc "$NAME" )" case "$1" in *=*) # # Like sysctl(8), if both `-d' AND "name=value" is passed, # first describe, then attempt to set # if [ "$SYSRC_VERBOSE" ]; then file="$( sysrc_find "$NAME" )" [ "$file" = "$RC_DEFAULTS" -o ! "$file" ] && \ file="$( sysrc_get "rc_conf_files%%[$IFS]*" )" echo -n "$file: " fi # # If `-N' is passed, simplify the output # if [ ! "$SHOW_VALUE" ]; then echo "$NAME" sysrc_set "$NAME" "${1#*}" else echo -n "${SHOW_NAME:+$NAME$SEP}$( sysrc_get "$NAME" )${SHOW_EQUALS:+\"}" if sysrc_set "$NAME" "${1#*=}"; then echo " -> $( sysrc_get "$NAME" )" fi fi ;; *) if ! IGNORED="$( sysrc_get "$NAME?" )"; then [ "$IGNORE_UNKNOWNS" ] \ || echo "$progname: unknown variable '$NAME'" shift 1 continue fi # # Like sysctl(8), when `-d' is passed, # desribe it rather than expanding it # if [ "$DESCRIBE" ]; then shift 1 continue fi [ "$SYSRC_VERBOSE" ] && \ echo -n "$( sysrc_find "$NAME" ): " # # If `-N' is passed, simplify the output # if [ ! "$SHOW_VALUE" ]; then echo "$NAME" else echo "${SHOW_NAME:+$NAME$SEP}$( sysrc_get "$NAME" )${SHOW_EQUALS:+\"}" fi esac shift 1 done -- Cheers, Devin Teske -> CONTACT INFORMATION <- Business Solutions Consultant II FIS - fisglobal.com 510-735-5650 Mobile 510-621-2038 Office 510-621-2020 Office Fax 909-477-4578 Home/Fax devin.teske@fisglobal.com -> LEGAL DISCLAIMER <- This message contains confidential and proprietary information of the sender, and is intended only for the person(s) to whom it is addressed. Any use, distribution, copying or disclosure by any other person is strictly prohibited. If you have received this message in error, please notify the e-mail sender immediately, and delete the original message without making a copy. -> FUN STUFF <- -----BEGIN GEEK CODE BLOCK----- Version 3.1 GAT/CS d(+) s: a- C++(++++) UB++++$ P++(++++) L++(++++) !E--- W++ N? o? K- w O M+ V- PS+ PE Y+ PGP- t(+) 5? X+(++) R>++ tv(+) b+(++) DI+(++) D(+) G+>++ e>+ h r>++ y+ ------END GEEK CODE BLOCK------ http://www.geekcode.com/ -> END TRANSMISSION <- _____________ The information contained in this message is proprietary and/or confidential. If you are not the intended recipient, please: (i) delete the message and all copies; (ii) do not disclose, distribute or use the message in any manner; and (iii) notify the sender immediately. In addition, please be aware that any message addressed to our domain is subject to archiving and review by persons other than the intended recipient. Thank you. _____________ From owner-freebsd-rc@FreeBSD.ORG Wed Oct 13 00:01:17 2010 Return-Path: Delivered-To: freebsd-rc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 6DBC71065679 for ; Wed, 13 Oct 2010 00:01:17 +0000 (UTC) (envelope-from Devin.Teske@fisglobal.com) Received: from mailoutltc.fnis.com (mailoutltc.fnis.com [199.200.24.190]) by mx1.freebsd.org (Postfix) with ESMTP id 290E48FC1C for ; Wed, 13 Oct 2010 00:01:16 +0000 (UTC) Received: from SBHFISLREXT03 ([10.132.254.62]) by SCSFISLTC02 (8.14.3/8.14.3) with ESMTP id o9D01Gv3025482 for ; Tue, 12 Oct 2010 19:01:16 -0500 Received: from SBHFISLTCGW07.FNFIS.COM (Not Verified[10.132.248.135]) by SBHFISLREXT03 with MailMarshal (v6, 5, 4, 7535) id ; Tue, 12 Oct 2010 19:01:23 -0500 Received: from SBHFISLTCGW07.FNFIS.COM ([10.132.248.135]) by SBHFISLTCGW07.FNFIS.COM with Microsoft SMTPSVC(6.0.3790.4675); Tue, 12 Oct 2010 19:01:16 -0500 Received: from dt.vicor.com ([10.14.152.1]) by SBHFISLTCGW07.FNFIS.COM over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Tue, 12 Oct 2010 19:01:15 -0500 From: Devin Teske To: freebsd-rc@freebsd.org In-Reply-To: <1286925182.32724.18.camel@localhost.localdomain> References: <1286925182.32724.18.camel@localhost.localdomain> Content-Type: text/plain Date: Tue, 12 Oct 2010 17:01:14 -0700 Message-Id: <1286928074.32724.29.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 (2.0.2-41.el4) Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 13 Oct 2010 00:01:15.0972 (UTC) FILETIME=[C1712840:01CB6A69] Subject: Re: sysrc(8) -- a sysctl(8)-like utility for managing rc.conf(5) X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Oct 2010 00:01:17 -0000 On Tue, 2010-10-12 at 16:13 -0700, Devin Teske wrote: > [...] > Behold... sysrc(8) v2.0 > > NOTE: just scroll down a little to the INFORMATION section for an easy- > to-read usage statement. > > #!/bin/sh > # -*- tab-width: 4 -*- ;; Emacs > # vi: set tabstop=4 :: Vi/ViM > # > # Revision: 2.0 > # Last Modified: October 12th, 2010 > ############################################################ COPYRIGHT > # > # (c)2010. Devin Teske. All Rights Reserved. > # > # Redistribution and use in source and binary forms, with or without > # modification, are permitted provided that the following conditions > # are met: > # 1. Redistributions of source code must retain the above copyright > # notice, this list of conditions and the following disclaimer. > # 2. Redistributions in binary form must reproduce the above copyright > # notice, this list of conditions and the following disclaimer in the > # documentation and/or other materials provided with the distribution. > # > # THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND > # ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING BUT NOT LIMITED TO, THE > # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE > # ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE > # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL > # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS > # OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) > # HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT > # LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY > # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF > # SUCH DAMAGE. > # > # AUTHOR DATE DESCRIPTION > # dteske 2010.10.12 Updates per freebsd-hackers thread. > # dteske 2010.09.29 Initial version. > # > ############################################################ INFORMATION > # > # Command Usage: > # > # sysrc [OPTIONS] name[=value] ... > # > # OPTIONS: > # -h Print this message to stderr and exit. > # -f file Operate on the specified file(s) instead of rc_conf_files. > # -a Dump a list of non-default configuration variables. > # -A Dump a list of all configuration variables (incl. defaults). > # -d Print a description of the given variable. > # -e Print query results as `var=value' (useful for producing > # output to be fed back in). Ignored if -n is specified. > # -v Verbose. Print the pathname of the specific rc.conf(5) > # file where the directive was found. > # -i Ignore unknown variables. > # -n Show only variable values, not their names. > # -N Show only variable names, not their values. > # > # ENVIRONMENT: > # RC_DEFAULTS Location of `/etc/defaults/rc.conf' file. > # SYSRC_VERBOSE Default verbosity. Set to non-NULL to enable. > # > ############################################################ CONFIGURATION > > # > # Default verbosity. > # > : ${SYSRC_VERBOSE:=} > > # > # Default location of the rc.conf(5) defaults configuration file. > # > : ${RC_DEFAULTS:="/etc/defaults/rc.conf"} > > ############################################################ GLOBALS > > # > # Global exit status variables > # > SUCCESS=0 > FAILURE=1 > > # > # Program name > # > progname="${0##*/}" > > # > # Options > # > DESCRIBE= > RC_CONFS= > IGNORE_UNKNOWNS= > SHOW_ALL= > SHOW_EQUALS= > SHOW_NAME=1 > SHOW_VALUE=1 > > ############################################################ FUNCTION > > # fprintf $fd $fmt [ $opts ... ] > # > # Like printf, except allows you to print to a specific file-descriptor. Useful > # for printing to stderr (fd=2) or some other known file-descriptor. > # > fprintf() > { > local fd=$1 > [ $# -gt 1 ] || return $FAILURE > shift 1 > printf "$@" >&$fd > } > > # eprintf $fmt [ $opts ... ] > # > # Print a message to stderr (fd=2). > # > eprintf() > { > fprintf 2 "$@" > } > > # die [ $fmt [ $opts ... ]] > # > # Optionally print a message to stderr before exiting with failure status. > # > die() > { > local fmt="$1" > [ $# -gt 0 ] && shift 1 > [ "$fmt" ] && eprintf "$fmt\n" "$@" > > exit $FAILURE > } > > # usage > # > # Prints a short syntax statement and exits. > # > usage() > { > local optfmt="\t%-11s%s\n" > local envfmt="\t%-17s%s\n" > > eprintf "Usage: %s [OPTIONS] name[=value] ...\n" "$progname" > > eprintf "OPTIONS:\n" > eprintf "$optfmt" "-h" \ > "Print this message to stderr and exit." > eprintf "$optfmt" "-f file" \ > "Operate on the specified file(s) instead of rc_conf_files." > eprintf "$optfmt" "-a" \ > "Dump a list of non-default configuration variables." > eprintf "$optfmt" "-A" \ > "Dump a list of all configuration variables (incl. defaults)." > eprintf "$optfmt" "-d" \ > "Print a description of the given variable." > eprintf "$optfmt" "-e" \ > "Print query results as \`var=value' (useful for producing" > eprintf "$optfmt" "" \ > "output to be fed back in). Ignored if -n is specified." > eprintf "$optfmt" "-v" \ > "Verbose. Print the pathname of the specific rc.conf(5)" > eprintf "$optfmt" "" \ > "file where the directive was found." > eprintf "$optfmt" "-i" \ > "Ignore unknown variables." > eprintf "$optfmt" "-n" \ > "Show only variable values, not their names." > eprintf "$optfmt" "-N" \ > "Show only variable names, not their values." > eprintf "\n" > > eprintf "ENVIRONMENT:\n" > eprintf "$envfmt" "RC_DEFAULTS" \ > "Location of \`/etc/defaults/rc.conf' file." > eprintf "$envfmt" "SYSRC_VERBOSE" \ > "Default verbosity. Set to non-NULL to enable." > > die > } > > # clean_env [ --except $varname ... ] > # > # Unset all environment variables in the current scope. An optional list of > # arguments can be passed, indicating which variables to avoid unsetting; the > # `--except' is required to enabled the exclusion-list as the remainder of > # positional arguments. > # > # Be careful not to call this in a shell that you still except to perform > # $PATH expansion in, because this will blow $PATH away. This is best used > # within a sub-shell block "(...)" or "$(...)" or "`...`". > # > clean_env() > { > local var arg except= > > # > # Should we process an exclusion-list? > # > if [ "$1" = "--except" ]; then > except=1 > shift 1 > fi > > # > # Loop over a list of variable names from set(1) built-in. > # > for var in $( set | awk -F= \ > '/^[[:alpha:]_][[:alnum:]_]*=/ {print $1}' \ > | grep -v '^except$' > ); do > # > # In POSIX bourne-shell, attempting to unset(1) OPTIND results > # in "unset: Illegal number:" and causes abrupt termination. > # > [ "$var" = OPTIND ] && continue > > # > # Process the exclusion-list? > # > if [ "$except" ]; then > for arg in "$@" ""; do > [ "$var" = "$arg" ] && break > done > [ "$arg" ] && continue > fi > > unset "$var" > done > } > > # sysrc_get $varname > # > # Get a system configuration setting from the collection of system- > # configuration files (in order: /etc/defaults/rc.conf /etc/rc.conf > # and /etc/rc.conf). > # > # NOTE: Additional shell parameter-expansion formats are supported. For > # example, passing an argument of "hostname%%.*" (properly quoted) will > # return the hostname up to (but not including) the first `.' (see sh(1), > # "Parameter Expansion" for more information on additional formats). > # > sysrc_get() > { > # Sanity check > [ -f "$RC_DEFAULTS" -a -r "$RC_DEFAULTS" ] || return $FAILURE > > # Taint-check variable name > case "$1" in > [0-9]*) > # Don't expand possible positional parameters > return $FAILURE;; > *) > [ "$1" ] || return $FAILURE > esac > > ( # Execute within sub-shell to protect parent environment > > # > # Clear the environment of all variables, preventing the > # expansion of normals such as `PS1', `TERM', etc. > # > clean_env --except RC_CONFS RC_DEFAULTS > > . "$RC_DEFAULTS" > > # > # If `-f file' was passed, set $rc_conf_files to an explicit > # value, modifying the default behavior of source_rc_confs(). > # > [ "$RC_CONFS" ] && rc_conf_files="$RC_CONFS" > > unset RC_CONFS > # no longer needed > > source_rc_confs > > # > # This must be the last functional line for both the sub-shell, > # and the function to preserve the return status from formats > # such as "${varname?}" and "${varname:?}" (see "Parameter > # Expansion" in sh(1) for more information). > # > eval echo '"${'"$1"'}"' 2> /dev/null > ) > } > > # sysrc_find $varname > # > # Find which file holds the effective last-assignment to a given variable > # within the rc.conf(5) file(s). > # > # If the variable is found in any of the rc.conf(5) files, the function prints > # the filename it was found in and then returns success. Otherwise output is > # NULL and the function returns with error status. > # > sysrc_find() > { > local varname="$1" > local rc_conf_files="$( sysrc_get rc_conf_files )" > local conf_files= > local file > > # Check parameters > [ "$varname" ] || return $FAILURE > > # > # If `-f file' was passed, set $rc_conf_files to an explicit > # value, modifying the default behavior of source_rc_confs(). > # > [ "$RC_CONFS" ] && rc_conf_files="$RC_CONFS" > > # > # Reverse the order of files in rc_conf_files (the boot process sources > # these in order, so we will search them in reverse-order to find the > # last-assignment -- the one that ultimately effects the environment). > # > for file in $rc_conf_files; do > conf_files="$file${conf_files:+ }$conf_files" > done > > # > # Append the defaults file (since directives in the defaults file > # indeed affect the boot process, we'll want to know when a directive > # is found there). > # > conf_files="$conf_files${conf_files:+ }$RC_DEFAULTS" > > # > # Find which file matches assignment to the given variable name. > # > for file in $conf_files; do > if grep -q "^[[:space:]]*$varname=" $file; then > echo $file > return $SUCCESS > fi > done > > return $FAILURE # Not found > } > > # ... | lrev > # lrev $file ... > # > # Reverse lines of input. Unlike rev(1) which reverses the ordering of > # characters on a single line, this function instead reverses the line > # sequencing. > # > # For example, the following input: > # > # Line 1 > # Line 2 > # Line 3 > # > # Becomes reversed in the following manner: > # > # Line 3 > # Line 2 > # Line 1 > # > lrev() > { > local stdin_rev= > if [ $# -gt 0 ]; then > # > # Reverse lines from files passed as positional arguments. > # > while [ $# -gt 0 ]; do > local file="$1" > [ -f "$file" ] && lrev < "$file" > shift 1 > done > else > # > # Reverse lines from standard input > # > while read -r LINE; do > stdin_rev="$LINE > $stdin_rev" > done > fi > > echo -n "$stdin_rev" > } > > # sysrc_set $varname $new_value > # > # Change a setting in the system configuration files (edits the files in-place > # to change the value in the last assignment to the variable). If the variable > # does not appear in the source file, it is appended to the end of the primary > # system configuration file `/etc/rc.conf'. > # > sysrc_set() > { > local varname="$1" new_value="$2" > > # Check arguments > [ "$varname" ] || return $FAILURE > > # > # Find which rc.conf(5) file contains the last-assignment > # > local not_found= > local file="$( sysrc_find "$varname" )" > if [ "$file" = "$RC_DEFAULTS" -o ! "$file" ]; then > # > # We either got a null response (not found) or the variable > # was only found in the rc.conf(5) defaults. In either case, > # let's instead modify the first file from $rc_conf_files. > # > > not_found=1 > > # > # If `-f file' was passed, use $RC_CONFS > # rather than $rc_conf_files. > # > if [ "$RC_CONFS" ]; then > file="${RC_CONFS%%[$IFS]*}" > else > file="$( sysrc_get "rc_conf_files%%[$IFS]*" )" > fi > fi > > # > # Perform sanity checks. > # > if [ ! -w $file ]; then > eprintf "\n%s: cannot create %s: Permission denied\n" \ > "$progname" "$file" > return $FAILURE > fi > > # > # If not found, append new value to last file and return. > # > if [ "$not_found" ]; then > echo "$varname=\"$new_value\"" >> "$file" > return $SUCCESS > fi > > # > # Operate on the matching file, replacing only the last occurrence. > # > local new_contents="`lrev $file 2> /dev/null | \ > ( found= > while read -r LINE; do > if [ ! "$found" ]; then > match="$( echo "$LINE" | grep "$regex" )" > if [ "$match" ]; then > LINE="$varname"'="'"$new_value"'"' > found=1 > fi > fi > echo "$LINE" > done > ) | lrev`" > > [ "$new_contents" ] || return $FAILURE > > # > # Create a new temporary file to write to. > # > local tmpfile="$( mktemp -t "$progname" )" > [ "$tmpfile" ] || return $FAILURE > > # > # Fixup permissions (else we're in for a surprise, as mktemp(1) creates > # the temporary file with 0600 permissions, and if we simply mv(1) the > # temporary file over the destination, the destination will inherit the > # permissions from the temporary file). > # > chmod $( stat -f '%#Lp' "$file" ) "$tmpfile" 2> /dev/null > > # > # Fixup ownerhsip. The destination file _is_ writable (we tested > # earlier above). However, this will fail if we don't have sufficient > # permissions (so we throw stderr into the bit-bucket). > # > chown $( stat -f '%u:%g' "$file" ) "$tmpfile" 2> /dev/null > > # > # Write the temporary file contents and move it into place. > # > echo "$new_contents" > "$tmpfile" || return $FAILURE > mv "$tmpfile" "$file" > } > > # sysrc_desc $varname > # > # Attempts to return the comments associated with varname from the rc.conf(5) > # defaults file `/etc/defaults/rc.conf' (or whatever RC_DEFAULTS points to). > # > # Multi-line comments are joined together. Results are NULL if no description > # could be found. > # > sysrc_desc() > { > local varname="$1" > > ( > buffer= > while read LINE; do > case "$LINE" in > $varname=*) > buffer="$LINE" > break > esac > done > > # Return if the variable wasn't found > [ "$buffer" ] || return $FAILURE > > regex='[[:alpha:]_][[:alnum:]_]*=' > while read LINE; do > # > # Stop reading comments if we reach a new assignment > # directive or if the line contains only whitespace > # > echo "$LINE" | grep -q "^[[:space:]]*$regex" && break > echo "$LINE" | grep -q "^[[:space:]]*#$regex" && break > echo "$LINE" | grep -q "^[[:space:]]*$" && break > > # Append new line to buffer > buffer="$buffer > $LINE" > done > > # Return if the buffer is empty > [ "$buffer" ] || return $FAILURE > > # > # Clean up the buffer. > # > regex='^[^#]*\(#[[:space:]]*\)\{0,1\}' > buffer="$( echo "$buffer" | sed -e "s/$regex//" )" > buffer="$( echo "$buffer" | tr '\n' ' ' \ > | sed -e 's/^[[:space:]]*//;s/[[:space:]]*$//' )" > > echo "$buffer" > > ) < "$RC_DEFAULTS" > } > > ############################################################ MAIN SOURCE > > # > # Perform sanity checks > # > [ $# -gt 0 ] || usage > > # > # Process command-line options > # > while getopts hf:aAdevinN flag; do > case "$flag" in > h) usage;; > f) RC_CONFS="$OPTARG";; > a) SHOW_ALL=1;; > A) SHOW_ALL=2;; > d) DESCRIBE=1;; > e) SHOW_EQUALS=1;; > v) SYSRC_VERBOSE=1;; > i) IGNORE_UNKNOWNS=1;; > n) SHOW_NAME=;; > N) SHOW_VALUE=;; > \?) usage;; > esac > done > shift $(( $OPTIND - 1 )) > > # > # Process command-line options > # > SEP=': ' > [ "$SHOW_EQUALS" ] && SEP='="' > [ "$SHOW_NAME" ] || SHOW_EQUALS= > [ "$SYSRC_VERBOSE" = "0" ] && SYSRC_VERBOSE= > if [ ! "$SHOW_VALUE" ]; then > SHOW_NAME=1 > SHOW_EQUALS= > fi > > if [ "$SHOW_ALL" ]; then > # > # Get a list of variables that are currently set in the rc.conf(5) > # files (included `/etc/defaults/rc.conf') by performing a call to > # source_rc_confs() in a clean environment. > # > ( > # > # Set which variables we want to preserve in the environment. > # Append the pipe-character (|) to the list of internal field > # separation (IFS) characters, allowing us to use the below > # list both as an extended grep (-E) pattern and argument list > # (required to first get clean_env() to preserve these in the > # environment and then later to prune them from the list of > # variables produced by set(1)). > # > IFS="$IFS|" > EXCEPT="IFS|EXCEPT|PATH|RC_DEFAULTS|OPTIND|DESCRIBE|SEP" > EXCEPT="$EXCEPT|SHOW_ALL|SHOW_EQUALS|SHOW_NAME|SHOW_VALUE" > EXCEPT="$EXCEPT|SYSRC_VERBOSE|RC_CONFS" > > # > # Clean the environment (except for our required variables) > # and then source the required files. > # > clean_env --except $EXCEPT > if [ -f "$RC_DEFAULTS" -a -r "$RC_DEFAULTS" ]; then > . "$RC_DEFAULTS" > > # > # If passed `-a' (rather than `-A'), re-purge the > # environment, removing the rc.conf(5) defaults. > # > [ "$SHOW_ALL" = "1" ] \ > && clean_env --except rc_conf_files $EXCEPT > > # > # If `-f file' was passed, set $rc_conf_files to an > # explicit value, modifying the default behavior of > # source_rc_confs(). > # > [ "$RC_CONFS" ] && rc_conf_files="$RC_CONFS" > > source_rc_confs > > # > # If passed `-a' (rather than `-A'), remove > # `rc_conf_files' unless it was defined somewhere > # other than rc.conf(5) defaults. > # > [ "$SHOW_ALL" = "1" -a \ > "$( sysrc_find rc_conf_files )" = "$RC_DEFAULTS" \ > ] \ > && unset rc_conf_files > fi > > for NAME in $( set | awk -F= \ > '/^[[:alpha:]_][[:alnum:]_]*=/ {print $1}' \ > | grep -Ev "^($EXCEPT)$" > ); do > # > # If enabled, describe rather than expand value > # > if [ "$DESCRIBE" ]; then > echo "$NAME: $( sysrc_desc "$NAME" )" > continue > fi > > [ "$SYSRC_VERBOSE" ] && \ > echo -n "$( sysrc_find "$NAME" ): " > > # > # If `-N' is passed, simplify the output > # > if [ ! "$SHOW_VALUE" ]; then > echo "$NAME" > continue > fi > > echo "${SHOW_NAME:+$NAME$SEP}$( > sysrc_get "$NAME" )${SHOW_EQUALS:+\"}" > done > ) > > # > # Ignore the remainder of positional arguments. > # > exit $SUCCESS > fi > > # > # Process command-line arguments > # > while [ $# -gt 0 ]; do > NAME="${1%%=*}" > > [ "$DESCRIBE" ] && \ > echo "$NAME: $( sysrc_desc "$NAME" )" > > case "$1" in > *=*) > # > # Like sysctl(8), if both `-d' AND "name=value" is passed, > # first describe, then attempt to set > # > > if [ "$SYSRC_VERBOSE" ]; then > file="$( sysrc_find "$NAME" )" > [ "$file" = "$RC_DEFAULTS" -o ! "$file" ] && \ > file="$( sysrc_get "rc_conf_files%%[$IFS]*" )" > echo -n "$file: " > fi > > # > # If `-N' is passed, simplify the output > # > if [ ! "$SHOW_VALUE" ]; then > echo "$NAME" > sysrc_set "$NAME" "${1#*}" > else > echo -n "${SHOW_NAME:+$NAME$SEP}$( > sysrc_get "$NAME" )${SHOW_EQUALS:+\"}" > if sysrc_set "$NAME" "${1#*=}"; then > echo " -> $( sysrc_get "$NAME" )" > fi > fi > ;; > *) > if ! IGNORED="$( sysrc_get "$NAME?" )"; then > [ "$IGNORE_UNKNOWNS" ] \ > || echo "$progname: unknown variable '$NAME'" > shift 1 > continue > fi > > # > # Like sysctl(8), when `-d' is passed, > # desribe it rather than expanding it > # > > if [ "$DESCRIBE" ]; then > shift 1 > continue > fi > > [ "$SYSRC_VERBOSE" ] && \ > echo -n "$( sysrc_find "$NAME" ): " > > # > # If `-N' is passed, simplify the output > # > if [ ! "$SHOW_VALUE" ]; then > echo "$NAME" > else > echo "${SHOW_NAME:+$NAME$SEP}$( > sysrc_get "$NAME" )${SHOW_EQUALS:+\"}" > fi > esac > shift 1 > done > > > > -- > Cheers, > Devin Teske > > -> CONTACT INFORMATION <- > Business Solutions Consultant II > FIS - fisglobal.com > 510-735-5650 Mobile > 510-621-2038 Office > 510-621-2020 Office Fax > 909-477-4578 Home/Fax > devin.teske@fisglobal.com > > -> LEGAL DISCLAIMER <- > This message contains confidential and proprietary information > of the sender, and is intended only for the person(s) to whom it > is addressed. Any use, distribution, copying or disclosure by any > other person is strictly prohibited. If you have received this > message in error, please notify the e-mail sender immediately, > and delete the original message without making a copy. > > -> FUN STUFF <- > -----BEGIN GEEK CODE BLOCK----- > Version 3.1 > GAT/CS d(+) s: a- C++(++++) UB++++$ P++(++++) L++(++++) !E--- W++ N? o? K- w O > M+ V- PS+ PE Y+ PGP- t(+) 5? X+(++) R>++ tv(+) b+(++) DI+(++) D(+) G+>++ e>+ h > r>++ y+ > ------END GEEK CODE BLOCK------ > http://www.geekcode.com/ > > -> END TRANSMISSION <- > > _____________ > > The information contained in this message is proprietary and/or confidential. If you are not the intended recipient, please: (i) delete the message and all copies; (ii) do not disclose, distribute or use the message in any manner; and (iii) notify the sender immediately. In addition, please be aware that any message addressed to our domain is subject to archiving and review by persons other than the intended recipient. Thank you. > _____________ > _______________________________________________ > freebsd-rc@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-rc > To unsubscribe, send any mail to "freebsd-rc-unsubscribe@freebsd.org" _____________ The information contained in this message is proprietary and/or confidential. If you are not the intended recipient, please: (i) delete the message and all copies; (ii) do not disclose, distribute or use the message in any manner; and (iii) notify the sender immediately. In addition, please be aware that any message addressed to our domain is subject to archiving and review by persons other than the intended recipient. Thank you. _____________ From owner-freebsd-rc@FreeBSD.ORG Wed Oct 13 00:03:53 2010 Return-Path: Delivered-To: freebsd-rc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 09628106566B for ; Wed, 13 Oct 2010 00:03:53 +0000 (UTC) (envelope-from Devin.Teske@fisglobal.com) Received: from mailoutltc.fnis.com (mailoutltc.fnis.com [199.200.24.190]) by mx1.freebsd.org (Postfix) with ESMTP id ADA218FC0A for ; Wed, 13 Oct 2010 00:03:52 +0000 (UTC) Received: from sbhfislrext02.fnfis.com ([192.168.249.140]) by SCSFISLTC02 (8.14.3/8.14.3) with ESMTP id o9D03qaW026682 for ; Tue, 12 Oct 2010 19:03:52 -0500 Received: from SBHFISLTCGW07.FNFIS.COM (Not Verified[10.132.248.135]) by sbhfislrext02.fnfis.com with MailMarshal (v6, 5, 4, 7535) id ; Tue, 12 Oct 2010 19:03:46 -0500 Received: from sbhfisltcgw01.FNFIS.COM ([10.132.248.121]) by SBHFISLTCGW07.FNFIS.COM with Microsoft SMTPSVC(6.0.3790.4675); Tue, 12 Oct 2010 19:03:51 -0500 Received: from dt.vicor.com ([10.14.152.1]) by sbhfisltcgw01.FNFIS.COM over TLS secured channel with Microsoft SMTPSVC(6.0.3790.4675); Tue, 12 Oct 2010 19:03:51 -0500 From: Devin Teske To: freebsd-rc@freebsd.org In-Reply-To: <1286928074.32724.29.camel@localhost.localdomain> References: <1286925182.32724.18.camel@localhost.localdomain> <1286928074.32724.29.camel@localhost.localdomain> Content-Type: text/plain Date: Tue, 12 Oct 2010 17:03:49 -0700 Message-Id: <1286928229.32724.33.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 (2.0.2-41.el4) Content-Transfer-Encoding: 7bit X-OriginalArrivalTime: 13 Oct 2010 00:03:51.0372 (UTC) FILETIME=[1E1150C0:01CB6A6A] Subject: Re: sysrc(8) -- a sysctl(8)-like utility for managing rc.conf(5) X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Oct 2010 00:03:53 -0000 On Tue, 2010-10-12 at 17:01 -0700, Devin Teske wrote: > > [...] > > Behold... sysrc(8) v2.0 > > GAH!!!! Sorry for the multiple post. Duplicate post was caused by e-mail problems (our company switched domains today, from `@vicor.com' to `@fisglobal.com'), and things bounced. The triplicate post was caused by human error (forgot that Ctrl-Enter in Evolution sends the e-mail, while Ctrl-Enter in other e-mail readers is contextual-newline). Grrrr. -- Devin _____________ The information contained in this message is proprietary and/or confidential. If you are not the intended recipient, please: (i) delete the message and all copies; (ii) do not disclose, distribute or use the message in any manner; and (iii) notify the sender immediately. In addition, please be aware that any message addressed to our domain is subject to archiving and review by persons other than the intended recipient. Thank you. _____________ From owner-freebsd-rc@FreeBSD.ORG Wed Oct 13 19:21:41 2010 Return-Path: Delivered-To: freebsd-rc@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id A075E106566C for ; Wed, 13 Oct 2010 19:21:41 +0000 (UTC) (envelope-from dteske@vicor.com) Received: from postoffice.vicor.com (postoffice.vicor.com [69.26.56.53]) by mx1.freebsd.org (Postfix) with ESMTP id 8AE178FC13 for ; Wed, 13 Oct 2010 19:21:41 +0000 (UTC) Received: from [208.206.78.30] (port=57426 helo=dt.vicor.com) by postoffice.vicor.com with esmtpsa (SSLv3:RC4-MD5:128) (Exim 4.71) (envelope-from ) id 1P66dR-0005PG-Kb for freebsd-rc@freebsd.org; Wed, 13 Oct 2010 12:05:11 -0700 From: Devin Teske To: freebsd-rc@freebsd.org In-Reply-To: <1286925182.32724.18.camel@localhost.localdomain> References: <1286925182.32724.18.camel@localhost.localdomain> Content-Type: text/plain Organization: Vicor, Inc Date: Wed, 13 Oct 2010 12:05:09 -0700 Message-Id: <1286996709.32724.60.camel@localhost.localdomain> Mime-Version: 1.0 X-Mailer: Evolution 2.0.2 (2.0.2-41.el4) Content-Transfer-Encoding: 7bit X-Scan-Signature: 0a625a8c8c0e1eebcb06b5f9d81eb4a5 X-Scan-Host: postoffice.vicor.com Subject: Re: sysrc(8) -- a sysctl(8)-like utility for managing rc.conf(5) X-BeenThere: freebsd-rc@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: "Discussion related to /etc/rc.d design and implementation." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 13 Oct 2010 19:21:41 -0000 On Tue, 2010-10-12 at 16:13 -0700, Devin Teske wrote: > Hey all, > > [...] > > Behold... sysrc(8) v2.0 > > #!/bin/sh > [...] Version 2.1 is available here: http://druidbsd.sf.net/ Direct links: http://druidbsd.sf.net/download/sysrc.gz (download gzipped) http://druidbsd.sf.net/download/sysrc.txt (view as text) Here's the changes: [dteske@ipm0 ~/bin]$ diff -pu sysrc.orig sysrc --- sysrc.orig 2010-10-13 07:16:06.000000000 +0000 +++ sysrc 2010-10-13 07:13:33.000000000 +0000 @@ -2,8 +2,8 @@ # -*- tab-width: 4 -*- ;; Emacs # vi: set tabstop=4 :: Vi/ViM # -# Revision: 2.0 -# Last Modified: October 12th, 2010 +# Revision: 2.1 +# Last Modified: October 13th, 2010 ############################################################ COPYRIGHT # # (c)2010. Devin Teske. All Rights Reserved. @@ -30,6 +30,7 @@ # SUCH DAMAGE. # # AUTHOR DATE DESCRIPTION +# dteske 2010.10.13 Allow `-f file' multiple times. # dteske 2010.10.12 Updates per freebsd-hackers thread. # dteske 2010.09.29 Initial version. # @@ -42,6 +43,7 @@ # OPTIONS: # -h Print this message to stderr and exit. # -f file Operate on the specified file(s) instead of rc_conf_files. +# Can be specified multiple times for additional files. # -a Dump a list of non-default configuration variables. # -A Dump a list of all configuration variables (incl. defaults). # -d Print a description of the given variable. @@ -146,6 +148,8 @@ usage() "Print this message to stderr and exit." eprintf "$optfmt" "-f file" \ "Operate on the specified file(s) instead of rc_conf_files." + eprintf "$optfmt" "" \ + "Can be specified multiple times for additional files." eprintf "$optfmt" "-a" \ "Dump a list of non-default configuration variables." eprintf "$optfmt" "-A" \ @@ -553,7 +557,7 @@ $LINE" while getopts hf:aAdevinN flag; do case "$flag" in h) usage;; - f) RC_CONFS="$OPTARG";; + f) RC_CONFS="$RC_CONFS${RC_CONFS:+ }$OPTARG";; a) SHOW_ALL=1;; A) SHOW_ALL=2;; d) DESCRIBE=1;; -- Cheers, Devin Teske -> CONTACT INFORMATION <- Business Solutions Consultant II FIS - fisglobal.com 510-735-5650 Mobile 510-621-2038 Office 510-621-2020 Office Fax 909-477-4578 Home/Fax devin.teske@fisglobal.com -> LEGAL DISCLAIMER <- This message contains confidential and proprietary information of the sender, and is intended only for the person(s) to whom it is addressed. Any use, distribution, copying or disclosure by any other person is strictly prohibited. If you have received this message in error, please notify the e-mail sender immediately, and delete the original message without making a copy. -> FUN STUFF <- -----BEGIN GEEK CODE BLOCK----- Version 3.1 GAT/CS d(+) s: a- C++(++++) UB++++$ P++(++++) L++(++++) !E--- W++ N? o? K- w O M+ V- PS+ PE Y+ PGP- t(+) 5? X+(++) R>++ tv(+) b+(++) DI+(++) D(+) G+>++ e>+ h r>++ y+ ------END GEEK CODE BLOCK------ http://www.geekcode.com/ -> END TRANSMISSION <-