Date: Wed, 19 Dec 2012 19:02:56 +0400 From: Andrey Zonov <zont@FreeBSD.org> To: Xin LI <delphij@FreeBSD.org> Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org, src-committers@freebsd.org Subject: Re: svn commit: r244198 - in head: etc/rc.d sbin/sysctl Message-ID: <50D1D720.80206@FreeBSD.org> In-Reply-To: <201212132332.qBDNWmK4037503@svn.freebsd.org> References: <201212132332.qBDNWmK4037503@svn.freebsd.org>
next in thread | previous in thread | raw e-mail | index | archive | help
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--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?50D1D720.80206>