FreeNAS Code
This project has moved to github - see https://github.com/freenas
Brought to you by:
cochard,
mattolander
#!/bin/sh # # $FreeBSD: src/etc/rc.d/sysctl,v 1.17.2.2.4.1 2009/04/15 03:14:26 kensmith Exp $ # # Modified by Volker Theile (votdev@gmx.de) # Changes: # - Add command mkconf # - Add full path to command sysctl to fix execution bug # # PROVIDE: sysctl # REQUIRE: root # BEFORE: DAEMON . /etc/rc.subr . /etc/configxml.subr name="sysctl" stop_cmd=":" start_precmd="sysctl_mkconf" start_cmd="sysctl_start" reload_cmd="sysctl_start" lastload_cmd="sysctl_start last" mkconf_cmd="sysctl_mkconf" extra_commands="reload lastload mkconf" # Defaults sysctl_config=${sysctl_config:-"/etc/sysctl.conf"} sysctl_mkconf() { # Clear /etc/sysctl.conf cat /dev/null > ${sysctl_config} # Generate /etc/sysctl.conf /usr/local/bin/xml sel -t -m "//system/sysctl/param[enable]" \ -i "string-length(comment) > 0" \ -v "concat('# ',comment)" -n \ -b \ -v "concat(name,'=',value)" -n \ ${configxml_file} | /usr/local/bin/xml unesc >> ${sysctl_config} } # # Read in a file containing sysctl settings and set things accordingly. # parse_file() { if [ -f $1 ]; then while read var comments do case ${var} in \#*|'') ;; *) mib=${var%=*} val=${var#*=} if current_value=`${SYSCTL} -n ${mib} 2>/dev/null`; then case ${current_value} in ${val}) ;; *) /sbin/sysctl "${var}" ;; esac elif [ "$2" = "last" ]; then warn "sysctl ${mib} does not exist." fi ;; esac done < $1 fi } sysctl_start() { parse_file /etc/sysctl.conf $1 parse_file /etc/sysctl.conf.local $1 } load_rc_config $name run_rc_command "$1"