sysctl revision 92516
1119420Sobrien#!/bin/sh
2178466Smarius#
353790Sobrien# Copyright (c) 1999  Warner Losh
453790Sobrien# All rights reserved.
586266Sgroudier#
653790Sobrien# Redistribution and use in source and binary forms, with or without
753790Sobrien# modification, are permitted provided that the following conditions
859743Sgroudier# are met:
959743Sgroudier# 1. Redistributions of source code must retain the above copyright
1053790Sobrien#    notice, this list of conditions and the following disclaimer.
11178466Smarius# 2. Redistributions in binary form must reproduce the above copyright
1253790Sobrien#    notice, this list of conditions and the following disclaimer in the
1353790Sobrien#    documentation and/or other materials provided with the distribution.
1453790Sobrien#
15178466Smarius# THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
1653790Sobrien# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
1753790Sobrien# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
1853790Sobrien# ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
1953790Sobrien# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
2053790Sobrien# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
2153790Sobrien# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
2253790Sobrien# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23178466Smarius# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24178466Smarius# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
2553790Sobrien# SUCH DAMAGE.
2653790Sobrien#
2753790Sobrien# $FreeBSD: head/etc/rc.d/sysctl 92516 2002-03-17 20:14:11Z dougb $
2853790Sobrien#
2953790Sobrien
3053790Sobrien#
3153790Sobrien# Read in /etc/sysctl.conf and set things accordingly
3253790Sobrien#
3353790Sobrien
3453790Sobrienif [ -f /etc/sysctl.conf ]; then
3553790Sobrien	while read var comments
3653790Sobrien	do
3753790Sobrien		case ${var} in
3853790Sobrien		\#*|'')
3953790Sobrien			;;
4053790Sobrien		*)
4153790Sobrien			mib=${var%=*}
4253790Sobrien			val=${var#*=}
4353790Sobrien
4453790Sobrien			if current_value=`sysctl -n ${mib} 2>/dev/null`; then
4553790Sobrien				case ${current_value} in
4653790Sobrien				${val}) ;;
4753790Sobrien				*)
4853790Sobrien					sysctl ${var}
4953790Sobrien					;;
5053790Sobrien				esac
5153790Sobrien			else
5253790Sobrien				case ${1} in
5353790Sobrien				last)
5453790Sobrien				echo "Warning: sysctl ${mib} does not exist"
5553790Sobrien					;;
5653790Sobrien				esac
5753790Sobrien			fi
58119420Sobrien			;;
59119420Sobrien		esac
6055258Sobrien	done < /etc/sysctl.conf
6165404Sgroudierfi
6253790Sobrien