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