[Demudi-commits] r913 - / sysv-rc-bootsplash
sysv-rc-bootsplash/branches sysv-rc-bootsplash/branches/upstream
sysv-rc-bootsplash/branches/upstream/current
Free Ekanayaka
free-guest at costa.debian.org
Wed Sep 20 11:49:21 UTC 2006
Author: free-guest
Date: 2006-09-20 11:49:14 +0000 (Wed, 20 Sep 2006)
New Revision: 913
Added:
sysv-rc-bootsplash/
sysv-rc-bootsplash/branches/
sysv-rc-bootsplash/branches/upstream/
sysv-rc-bootsplash/branches/upstream/current/
sysv-rc-bootsplash/branches/upstream/current/functions.bootsplash
sysv-rc-bootsplash/branches/upstream/current/functions.initramfs-tools
sysv-rc-bootsplash/branches/upstream/current/rc.bootsplash
sysv-rc-bootsplash/branches/upstream/current/rc.sysv-rc
sysv-rc-bootsplash/tags/
Log:
[svn-inject] Installing original source of sysv-rc-bootsplash
Added: sysv-rc-bootsplash/branches/upstream/current/functions.bootsplash
===================================================================
--- sysv-rc-bootsplash/branches/upstream/current/functions.bootsplash (rev 0)
+++ sysv-rc-bootsplash/branches/upstream/current/functions.bootsplash 2006-09-20 11:49:14 UTC (rev 913)
@@ -0,0 +1,224 @@
+# -*- shell-script -*-
+
+_log_msg()
+{
+ if [ "$quiet" = "y" ]; then return; fi
+ echo "$@"
+}
+
+log_success_msg()
+{
+ _log_msg "Success: $@"
+}
+
+log_failure_msg()
+{
+ _log_msg "Failure: $@"
+}
+
+log_warning_msg()
+{
+ _log_msg "Warning: $@"
+}
+
+log_begin_msg()
+{
+ if [ -x /sbin/usplash_write ]; then
+ /sbin/usplash_write "TEXT $@"
+ fi
+ _log_msg "Begin: $@ ..."
+}
+
+log_end_msg()
+{
+ if [ -x /sbin/usplash_write ]; then
+ /sbin/usplash_write "SUCCESS ok"
+ fi
+ _log_msg "Done."
+ update_progress
+}
+
+update_progress()
+{
+ [ -d /dev/.initramfs ] || return
+
+ if [ -z "$PROGRESS_STATE" ]; then
+ export PROGRESS_STATE=0
+ fi
+
+ PROGRESS_STATE=$(($PROGRESS_STATE + 1))
+ echo "PROGRESS_STATE=${PROGRESS_STATE}" > /dev/.initramfs/progress_state
+
+ if [ -x /sbin/usplash_write ]; then
+ /sbin/usplash_write "PROGRESS $PROGRESS_STATE"
+ fi
+ if [ -w /proc/splash ]; then
+ echo "show $(( $PROGRESS_STATE * 65534 / 100 ))" > /proc/splash
+ fi
+}
+
+panic()
+{
+ if [ -x /sbin/usplash_write ]; then
+ /sbin/usplash_write "QUIT"
+ fi
+ modprobe -q i8042
+ modprobe -q atkbd
+ echo $@
+ FS1='(initramfs) ' /bin/sh </dev/console >/dev/console 2>&1
+}
+
+maybe_break()
+{
+ if [ x$1 = x${break} ]; then
+ panic "Spawning shell within the initramfs"
+ fi
+}
+
+render()
+{
+ eval "echo -n \${$@}"
+}
+
+set_initlist()
+{
+ unset initlist
+ for si_x in ${initdir}/*; do
+ if [ ! -x ${si_x} ]; then
+ continue
+ fi
+ initlist="${initlist} $(basename ${si_x})"
+ done
+}
+
+reduce_satisfied()
+{
+ deplist="$(render array_${1})"
+ for rs_x in ${runlist}; do
+ pop_list_item ${rs_x} ${deplist}
+ deplist=${tmppop}
+ done
+ eval array_${1}=\"${deplist}\"
+}
+
+get_prereqs()
+{
+ set_initlist
+ for gp_x in ${initlist}; do
+ tmp=$(${initdir}/${gp_x} prereqs)
+ eval array_${gp_x}=\"${tmp}\"
+ done
+}
+
+count_unsatisfied()
+{
+ set - ${@}
+ return ${#}
+}
+
+# Removes $1 from initlist
+pop_list_item()
+{
+ item=${1}
+ shift
+ set - ${@}
+ unset tmppop
+ # Iterate
+ for pop in ${@}; do
+ if [ ${pop} = ${item} ]; then
+ continue
+ fi
+ tmppop="${tmppop} ${pop}"
+ done
+
+}
+
+# This function generates the runlist, so we clear it first.
+reduce_prereqs()
+{
+ unset runlist
+ set_initlist
+ set - ${initlist}
+ i=$#
+ # Loop until there's no more in the queue to loop through
+ while [ ${i} -ne 0 ]; do
+ oldi=${i}
+ for rp_x in ${initlist}; do
+ reduce_satisfied ${rp_x}
+ count_unsatisfied $(render array_${rp_x})
+ cnt=${?}
+ if [ ${cnt} -eq 0 ]; then
+ runlist="${runlist} ${rp_x}"
+ pop_list_item ${rp_x} ${initlist}
+ initlist=${tmppop}
+ i=$((${i} - 1))
+ fi
+ done
+ if [ ${i} -eq ${oldi} ]; then
+ panic "PANIC: Circular dependancy. Exiting."
+ fi
+ done
+}
+
+call_scripts()
+{
+ for cs_x in ${runlist}; do
+ ${initdir}/${cs_x}
+ # allow boot scripts to modify exported boot paramaters
+ if [ -e /conf/param.conf ]; then
+ . /conf/param.conf
+ fi
+ done
+}
+
+run_scripts()
+{
+ initdir=${1}
+ get_prereqs
+ reduce_prereqs
+ call_scripts
+}
+
+# Load custom modules first
+load_modules()
+{
+ if [ -e /conf/modules ]; then
+ cat /conf/modules | while read m; do
+ if [ -z "$m" ] \
+ || expr "$m" : "#" >/dev/null \
+ || expr "$m" : "[ \t]+#?" > /dev/null
+ then
+ continue;
+ else
+ modprobe -q $m
+ fi
+ done
+ fi
+}
+
+# lilo compatibility
+parse_numeric() {
+ case $1 in
+ "")
+ return
+ ;;
+ /*)
+ return
+ ;;
+ *:*)
+ minor=${1#*:}
+ major=${1%:*}
+ ;;
+ [0-9][0-9][0-9])
+ minor=$((0x${1#?}))
+ major=$((0x${1%??}))
+ ;;
+ *)
+ minor=$((0x${1#??}))
+ major=$((0x${1%??}))
+ ;;
+ esac
+
+ mknod /dev/root b ${major} ${minor}
+ ROOT=/dev/root
+}
Added: sysv-rc-bootsplash/branches/upstream/current/functions.initramfs-tools
===================================================================
--- sysv-rc-bootsplash/branches/upstream/current/functions.initramfs-tools (rev 0)
+++ sysv-rc-bootsplash/branches/upstream/current/functions.initramfs-tools 2006-09-20 11:49:14 UTC (rev 913)
@@ -0,0 +1,221 @@
+# -*- shell-script -*-
+
+_log_msg()
+{
+ if [ "$quiet" = "y" ]; then return; fi
+ echo "$@"
+}
+
+log_success_msg()
+{
+ _log_msg "Success: $@"
+}
+
+log_failure_msg()
+{
+ _log_msg "Failure: $@"
+}
+
+log_warning_msg()
+{
+ _log_msg "Warning: $@"
+}
+
+log_begin_msg()
+{
+ if [ -x /sbin/usplash_write ]; then
+ /sbin/usplash_write "TEXT $@"
+ fi
+ _log_msg "Begin: $@ ..."
+}
+
+log_end_msg()
+{
+ if [ -x /sbin/usplash_write ]; then
+ /sbin/usplash_write "SUCCESS ok"
+ fi
+ _log_msg "Done."
+ update_progress
+}
+
+update_progress()
+{
+ [ -d /dev/.initramfs ] || return
+
+ if [ -z "$PROGRESS_STATE" ]; then
+ export PROGRESS_STATE=0
+ fi
+
+ PROGRESS_STATE=$(($PROGRESS_STATE + 1))
+ echo "PROGRESS_STATE=${PROGRESS_STATE}" > /dev/.initramfs/progress_state
+
+ if [ -x /sbin/usplash_write ]; then
+ /sbin/usplash_write "PROGRESS $PROGRESS_STATE"
+ fi
+}
+
+panic()
+{
+ if [ -x /sbin/usplash_write ]; then
+ /sbin/usplash_write "QUIT"
+ fi
+ modprobe -q i8042
+ modprobe -q atkbd
+ echo $@
+ FS1='(initramfs) ' /bin/sh </dev/console >/dev/console 2>&1
+}
+
+maybe_break()
+{
+ if [ x$1 = x${break} ]; then
+ panic "Spawning shell within the initramfs"
+ fi
+}
+
+render()
+{
+ eval "echo -n \${$@}"
+}
+
+set_initlist()
+{
+ unset initlist
+ for si_x in ${initdir}/*; do
+ if [ ! -x ${si_x} ]; then
+ continue
+ fi
+ initlist="${initlist} $(basename ${si_x})"
+ done
+}
+
+reduce_satisfied()
+{
+ deplist="$(render array_${1})"
+ for rs_x in ${runlist}; do
+ pop_list_item ${rs_x} ${deplist}
+ deplist=${tmppop}
+ done
+ eval array_${1}=\"${deplist}\"
+}
+
+get_prereqs()
+{
+ set_initlist
+ for gp_x in ${initlist}; do
+ tmp=$(${initdir}/${gp_x} prereqs)
+ eval array_${gp_x}=\"${tmp}\"
+ done
+}
+
+count_unsatisfied()
+{
+ set - ${@}
+ return ${#}
+}
+
+# Removes $1 from initlist
+pop_list_item()
+{
+ item=${1}
+ shift
+ set - ${@}
+ unset tmppop
+ # Iterate
+ for pop in ${@}; do
+ if [ ${pop} = ${item} ]; then
+ continue
+ fi
+ tmppop="${tmppop} ${pop}"
+ done
+
+}
+
+# This function generates the runlist, so we clear it first.
+reduce_prereqs()
+{
+ unset runlist
+ set_initlist
+ set - ${initlist}
+ i=$#
+ # Loop until there's no more in the queue to loop through
+ while [ ${i} -ne 0 ]; do
+ oldi=${i}
+ for rp_x in ${initlist}; do
+ reduce_satisfied ${rp_x}
+ count_unsatisfied $(render array_${rp_x})
+ cnt=${?}
+ if [ ${cnt} -eq 0 ]; then
+ runlist="${runlist} ${rp_x}"
+ pop_list_item ${rp_x} ${initlist}
+ initlist=${tmppop}
+ i=$((${i} - 1))
+ fi
+ done
+ if [ ${i} -eq ${oldi} ]; then
+ panic "PANIC: Circular dependancy. Exiting."
+ fi
+ done
+}
+
+call_scripts()
+{
+ for cs_x in ${runlist}; do
+ ${initdir}/${cs_x}
+ # allow boot scripts to modify exported boot paramaters
+ if [ -e /conf/param.conf ]; then
+ . /conf/param.conf
+ fi
+ done
+}
+
+run_scripts()
+{
+ initdir=${1}
+ get_prereqs
+ reduce_prereqs
+ call_scripts
+}
+
+# Load custom modules first
+load_modules()
+{
+ if [ -e /conf/modules ]; then
+ cat /conf/modules | while read m; do
+ if [ -z "$m" ] \
+ || expr "$m" : "#" >/dev/null \
+ || expr "$m" : "[ \t]+#?" > /dev/null
+ then
+ continue;
+ else
+ modprobe -q $m
+ fi
+ done
+ fi
+}
+
+# lilo compatibility
+parse_numeric() {
+ case $1 in
+ "")
+ return
+ ;;
+ /*)
+ return
+ ;;
+ *:*)
+ minor=${1#*:}
+ major=${1%:*}
+ ;;
+ [0-9][0-9][0-9])
+ minor=$((0x${1#?}))
+ major=$((0x${1%??}))
+ ;;
+ *)
+ minor=$((0x${1#??}))
+ major=$((0x${1%??}))
+ ;;
+ esac
+
+ mknod /dev/root b ${major} ${minor}
+ ROOT=/dev/root
+}
Added: sysv-rc-bootsplash/branches/upstream/current/rc.bootsplash
===================================================================
--- sysv-rc-bootsplash/branches/upstream/current/rc.bootsplash (rev 0)
+++ sysv-rc-bootsplash/branches/upstream/current/rc.bootsplash 2006-09-20 11:49:14 UTC (rev 913)
@@ -0,0 +1,363 @@
+#! /bin/sh
+#
+# rc
+#
+# Starts/stops services on runlevel changes.
+#
+# Optimization: A start script is not run when the service was already
+# configured to run in the previous runlevel. A stop script is not run
+# when the the service was already configured not to run in the previous
+# runlevel.
+#
+# Authors:
+# Miquel van Smoorenburg <miquels at cistron.nl>
+# Bruce Perens <Bruce at Pixar.com>
+# Edited for bootsplash by Pablo Chinea <khertz at gmail.com>, 2006
+#
+
+PATH=/sbin:/bin:/usr/sbin:/usr/bin
+export PATH
+
+# Un-comment the following for debugging.
+# debug=echo
+
+# Specify method used to enable concurrent init.d scripts.
+# Valid options are 'none', 'shell' and 'startpar'
+CONCURRENCY=none
+
+# Make sure the name survive changing the argument list
+scriptname="$0"
+
+umask 022
+
+on_exit() {
+ echo "error: '$scriptname' exited outside the expected code flow."
+}
+trap on_exit EXIT # Enable emergency handler
+
+# Ignore CTRL-C only in this shell, so we can interrupt subprocesses.
+trap ":" INT QUIT TSTP
+
+# Set onlcr to avoid staircase effect.
+stty onlcr 0>&1
+
+# source the bootsplash config file
+test -f /etc/default/bootsplash && . /etc/default/bootsplash
+
+#
+# Update bootsplash stuff. (progress bar, animations...)
+#
+rc_splash() {
+ export progress
+ test "$SPLASH" != "no" && /sbin/splash.sh "$1"
+}
+
+# Now find out what the current and what the previous runlevel are.
+
+runlevel=$RUNLEVEL
+# Get first argument. Set new runlevel to this argument.
+[ "$1" != "" ] && runlevel=$1
+if [ "$runlevel" = "" ]
+then
+ echo "Usage: $scriptname <runlevel>" >&2
+ exit 1
+fi
+previous=$PREVLEVEL
+[ "$previous" = "" ] && previous=N
+
+export runlevel previous
+
+if [ S = "$runlevel" ]
+then
+ #
+ # See if system needs to be setup. This is ONLY meant to
+ # be used for the initial setup after a fresh installation!
+ #
+ if [ -x /sbin/unconfigured.sh ]
+ then
+ /sbin/unconfigured.sh
+ fi
+ rc_splash "splash start" # let bootsplash know we are ready
+fi
+
+. /etc/default/rcS
+export VERBOSE
+
+#
+# Stub to do progress bar ticks (currently just for usplash) on startup
+#
+startup_progress() {
+ $@
+ step=$(($step + $step_change))
+ progress=$(($step * $progress_size / $num_steps + $first_step))
+ if type usplash_write >/dev/null 2>&1; then
+ usplash_write "PROGRESS $progress" || true
+ fi
+}
+
+#
+# Start script or program.
+#
+case "$CONCURRENCY" in
+ none)
+ startup() {
+ action=$1
+ shift
+ scripts="$@"
+ sh=sh
+ # Debian Policy §9.3.1 requires .sh scripts in runlevel S to be sourced
+ # However, some important packages currently contain .sh scripts
+ # that do "exit" at some point, thus killing this process. Bad!
+ #[ S = "$runlevel" ] && sh=.
+ for script in $scripts ; do
+ case "$script" in
+ *.sh)
+ if [ "." = "$sh" ] ; then
+ set "$action"
+ RC_SAVE_PATH="$PATH"
+ startup_progress $debug . "$script"
+ PATH="$RC_SAVE_PATH"
+ else
+ startup_progress $debug $sh "$script" $action
+ fi
+ ;;
+ *)
+ startup_progress $debug "$script" $action
+ ;;
+ esac
+ done
+ }
+ ;;
+ shell)
+ startup() {
+ action=$1
+ shift
+ scripts="$@"
+ sh=sh
+ # Debian Policy §9.3.1 requires .sh scripts in runlevel S to be sourced
+ # However, some important packages currently contain .sh scripts
+ # that do "exit" at some point, thus killing this process. Bad!
+ #[ S = "$runlevel" ] && sh=.
+ backgrounded=0
+ for script in $scripts ; do
+ case "$script" in
+ *.sh)
+ if [ "." = "$sh" ] ; then
+ set "$action"
+ RC_SAVE_PATH="$PATH"
+ startup_progress $debug . "$script"
+ PATH="$RC_SAVE_PATH"
+ else
+ startup_progress $debug $sh "$script" $action
+ fi
+ ;;
+ *)
+ startup_progress $debug "$script" $action &
+ backgrounded=1
+ ;;
+ esac
+ done
+ [ 1 = "$backgrounded" ] && wait
+ }
+ ;;
+ startpar)
+ startup() {
+ action=$1
+ shift
+ scripts="$@"
+ sh=sh
+ # Debian Policy §9.3.1 requires .sh scripts in runlevel S to be sourced
+ # However, some important packages currently contain .sh scripts
+ # that do "exit" at some point, thus killing this process. Bad!
+ #[ S = "$runlevel" ] && sh=.
+ # Make sure .sh scripts are sourced in runlevel S
+ if [ "." = "$sh" ] ; then
+ newscripts=
+ for script in $scripts ; do
+ case "$script" in
+ *.sh)
+ set "$action"
+ RC_SAVE_PATH="$PATH"
+ startup_progress $debug . "$script"
+ PATH="$RC_SAVE_PATH"
+ ;;
+ *)
+ newscripts="$newscripts $script"
+ ;;
+ esac
+ done
+ scripts="$newscripts"
+ 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" ] && startup_progress $debug startpar -a $action $scripts
+ }
+ ;;
+esac
+
+#
+# let bootsplash know if we are shutting down
+#
+if [ "$runlevel" = "0" -o "$runlevel" = "6" ]
+then
+ rc_splash "splash start"
+ rc_splash "shutdown"
+fi
+
+# Is there an rc directory for this new runlevel?
+if [ -d /etc/rc$runlevel.d ]
+then
+ # Find out where in the progress bar the initramfs got to.
+ PROGRESS_STATE=0
+ if [ -f /dev/.initramfs/progress_state ]; then
+ . /dev/.initramfs/progress_state
+ fi
+
+ # Split the remaining portion of the progress bar into thirds
+ progress_size=$(((100 - $PROGRESS_STATE) / 3))
+
+ case "$runlevel" in
+ 0|6)
+ ACTION=stop
+ # Count down from 0 to -100 and use the entire bar
+ first_step=0
+ progress_size=100
+ step_change=-1
+ ;;
+ S)
+ ACTION=start
+ # Begin where the initramfs left off and use 2/3
+ # of the remaining space
+ first_step=$PROGRESS_STATE
+ progress_size=$(($progress_size * 2))
+ step_change=1
+ ;;
+ *)
+ ACTION=start
+ # Begin where rcS left off and use the final 1/3 of
+ # the space (by leaving progress_size unchanged)
+ first_step=$(($progress_size * 2 + $PROGRESS_STATE))
+ step_change=1
+ ;;
+ esac
+
+ # Count the number of scripts we need to run (for usplash
+ # progress bar)
+ num_steps=0
+ for s in /etc/rc$runlevel.d/[SK]*; do
+ case "${s##/etc/rc$runlevel.d/S??}" in
+ gdm|xdm|kdm|reboot|halt)
+ break
+ ;;
+ esac
+ num_steps=$(($num_steps + 1))
+ done
+ step=0
+
+ # First, run the KILL scripts.
+ if [ "$previous" != N ]
+ then
+ # Run all scripts with the same level in parallel
+ CURLEVEL=""
+ for s in /etc/rc$runlevel.d/K*
+ do
+ level=$(echo $s | sed 's/.*\/K\([0-9][0-9]\).*/\1/')
+ if [ "$level" = "$CURLEVEL" ]
+ then
+ continue
+ fi
+ CURLEVEL=$level
+ SCRIPTS=""
+ for i in /etc/rc$runlevel.d/K$level*
+ do
+ # Check if the script is there.
+ [ ! -f $i ] && continue
+
+ #
+ # Find stop script in previous runlevel but
+ # no start script there.
+ #
+ suffix=${i#/etc/rc$runlevel.d/K[0-9][0-9]}
+ previous_stop=/etc/rc$previous.d/K[0-9][0-9]$suffix
+ previous_start=/etc/rc$previous.d/S[0-9][0-9]$suffix
+ #
+ # If there is a stop script in the previous level
+ # and _no_ start script there, we don't
+ # have to re-stop the service.
+ #
+ [ -f $previous_stop ] && [ ! -f $previous_start ] && continue
+
+ # Stop the service.
+ SCRIPTS="$SCRIPTS $i"
+ done
+ startup stop $SCRIPTS
+ rc_splash "$i stop" # update bootsplash progress bar
+ done
+ fi
+
+ # Now run the START scripts for this runlevel.
+ # Run all scripts with the same level in parallel
+ CURLEVEL=""
+ step=0
+ for s in /etc/rc$runlevel.d/S*
+ do
+ level=$(echo $s | sed 's/.*\/S\([0-9][0-9]\).*/\1/')
+ if [ "$level" = "$CURLEVEL" ]
+ then
+ continue
+ fi
+ CURLEVEL=$level
+ SCRIPTS=""
+ for i in /etc/rc$runlevel.d/S$level*
+ do
+ [ ! -f $i ] && continue
+
+ if [ "$previous" != N ]
+ then
+ #
+ # Find start script in previous runlevel and
+ # stop script in this runlevel.
+ #
+ suffix=${i#/etc/rc$runlevel.d/S[0-9][0-9]}
+ stop=/etc/rc$runlevel.d/K[0-9][0-9]$suffix
+ previous_start=/etc/rc$previous.d/S[0-9][0-9]$suffix
+ #
+ # If there is a start script in the previous level
+ # and _no_ stop script in this level, we don't
+ # have to re-start the service.
+ #
+ [ -f $previous_start ] && [ ! -f $stop ] && continue
+ fi
+ SCRIPTS="$SCRIPTS $i"
+ done
+ startup $ACTION $SCRIPTS
+ rc_splash "$i $ACTION" # update bootsplash progress bar
+ done
+fi
+
+if [ S = "$runlevel" ]
+then
+ #
+ # For compatibility, run the files in /etc/rc.boot too.
+ #
+ [ -d /etc/rc.boot ] && run-parts /etc/rc.boot
+
+ #
+ # Finish setup if needed. The comment above about
+ # /sbin/unconfigured.sh applies here as well!
+ #
+ if [ -x /sbin/setup.sh ]
+ then
+ /sbin/setup.sh
+ fi
+fi
+
+rc_splash "master" # stop playing animations
+
+trap - EXIT # Disable emergency handler
+
+exit 0
+
Added: sysv-rc-bootsplash/branches/upstream/current/rc.sysv-rc
===================================================================
--- sysv-rc-bootsplash/branches/upstream/current/rc.sysv-rc (rev 0)
+++ sysv-rc-bootsplash/branches/upstream/current/rc.sysv-rc 2006-09-20 11:49:14 UTC (rev 913)
@@ -0,0 +1,346 @@
+#! /bin/sh
+#
+# rc
+#
+# Starts/stops services on runlevel changes.
+#
+# Optimization: A start script is not run when the service was already
+# configured to run in the previous runlevel. A stop script is not run
+# when the the service was already configured not to run in the previous
+# runlevel.
+#
+# Authors:
+# Miquel van Smoorenburg <miquels at cistron.nl>
+# Bruce Perens <Bruce at Pixar.com>
+
+PATH=/sbin:/bin:/usr/sbin:/usr/bin
+export PATH
+
+# Un-comment the following for debugging.
+# debug=echo
+
+# Specify method used to enable concurrent init.d scripts.
+# Valid options are 'none', 'shell' and 'startpar'
+CONCURRENCY=none
+
+# Make sure the name survive changing the argument list
+scriptname="$0"
+
+umask 022
+
+on_exit() {
+ echo "error: '$scriptname' exited outside the expected code flow."
+}
+trap on_exit EXIT # Enable emergency handler
+
+# Ignore CTRL-C only in this shell, so we can interrupt subprocesses.
+trap ":" INT QUIT TSTP
+
+# Set onlcr to avoid staircase effect.
+stty onlcr 0>&1
+
+# Decide if usplash progress bar should be activated or not. Override
+# in /etc/default/rcS if required.
+if type usplash_write >/dev/null 2>&1; then
+ SPLASH=true
+else
+ SPLASH=false
+fi
+
+# Now find out what the current and what the previous runlevel are.
+
+runlevel=$RUNLEVEL
+# Get first argument. Set new runlevel to this argument.
+[ "$1" != "" ] && runlevel=$1
+if [ "$runlevel" = "" ]
+then
+ echo "Usage: $scriptname <runlevel>" >&2
+ exit 1
+fi
+previous=$PREVLEVEL
+[ "$previous" = "" ] && previous=N
+
+export runlevel previous
+
+if [ S = "$runlevel" ]
+then
+ #
+ # See if system needs to be setup. This is ONLY meant to
+ # be used for the initial setup after a fresh installation!
+ #
+ if [ -x /sbin/unconfigured.sh ]
+ then
+ /sbin/unconfigured.sh
+ fi
+fi
+
+. /etc/default/rcS
+export VERBOSE
+
+#
+# Stub to do progress bar ticks (currently just for usplash) on startup
+#
+startup_progress() {
+ $@
+ if [ "$SPLASH" = true ] ; then
+ step=$(($step + $step_change))
+ progress=$(($step * $progress_size / $num_steps + $first_step))
+ usplash_write "PROGRESS $progress" || true
+ fi
+}
+
+#
+# Start script or program.
+#
+case "$CONCURRENCY" in
+ none)
+ startup() {
+ action=$1
+ shift
+ scripts="$@"
+ sh=sh
+ # Debian Policy §9.3.1 requires .sh scripts in runlevel S to be sourced
+ # However, some important packages currently contain .sh scripts
+ # that do "exit" at some point, thus killing this process. Bad!
+ #[ S = "$runlevel" ] && sh=.
+ for script in $scripts ; do
+ case "$script" in
+ *.sh)
+ if [ "." = "$sh" ] ; then
+ set "$action"
+ RC_SAVE_PATH="$PATH"
+ startup_progress $debug . "$script"
+ PATH="$RC_SAVE_PATH"
+ else
+ startup_progress $debug $sh "$script" $action
+ fi
+ ;;
+ *)
+ startup_progress $debug "$script" $action
+ ;;
+ esac
+ done
+ }
+ ;;
+ shell)
+ startup() {
+ action=$1
+ shift
+ scripts="$@"
+ sh=sh
+ # Debian Policy §9.3.1 requires .sh scripts in runlevel S to be sourced
+ # However, some important packages currently contain .sh scripts
+ # that do "exit" at some point, thus killing this process. Bad!
+ #[ S = "$runlevel" ] && sh=.
+ backgrounded=0
+ for script in $scripts ; do
+ case "$script" in
+ *.sh)
+ if [ "." = "$sh" ] ; then
+ set "$action"
+ RC_SAVE_PATH="$PATH"
+ startup_progress $debug . "$script"
+ PATH="$RC_SAVE_PATH"
+ else
+ startup_progress $debug $sh "$script" $action
+ fi
+ ;;
+ *)
+ startup_progress $debug "$script" $action &
+ backgrounded=1
+ ;;
+ esac
+ done
+ [ 1 = "$backgrounded" ] && wait
+ }
+ ;;
+ startpar)
+ startup() {
+ action=$1
+ shift
+ scripts="$@"
+ sh=sh
+ # Debian Policy §9.3.1 requires .sh scripts in runlevel S to be sourced
+ # However, some important packages currently contain .sh scripts
+ # that do "exit" at some point, thus killing this process. Bad!
+ #[ S = "$runlevel" ] && sh=.
+ # Make sure .sh scripts are sourced in runlevel S
+ if [ "." = "$sh" ] ; then
+ newscripts=
+ for script in $scripts ; do
+ case "$script" in
+ *.sh)
+ set "$action"
+ RC_SAVE_PATH="$PATH"
+ startup_progress $debug . "$script"
+ PATH="$RC_SAVE_PATH"
+ ;;
+ *)
+ newscripts="$newscripts $script"
+ ;;
+ esac
+ done
+ scripts="$newscripts"
+ 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" ] && startup_progress $debug startpar -a $action $scripts
+ }
+ ;;
+esac
+
+# Is there an rc directory for this new runlevel?
+if [ -d /etc/rc$runlevel.d ]
+then
+ # Find out where in the progress bar the initramfs got to.
+ PROGRESS_STATE=0
+ if [ -f /dev/.initramfs/progress_state ]; then
+ . /dev/.initramfs/progress_state
+ fi
+
+ # Split the remaining portion of the progress bar into thirds
+ progress_size=$(((100 - $PROGRESS_STATE) / 3))
+
+ case "$runlevel" in
+ 0|6)
+ ACTION=stop
+ # Count down from 0 to -100 and use the entire bar
+ first_step=0
+ progress_size=100
+ step_change=-1
+ ;;
+ S)
+ ACTION=start
+ # Begin where the initramfs left off and use 2/3
+ # of the remaining space
+ first_step=$PROGRESS_STATE
+ progress_size=$(($progress_size * 2))
+ step_change=1
+ ;;
+ *)
+ ACTION=start
+ # Begin where rcS left off and use the final 1/3 of
+ # the space (by leaving progress_size unchanged)
+ first_step=$(($progress_size * 2 + $PROGRESS_STATE))
+ step_change=1
+ ;;
+ esac
+
+ if [ "$SPLASH" = true ] ; then
+ # Count the number of scripts we need to run (for usplash
+ # progress bar)
+ num_steps=0
+ for s in /etc/rc$runlevel.d/[SK]*; do
+ case "${s##/etc/rc$runlevel.d/S??}" in
+ gdm|xdm|kdm|reboot|halt)
+ break
+ ;;
+ esac
+ num_steps=$(($num_steps + 1))
+ done
+ step=0
+ fi
+
+ # First, run the KILL scripts.
+ if [ "$previous" != N ]
+ then
+ # Run all scripts with the same level in parallel
+ CURLEVEL=""
+ for s in /etc/rc$runlevel.d/K*
+ do
+ level=$(echo $s | sed 's/.*\/K\([0-9][0-9]\).*/\1/')
+ if [ "$level" = "$CURLEVEL" ]
+ then
+ continue
+ fi
+ CURLEVEL=$level
+ SCRIPTS=""
+ for i in /etc/rc$runlevel.d/K$level*
+ do
+ # Check if the script is there.
+ [ ! -f $i ] && continue
+
+ #
+ # Find stop script in previous runlevel but
+ # no start script there.
+ #
+ suffix=${i#/etc/rc$runlevel.d/K[0-9][0-9]}
+ previous_stop=/etc/rc$previous.d/K[0-9][0-9]$suffix
+ previous_start=/etc/rc$previous.d/S[0-9][0-9]$suffix
+ #
+ # If there is a stop script in the previous level
+ # and _no_ start script there, we don't
+ # have to re-stop the service.
+ #
+ [ -f $previous_stop ] && [ ! -f $previous_start ] && continue
+
+ # Stop the service.
+ SCRIPTS="$SCRIPTS $i"
+ done
+ startup stop $SCRIPTS
+ done
+ fi
+
+ # Now run the START scripts for this runlevel.
+ # Run all scripts with the same level in parallel
+ CURLEVEL=""
+ step=0
+ for s in /etc/rc$runlevel.d/S*
+ do
+ level=$(echo $s | sed 's/.*\/S\([0-9][0-9]\).*/\1/')
+ if [ "$level" = "$CURLEVEL" ]
+ then
+ continue
+ fi
+ CURLEVEL=$level
+ SCRIPTS=""
+ for i in /etc/rc$runlevel.d/S$level*
+ do
+ [ ! -f $i ] && continue
+
+ if [ "$previous" != N ]
+ then
+ #
+ # Find start script in previous runlevel and
+ # stop script in this runlevel.
+ #
+ suffix=${i#/etc/rc$runlevel.d/S[0-9][0-9]}
+ stop=/etc/rc$runlevel.d/K[0-9][0-9]$suffix
+ previous_start=/etc/rc$previous.d/S[0-9][0-9]$suffix
+ #
+ # If there is a start script in the previous level
+ # and _no_ stop script in this level, we don't
+ # have to re-start the service.
+ #
+ [ -f $previous_start ] && [ ! -f $stop ] && continue
+ fi
+ SCRIPTS="$SCRIPTS $i"
+ done
+ startup $ACTION $SCRIPTS
+ done
+fi
+
+if [ S = "$runlevel" ]
+then
+ #
+ # For compatibility, run the files in /etc/rc.boot too.
+ #
+ [ -d /etc/rc.boot ] && run-parts /etc/rc.boot
+
+ #
+ # Finish setup if needed. The comment above about
+ # /sbin/unconfigured.sh applies here as well!
+ #
+ if [ -x /sbin/setup.sh ]
+ then
+ /sbin/setup.sh
+ fi
+fi
+
+trap - EXIT # Disable emergency handler
+
+exit 0
+
More information about the Demudi-commits
mailing list