求助──解释下这段代码/etc/rc

sh/bash/dash/ksh/zsh等Shell脚本
回复
yhui1286
帖子: 25
注册时间: 2008-03-20 21:46

求助──解释下这段代码/etc/rc

#1

帖子 yhui1286 » 2010-05-03 15:06

case "$CONCURRENCY" in
shell)
log_action_msg "Using shell-style concurrent boot in runlevel $runlevel"
startup() {
action=$1
shift
scripts="$@"
backgrounded=0 :em20
for script in $scripts ; do
case "$script" in
*.sh)
if [ "." = "$sh" ] ; then
RC_SAVE_PATH="$PATH"
set -- "$action"
$debug . "$script"
PATH="$RC_SAVE_PATH"
startup_progress
else
$debug $sh "$script" $action
startup_progress
fi
;;
*)
$debug "$script" $action &
startup_progress
backgrounded=1
;;
esac
done
[ 1 = "$backgrounded" ] && wait
}
;;
startpar)
log_action_msg "Using startpar-style concurrent boot in runlevel $runlevel"
startup() {
action=$1
shift
scripts="$@"
# Make sure .sh scripts are sourced in runlevel S
if [ "." = "$sh" ] ; then
newscripts=
for script in $scripts ; do
case "$script" in
*.sh)
RC_SAVE_PATH="$PATH"
set -- "$action"
$debug . "$script"
PATH="$RC_SAVE_PATH"
startup_progress
;;
*)
newscripts="$newscripts $script"
step=$(($step + $step_change))
;;
esac
done
scripts="$newscripts"
else
# Update progress bar counter and jump to the new position
for script in $scripts ; do
step=$(($step + $step_change))
done
fi

# startpar is not able to handle time jumps. So the
# hwclock.sh scripts should not be executed from
# within startpar. The .sh hack above make this
# problem irrelevant. [pere 2005-09-10]
[ -n "$scripts" ] && $debug startpar -a $action $scripts

# Jump back one step to compencate for stepping one
# time too many in the for loop, and to keep the same
# location as the startup_progress call in the *.sh
# case.
step=$(($step - $step_change))
startup_progress
}
;;
none|*)
startup() {
action=$1
shift
scripts="$@"
for script in $scripts ; do
case "$script" in
*.sh)
if [ "." = "$sh" ] ; then
RC_SAVE_PATH="$PATH"
set "$action"
$debug . "$script"
PATH="$RC_SAVE_PATH"
startup_progress
else
$debug $sh "$script" $action
startup_progress
fi
;;
*)
$debug "$script" $action
startup_progress
;;
esac
done
}
;;
esac


:em20
回复