1if [ ! "$_STARTUP_RCVAR_SUBR" ]; then _STARTUP_RCVAR_SUBR=1
2#
3# Copyright (c) 2006-2013 Devin Teske
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:
--- 10 unchanged lines hidden (view full) ---
19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25# SUCH DAMAGE.
26#
27# $FreeBSD: head/usr.sbin/bsdconfig/startup/share/rcvar.subr 259054 2013-12-07 00:31:01Z dteske $
28#
29############################################################ INCLUDES
30
31BSDCFG_SHARE="/usr/share/bsdconfig"
32. $BSDCFG_SHARE/common.subr || exit 1
33f_dprintf "%s: loading includes..." startup/rcvar.subr
34f_include $BSDCFG_SHARE/sysrc.subr
35
--- 80 unchanged lines hidden (view full) ---
116 find_local_scripts_new
117 echo $local_rc
118 )"
119 __rc_script_list="${__rc_script_list# }" # Trim leading space
120
121 #
122 # Calculate a digest given the checksums of all dependencies (scripts
123 # and the defaults file). This digest will be used to determine if an
124 # on-disk global persistant cache file (containg this digest on the
125 # first line) is valid and can be used to quickly populate the cache
126 # value for immediate return.
127 #
128 local __rc_script_list_digest
129 __rc_script_list_digest=$( cd "$ETC_RC_D" 2> /dev/null &&
130 cksum "$RC_DEFAULTS" $__rc_script_list 2> /dev/null | md5 )
131
132 #
133 # Check to see if the global persistant cache file exists
134 #
135 if [ -f "$STARTUP_RCVAR_MAP_CACHEFILE" ]; then
136 #
137 # Attempt to populate the in-memory cache with the (soon to be)
138 # validated on-disk cache. If validation fails, fall-back to
139 # the current value and return error.
140 #
141 STARTUP_RCVAR_MAP=$(
--- 27 unchanged lines hidden (view full) ---
169 fi
170 return $SUCCESS
171 fi
172 # Otherwise, fall-thru to create in-memory cache from scratch
173 fi
174
175 #
176 # If we reach this point, we need to generate the data from scratch
177 # (and after we do, we'll attempt to create the global persistant
178 # cache file to speed up future executions).
179 #
180
181 STARTUP_RCVAR_MAP=$(
182 for script in $__rc_script_list; do
183 rcvar_list=$( $script rcvar 2> /dev/null | awk -F= \
184 -v script="$script" '
185 /^'"$STARTUP_RCVAR_REGEX"'/ {
--- 17 unchanged lines hidden (view full) ---
203 export _STARTUP_RCVAR_MAP=1
204 if [ "$__var_to_set" ]; then
205 setvar "$__var_to_set" "$STARTUP_RCVAR_MAP"
206 else
207 echo "$STARTUP_RCVAR_MAP"
208 fi
209
210 #
211 # Attempt to create/update the persistant global cache
212 #
213
214 # Create a new temporary file to write to
215 local __tmpfile
216 f_eval_catch -dk __tmpfile $__funcname mktemp \
217 'mktemp -t "%s"' "$__tmpfile" || return $FAILURE
218
219 # Write the temporary file contents
--- 17 unchanged lines hidden ---
2#
3# Copyright (c) 2006-2013 Devin Teske
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:
--- 10 unchanged lines hidden (view full) ---
19# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
20# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
21# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25# SUCH DAMAGE.
26#
27# $FreeBSD: head/usr.sbin/bsdconfig/startup/share/rcvar.subr 259054 2013-12-07 00:31:01Z dteske $
28#
29############################################################ INCLUDES
30
31BSDCFG_SHARE="/usr/share/bsdconfig"
32. $BSDCFG_SHARE/common.subr || exit 1
33f_dprintf "%s: loading includes..." startup/rcvar.subr
34f_include $BSDCFG_SHARE/sysrc.subr
35
--- 80 unchanged lines hidden (view full) ---
116 find_local_scripts_new
117 echo $local_rc
118 )"
119 __rc_script_list="${__rc_script_list# }" # Trim leading space
120
121 #
122 # Calculate a digest given the checksums of all dependencies (scripts
123 # and the defaults file). This digest will be used to determine if an
124 # on-disk global persistant cache file (containg this digest on the
125 # first line) is valid and can be used to quickly populate the cache
126 # value for immediate return.
127 #
128 local __rc_script_list_digest
129 __rc_script_list_digest=$( cd "$ETC_RC_D" 2> /dev/null &&
130 cksum "$RC_DEFAULTS" $__rc_script_list 2> /dev/null | md5 )
131
132 #
133 # Check to see if the global persistant cache file exists
134 #
135 if [ -f "$STARTUP_RCVAR_MAP_CACHEFILE" ]; then
136 #
137 # Attempt to populate the in-memory cache with the (soon to be)
138 # validated on-disk cache. If validation fails, fall-back to
139 # the current value and return error.
140 #
141 STARTUP_RCVAR_MAP=$(
--- 27 unchanged lines hidden (view full) ---
169 fi
170 return $SUCCESS
171 fi
172 # Otherwise, fall-thru to create in-memory cache from scratch
173 fi
174
175 #
176 # If we reach this point, we need to generate the data from scratch
177 # (and after we do, we'll attempt to create the global persistant
178 # cache file to speed up future executions).
179 #
180
181 STARTUP_RCVAR_MAP=$(
182 for script in $__rc_script_list; do
183 rcvar_list=$( $script rcvar 2> /dev/null | awk -F= \
184 -v script="$script" '
185 /^'"$STARTUP_RCVAR_REGEX"'/ {
--- 17 unchanged lines hidden (view full) ---
203 export _STARTUP_RCVAR_MAP=1
204 if [ "$__var_to_set" ]; then
205 setvar "$__var_to_set" "$STARTUP_RCVAR_MAP"
206 else
207 echo "$STARTUP_RCVAR_MAP"
208 fi
209
210 #
211 # Attempt to create/update the persistant global cache
212 #
213
214 # Create a new temporary file to write to
215 local __tmpfile
216 f_eval_catch -dk __tmpfile $__funcname mktemp \
217 'mktemp -t "%s"' "$__tmpfile" || return $FAILURE
218
219 # Write the temporary file contents
--- 17 unchanged lines hidden ---