svn commit: r244198 - in head: etc/rc.d sbin/sysctl
Andrey Zonov
zont at FreeBSD.org
Wed Dec 19 15:03:04 UTC 2012
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
>
> Log:
> Teach sysctl(8) about parsing a file (while I'm there also give it
> capability of parsing both = and : formats).
>
> Submitted by: hrs (initial version, bugs are mine)
> MFC after: 3 months
>
> Modified:
> head/etc/rc.d/sysctl
> head/sbin/sysctl/sysctl.8
> head/sbin/sysctl/sysctl.c
>
> Modified: head/etc/rc.d/sysctl
> ==============================================================================
> --- 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
>
> name="sysctl"
> +command="/sbin/sysctl"
> stop_cmd=":"
> start_cmd="sysctl_start"
> reload_cmd="sysctl_start"
> lastload_cmd="sysctl_start last"
> extra_commands="reload lastload"
>
> -#
> -# Read in a file containing sysctl settings and set things accordingly.
> -#
> -parse_file()
> -{
> - if [ -f $1 ]; then
> - while read var comments
> - do
> - case ${var} in
> - \#*|'')
> - ;;
> - *)
> - mib=${var%=*}
> - val=${var#*=}
> -
> - if current_value=`${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" = "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="-i -f"
> + ;;
> + *)
> + command_args="-f"
> + ;;
> + esac
> +
> + for _f in /etc/sysctl.conf /etc/sysctl.conf.local; do
> + [ -r ${_f} ] && ${command} ${command_args} ${_f} > /dev/null
> + done
> }
>
> load_rc_config $name
>
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/null
done
}
--
Andrey Zonov
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 535 bytes
Desc: OpenPGP digital signature
URL: <http://lists.freebsd.org/pipermail/svn-src-head/attachments/20121219/cbef0d86/attachment.sig>
More information about the svn-src-head
mailing list