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.1 2003/07/24 06:35:37 dillon Exp $ 6# 7 8# PROVIDE: sysctl 9# REQUIRE: root 10# BEFORE: DAEMON 11# KEYWORD: DragonFly FreeBSD NetBSD 12 13. /etc/rc.subr 14 15name="sysctl" 16stop_cmd=":" 17 18case ${OSTYPE} in 19DragonFly) 20 start_cmd="DragonFly_start" 21 extra_commands="reload lastload" 22 reload_cmd="DragonFly_start" 23 lastload_cmd="DragonFly_start last" 24 ;; 25 26FreeBSD) 27 start_cmd="FreeBSD_start" 28 extra_commands="reload lastload" 29 reload_cmd="FreeBSD_start" 30 lastload_cmd="FreeBSD_start last" 31 ;; 32NetBSD) 33 start_cmd="NetBSD_start" 34 ;; 35esac 36FreeBSD_start() 37{ 38 # 39 # Read in /etc/sysctl.conf and set things accordingly 40 # 41 if [ -f /etc/sysctl.conf ]; then 42 while read var comments 43 do 44 case ${var} in 45 \#*|'') 46 ;; 47 *) 48 mib=${var%=*} 49 val=${var#*=} 50 if current_value=`${SYSCTL} -n ${mib} 2>/dev/null`; then 51 case ${current_value} in 52 ${val}) 53 ;; 54 *) 55 sysctl ${var} 56 ;; 57 esac 58 elif [ "$1" = "last" ]; then 59 warn "sysctl ${mib} does not exist." 60 fi 61 ;; 62 esac 63 done < /etc/sysctl.conf 64 fi 65} 66 67FreeBSD_start() 68{ 69 # 70 # Read in /etc/sysctl.conf and set things accordingly 71 # 72 if [ -f /etc/sysctl.conf ]; then 73 while read var comments 74 do 75 case ${var} in 76 \#*|'') 77 ;; 78 *) 79 mib=${var%=*} 80 val=${var#*=} 81 82 if current_value=`${SYSCTL} -n ${mib} 2>/dev/null`; then 83 case ${current_value} in 84 ${val}) 85 ;; 86 *) 87 sysctl ${var} 88 ;; 89 esac 90 elif [ "$1" = "last" ]; then 91 warn "sysctl ${mib} does not exist." 92 fi 93 ;; 94 esac 95 done < /etc/sysctl.conf 96 fi 97} 98 99NetBSD_start() 100{ 101 if [ -r /etc/sysctl.conf ]; then 102 echo "Setting sysctl variables:" 103 ${SYSCTL} -f /etc/sysctl.conf 104 fi 105} 106 107load_rc_config $name 108run_rc_command "$1" 109