if [ ! -d ${rc_base}/rc${runlevel}.d ];then#是否有该级别的目录 boot_mesg "${rc_base}/rc${runlevel}.d does not exist."${WARNING} boot_mesg_flush exit1 fi
# Attempt to stop all service started by previous runlevel, # and killed in this runlevel #结束该级别中K开头的脚本 if [ "${previous}" !="N" ];then#如果有前一个级别 for i in $(ls -v ${rc_base}/rc${runlevel}.d/K* 2>/dev/null) do check_script_status
if [ "${runlevel}" !="0" ] && [ "${runlevel}" !="6" ];then#不是重启和关机 if [ ! -f ${prev_start} ] && [ ! -f ${sysinit_start} ];then#如果不存在 boot_mesg -n "WARNING: ${i} can't be"${WARNING} #前一级别并没有启动该脚本 boot_mesg -n " executed because it was not" boot_mesg -n " not started in the previous" boot_mesg -n " runlevel (${previous})." boot_mesg ""${NORMAL} boot_mesg_flush continue fi fi ${i} stop #脚本执行stop error_value=${?} #返回值
if [ "${error_value}" !="0" ];then print_error_msg fi done fi
#Start all functions in this runlevel #开始所有S开头的脚本 for i in $( ls -v ${rc_base}/rc${runlevel}.d/S* 2>/dev/null)#获得每个脚本 do if [ "${previous}" !="N" ];then#如果有前一个级别 suffix=${i#$rc_base/rc$runlevel.d/S[0-9][0-9]} #脚本文件名 stop=$rc_base/rc$runlevel.d/K[0-9][0-9]$suffix prev_start=$rc_base/rc$previous.d/S[0-9][0-9]$suffix