rc.subr (271545) | rc.subr (272393) |
---|---|
1# $NetBSD: rc.subr,v 1.67 2006/10/07 11:25:15 elad Exp $ | 1# $NetBSD: rc.subr,v 1.67 2006/10/07 11:25:15 elad Exp $ |
2# $FreeBSD: head/etc/rc.subr 271545 2014-09-13 18:54:15Z hrs $ | 2# $FreeBSD: head/etc/rc.subr 272393 2014-10-02 01:16:30Z hrs $ |
3# 4# Copyright (c) 1997-2004 The NetBSD Foundation, Inc. 5# All rights reserved. 6# 7# This code is derived from software contributed to The NetBSD Foundation 8# by Luke Mewburn. 9# 10# Redistribution and use in source and binary forms, with or without --- 52 unchanged lines hidden (view full) --- 63 var="${LINE%%=*}" 64 case "$var" in 65 "$LINE"|*[!a-zA-Z0-9_]*) continue ;; 66 $1) echo $var 67 esac 68 done; } 69} 70 | 3# 4# Copyright (c) 1997-2004 The NetBSD Foundation, Inc. 5# All rights reserved. 6# 7# This code is derived from software contributed to The NetBSD Foundation 8# by Luke Mewburn. 9# 10# Redistribution and use in source and binary forms, with or without --- 52 unchanged lines hidden (view full) --- 63 var="${LINE%%=*}" 64 case "$var" in 65 "$LINE"|*[!a-zA-Z0-9_]*) continue ;; 66 $1) echo $var 67 esac 68 done; } 69} 70 |
71# set_rcvar [var] [defval] [desc] 72# 73# Echo or define a rc.conf(5) variable name. Global variable 74# $rcvars is used. 75# 76# If no argument is specified, echo "${name}_enable". 77# 78# If only a var is specified, echo "${var}_enable". 79# 80# If var and defval are specified, the ${var} is defined as 81# rc.conf(5) variable and the default value is ${defvar}. An 82# optional argument $desc can also be specified to add a 83# description for that. 84# 85set_rcvar() 86{ 87 local _var 88 89 case $# in 90 0) echo ${name}_enable ;; 91 1) echo ${1}_enable ;; 92 *) 93 debug "set_rcvar: \$$1=$2 is added" \ 94 " as a rc.conf(5) variable." 95 _var=$1 96 rcvars="${rcvars# } $_var" 97 eval ${_var}_defval=\"$2\" 98 shift 2 99 eval ${_var}_desc=\"$*\" 100 ;; 101 esac 102} 103 |
|
71# set_rcvar_obsolete oldvar [newvar] [msg] 72# Define obsolete variable. 73# Global variable $rcvars_obsolete is used. 74# 75set_rcvar_obsolete() 76{ 77 local _var 78 _var=$1 | 104# set_rcvar_obsolete oldvar [newvar] [msg] 105# Define obsolete variable. 106# Global variable $rcvars_obsolete is used. 107# 108set_rcvar_obsolete() 109{ 110 local _var 111 _var=$1 |
79 debug "rcvar_obsolete: \$$1(old) -> \$$2(new) is defined" | 112 debug "set_rcvar_obsolete: \$$1(old) -> \$$2(new) is defined" |
80 81 rcvars_obsolete="${rcvars_obsolete# } $1" 82 eval ${1}_newvar=\"$2\" 83 shift 2 84 eval ${_var}_obsolete_msg=\"$*\" 85} 86 87# --- 998 unchanged lines hidden (view full) --- 1086 rcvar) 1087 echo -n "# $name" 1088 if [ -n "$desc" ]; then 1089 echo " : $desc" 1090 else 1091 echo "" 1092 fi 1093 echo "#" | 113 114 rcvars_obsolete="${rcvars_obsolete# } $1" 115 eval ${1}_newvar=\"$2\" 116 shift 2 117 eval ${_var}_obsolete_msg=\"$*\" 118} 119 120# --- 998 unchanged lines hidden (view full) --- 1119 rcvar) 1120 echo -n "# $name" 1121 if [ -n "$desc" ]; then 1122 echo " : $desc" 1123 else 1124 echo "" 1125 fi 1126 echo "#" |
1094 # Get unique vars in $rcvar 1095 for _v in $rcvar; do | 1127 # Get unique vars in $rcvar $rcvars 1128 for _v in $rcvar $rcvars; do |
1096 case $v in 1097 $_v\ *|\ *$_v|*\ $_v\ *) ;; 1098 *) v="${v# } $_v" ;; 1099 esac 1100 done 1101 1102 # Display variables. 1103 for _v in $v; do --- 129 unchanged lines hidden (view full) --- 1233 _file=$1 1234 _arg=$2 1235 if [ -z "$_file" -o -z "$_arg" ]; then 1236 err 3 'USAGE: run_rc_script file arg' 1237 fi 1238 1239 unset name command command_args command_interpreter \ 1240 extra_commands pidfile procname \ | 1129 case $v in 1130 $_v\ *|\ *$_v|*\ $_v\ *) ;; 1131 *) v="${v# } $_v" ;; 1132 esac 1133 done 1134 1135 # Display variables. 1136 for _v in $v; do --- 129 unchanged lines hidden (view full) --- 1266 _file=$1 1267 _arg=$2 1268 if [ -z "$_file" -o -z "$_arg" ]; then 1269 err 3 'USAGE: run_rc_script file arg' 1270 fi 1271 1272 unset name command command_args command_interpreter \ 1273 extra_commands pidfile procname \ |
1241 rcvar rcvars_obsolete required_dirs required_files \ | 1274 rcvar rcvars rcvars_obsolete required_dirs required_files \ |
1242 required_vars 1243 eval unset ${_arg}_cmd ${_arg}_precmd ${_arg}_postcmd 1244 1245 case "$_file" in 1246 /etc/rc.d/*.sh) # no longer allowed in the base 1247 warn "Ignoring old-style startup script $_file" 1248 ;; 1249 *[~#]|*.OLD|*.bak|*.orig|*,v) # scratch file; skip --- 51 unchanged lines hidden (view full) --- 1301 debug "Sourcing $_rc" 1302 . "$_rc" 1303 fi 1304 done 1305 fi 1306 done 1307 1308 # Set defaults if defined. | 1275 required_vars 1276 eval unset ${_arg}_cmd ${_arg}_precmd ${_arg}_postcmd 1277 1278 case "$_file" in 1279 /etc/rc.d/*.sh) # no longer allowed in the base 1280 warn "Ignoring old-style startup script $_file" 1281 ;; 1282 *[~#]|*.OLD|*.bak|*.orig|*,v) # scratch file; skip --- 51 unchanged lines hidden (view full) --- 1334 debug "Sourcing $_rc" 1335 . "$_rc" 1336 fi 1337 done 1338 fi 1339 done 1340 1341 # Set defaults if defined. |
1309 for _var in $rcvar; do | 1342 for _var in $rcvar $rcvars; do |
1310 eval _defval=\$${_var}_defval 1311 if [ -n "$_defval" ]; then 1312 eval : \${$_var:=\$${_var}_defval} 1313 fi 1314 done 1315 1316 # check obsolete rc.conf variables 1317 for _var in $rcvars_obsolete; do --- 728 unchanged lines hidden --- | 1343 eval _defval=\$${_var}_defval 1344 if [ -n "$_defval" ]; then 1345 eval : \${$_var:=\$${_var}_defval} 1346 fi 1347 done 1348 1349 # check obsolete rc.conf variables 1350 for _var in $rcvars_obsolete; do --- 728 unchanged lines hidden --- |