rc: Use SYSCTL{,_N,_W} variables
[dragonfly.git] / etc / rc.d / sysctl
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 #
6
7 # PROVIDE: sysctl
8 # REQUIRE: root modules
9 # BEFORE:  DAEMON
10
11 . /etc/rc.subr
12
13 name="sysctl"
14 stop_cmd=":"
15 start_cmd="DragonFly_start"
16 extra_commands="reload lastload"
17 reload_cmd="DragonFly_start"
18 lastload_cmd="DragonFly_start last"
19
20 DragonFly_start()
21 {
22         #
23         # Read in /etc/sysctl.conf and set things accordingly
24         #
25         if [ -f /etc/sysctl.conf ]; then
26                 while read var comments
27                 do
28                         case ${var} in
29                         \#*|'')
30                                 ;;
31                         *)
32                                 mib=${var%=*}
33                                 val=${var#*=}
34
35                                 if current_value=`${SYSCTL_N} -q ${mib}`; then
36                                         case ${current_value} in
37                                         ${val})
38                                                 ;;
39                                         *)
40                                                 ${SYSCTL_W} ${var}
41                                                 ;;
42                                         esac
43                                 elif [ "$1" = "last" ]; then
44                                         warn "sysctl ${mib} does not exist."
45                                 fi
46                                 ;;
47                         esac
48                 done < /etc/sysctl.conf
49         fi
50 }
51
52
53 load_rc_config $name
54 run_rc_command "$1"