xref: /dragonfly/etc/rc.d/sysctl (revision c89a6c1b)
1#!/bin/sh
2#
3# $NetBSD: sysctl,v 1.12 2002/04/29 12:10:23 lukem Exp $
4# $FreeBSD: src/etc/rc.d/sysctl,v 1.12 2003/04/24 08:20:47 mtm Exp $
5# $DragonFly: src/etc/rc.d/sysctl,v 1.5 2005/11/19 21:47:32 swildner Exp $
6#
7
8# PROVIDE: sysctl
9# REQUIRE: root
10# BEFORE:  DAEMON
11
12. /etc/rc.subr
13
14name="sysctl"
15stop_cmd=":"
16start_cmd="DragonFly_start"
17extra_commands="reload lastload"
18reload_cmd="DragonFly_start"
19lastload_cmd="DragonFly_start last"
20
21DragonFly_start()
22{
23	#
24	# Read in /etc/sysctl.conf and set things accordingly
25	#
26	if [ -f /etc/sysctl.conf ]; then
27		while read var comments
28		do
29			case ${var} in
30			\#*|'')
31				;;
32			*)
33				mib=${var%=*}
34				val=${var#*=}
35
36				if current_value=`${SYSCTL} -n ${mib} 2>/dev/null`; then
37					case ${current_value} in
38					${val})
39						;;
40					*)
41						sysctl ${var}
42						;;
43					esac
44				elif [ "$1" = "last" ]; then
45					warn "sysctl ${mib} does not exist."
46				fi
47				;;
48			esac
49		done < /etc/sysctl.conf
50	fi
51}
52
53
54load_rc_config $name
55run_rc_command "$1"
56