From owner-svn-src-head@FreeBSD.ORG Wed Dec 19 15:03:04 2012 Return-Path: Delivered-To: svn-src-head@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 3D8A014E for ; Wed, 19 Dec 2012 15:03:04 +0000 (UTC) (envelope-from andrey@zonov.org) Received: from mail-la0-f45.google.com (mail-la0-f45.google.com [209.85.215.45]) by mx1.freebsd.org (Postfix) with ESMTP id A44278FC16 for ; Wed, 19 Dec 2012 15:03:03 +0000 (UTC) Received: by mail-la0-f45.google.com with SMTP id p9so1540224laa.32 for ; Wed, 19 Dec 2012 07:03:02 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20120113; h=x-received:sender:message-id:date:from:user-agent:mime-version:to :cc:subject:references:in-reply-to:x-enigmail-version:content-type :x-gm-message-state; bh=U3r6N9VTRhfEGd+3vLEaSFyyM1K/iXc0X8paMUirrmA=; b=Ry9Eyf/gsA6ng8ezwWypv3ZHKy5Ggf/2k5r5tY4uCBNFJNQjQbJ0uh5+IobzrX3bXm ++FyT90oxOUl8BoCnVi9OMadsnskGv89Tv48t6Vnty/o++et4KRCNzCt+JCVQgG1YWZ/ YNYBjRTHRAssSRoYDtEMHIQuRy4Q46i4HsIUvSjQuUYIOSL5X8FFIwQm/w8FC9d9HNbW 0g/4Qpij60DbJGtRIb8yD1okgNB51GdvGckAk4l1zXGAKOtDwsOAn7xAX08j+TmyL7kU KGcdN/FfVBbpPH+CXcT21ZOgRmlB0gt4MKu+u+sv57fLOoseWOI+hL3pr+9fa4zmTRVV 6P3Q== X-Received: by 10.112.49.97 with SMTP id t1mr2436548lbn.58.1355929382122; Wed, 19 Dec 2012 07:03:02 -0800 (PST) Received: from dhcp170-82-red.yandex.net (dhcp170-82-red.yandex.net. [95.108.170.82]) by mx.google.com with ESMTPS id ox6sm2168588lab.16.2012.12.19.07.03.00 (version=SSLv3 cipher=OTHER); Wed, 19 Dec 2012 07:03:01 -0800 (PST) Sender: Andrey Zonov Message-ID: <50D1D720.80206@FreeBSD.org> Date: Wed, 19 Dec 2012 19:02:56 +0400 From: Andrey Zonov User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.7; rv:17.0) Gecko/17.0 Thunderbird/17.0 MIME-Version: 1.0 To: Xin LI Subject: Re: svn commit: r244198 - in head: etc/rc.d sbin/sysctl References: <201212132332.qBDNWmK4037503@svn.freebsd.org> In-Reply-To: <201212132332.qBDNWmK4037503@svn.freebsd.org> X-Enigmail-Version: 1.4.6 Content-Type: multipart/signed; micalg=pgp-sha1; protocol="application/pgp-signature"; boundary="------------enig805A045EAA6379B1C8C69FAC" X-Gm-Message-State: ALoCoQm4iwJhIUpyli0raz/tA3v3sjefDvXGe+qu+X2pMHbUP0LwokhvofTKMTNEsGHdl9NqDNJK Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Dec 2012 15:03:04 -0000 This is an OpenPGP/MIME signed message (RFC 2440 and 3156) --------------enig805A045EAA6379B1C8C69FAC Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable On 12/14/12 3:32 AM, Xin LI wrote: > Author: delphij > Date: Thu Dec 13 23:32:47 2012 > New Revision: 244198 > URL: http://svnweb.freebsd.org/changeset/base/244198 >=20 > Log: > Teach sysctl(8) about parsing a file (while I'm there also give it > capability of parsing both =3D and : formats). > =20 > Submitted by: hrs (initial version, bugs are mine) > MFC after: 3 months >=20 > Modified: > head/etc/rc.d/sysctl > head/sbin/sysctl/sysctl.8 > head/sbin/sysctl/sysctl.c >=20 > Modified: head/etc/rc.d/sysctl > =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=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D > --- head/etc/rc.d/sysctl Thu Dec 13 23:19:13 2012 (r244197) > +++ head/etc/rc.d/sysctl Thu Dec 13 23:32:47 2012 (r244198) > @@ -8,51 +8,27 @@ > . /etc/rc.subr > =20 > name=3D"sysctl" > +command=3D"/sbin/sysctl" > stop_cmd=3D":" > start_cmd=3D"sysctl_start" > reload_cmd=3D"sysctl_start" > lastload_cmd=3D"sysctl_start last" > extra_commands=3D"reload lastload" > =20 > -# > -# Read in a file containing sysctl settings and set things accordingly= =2E > -# > -parse_file() > -{ > - if [ -f $1 ]; then > - while read var comments > - do > - case ${var} in > - \#*|'') > - ;; > - *) > - mib=3D${var%=3D*} > - val=3D${var#*=3D} > - > - if current_value=3D`${SYSCTL} -n ${mib} 2>/dev/null`; then > - case ${current_value} in > - ${val}) > - ;; > - *) > - if ! sysctl "${var}" >/dev/null 2>&1; then > - warn "unable to set ${var}" > - fi > - ;; > - esac > - elif [ "$2" =3D "last" ]; then > - warn "sysctl ${mib} does not exist." > - fi > - ;; > - esac > - done < $1 > - fi > -} > - > sysctl_start() > { > - > - parse_file /etc/sysctl.conf $1 > - parse_file /etc/sysctl.conf.local $1 > + case $1 in > + last) > + command_args=3D"-i -f" > + ;; > + *) > + command_args=3D"-f" > + ;; > + esac > + > + for _f in /etc/sysctl.conf /etc/sysctl.conf.local; do > + [ -r ${_f} ] && ${command} ${command_args} ${_f} > /dev/null > + done > } > =20 > load_rc_config $name >=20 Hi, I'd really like to see something like the patch bellow in the tree. I found it very useful with cfengine configuration (as like as cron.d). What do think? diff --git a/etc/rc.d/sysctl b/etc/rc.d/sysctl index 36f1414..014e4c5 100755 --- a/etc/rc.d/sysctl +++ b/etc/rc.d/sysctl @@ -26,7 +26,7 @@ sysctl_start() ;; esac - for _f in /etc/sysctl.conf /etc/sysctl.conf.local; do + for _f in `ls /etc/sysctl.d/* 2> /dev/null` /etc/sysctl.conf /etc/sysctl.conf.local; do [ -r ${_f} ] && ${command} ${command_args} ${_f} > /dev/n= ull done } --=20 Andrey Zonov --------------enig805A045EAA6379B1C8C69FAC Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- Version: GnuPG/MacGPG2 v2.0.18 (Darwin) Comment: GPGTools - http://gpgtools.org iQEcBAEBAgAGBQJQ0dcjAAoJEBWLemxX/CvTxocH/0CHufHaEb4Hp9cxhJ7jY/th D3ohgw1Bcu4qKvqUIq2k6COfUdWwPF0Y97/abowLRT55uHKuzhlwVeOiIqh8+ieJ 20R78DozLDc3QJT8HaJ/m/QQjsWFG8oFr0H5F8S/B+HLZ56mjGAYmsEqy5oAVLT/ rEkp3QEYgZhXP/iwfBJ1GNUDnnskbhqa3aZvuudohPwXW2flwtlLgZHcFnIfYYvV cc3+3TH5Kp597YiY/1gs9uEXw7QY6aon7B1RK+boxM0n9yh30SHcfuZMMbt9whs0 +i3Hw7NzKY4BjpNmjyHkgucHLYuhiUHbskKLSk6ZBhBO5HaWeDX32b1sbUV2AAs= =vB3y -----END PGP SIGNATURE----- --------------enig805A045EAA6379B1C8C69FAC--