RC cleanups and minor bug fixes to support the uname change to DragonFly
[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.2 2003/11/18 23:46:01 dillon 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
18 case ${OSTYPE} in
19 DragonFly)
20          start_cmd="DragonFly_start"
21         extra_commands="reload lastload"
22         reload_cmd="DragonFly_start"
23         lastload_cmd="DragonFly_start last"
24         ;;
25
26 FreeBSD)
27         start_cmd="FreeBSD_start"
28         extra_commands="reload lastload"
29         reload_cmd="FreeBSD_start"
30         lastload_cmd="FreeBSD_start last"
31         ;;
32 NetBSD)
33         start_cmd="NetBSD_start"
34         ;;
35 esac
36
37 DragonFly_start()
38 {
39         FreeBSD_start $1
40 }
41
42 FreeBSD_start()
43 {
44         #
45         # Read in /etc/sysctl.conf and set things accordingly
46         #
47         if [ -f /etc/sysctl.conf ]; then
48                 while read var comments
49                 do
50                         case ${var} in
51                         \#*|'')
52                                 ;;
53                         *)
54                                 mib=${var%=*}
55                                 val=${var#*=}
56
57                                 if current_value=`${SYSCTL} -n ${mib} 2>/dev/null`; then
58                                         case ${current_value} in
59                                         ${val})
60                                                 ;;
61                                         *)
62                                                 sysctl ${var}
63                                                 ;;
64                                         esac
65                                 elif [ "$1" = "last" ]; then
66                                         warn "sysctl ${mib} does not exist."
67                                 fi
68                                 ;;
69                         esac
70                 done < /etc/sysctl.conf
71         fi
72 }
73
74 NetBSD_start()
75 {
76         if [ -r /etc/sysctl.conf ]; then
77                 echo "Setting sysctl variables:"
78                 ${SYSCTL} -f /etc/sysctl.conf
79         fi
80 }
81
82 load_rc_config $name
83 run_rc_command "$1"