xref: /freebsd/libexec/rc/rc.d/sysctl (revision e8d8bef961a50d4dc22501cde4fb9fb0be1b2532)
1#!/bin/sh
2#
3# $FreeBSD$
4#
5
6# PROVIDE: sysctl
7
8. /etc/rc.subr
9
10name="sysctl"
11desc="Set sysctl variables from /etc/sysctl.conf and /etc/sysctl.conf.local"
12command="/sbin/sysctl"
13stop_cmd=":"
14start_cmd="sysctl_start"
15reload_cmd="sysctl_start last"
16lastload_cmd="sysctl_start last"
17extra_commands="reload lastload"
18
19sysctl_start()
20{
21	case $1 in
22	last)
23		command_args="-f"
24	;;
25	*)
26		command_args="-i -f"
27	;;
28	esac
29
30	for _f in /etc/sysctl.conf /etc/sysctl.conf.local; do
31		if [ -r ${_f} ]; then
32			${command} ${command_args} ${_f} > /dev/null
33		fi
34	done
35}
36
37load_rc_config $name
38run_rc_command "$1"
39