initscripts/etc/rc.d/init.d/rc.sysinit
Davide Madrisan c58556f8e8 Remove SIG prefix from SIGINT,SIGQUIT,SIGTSTP for POSIX (and dash) compatibility
Signed-off-by: Davide Madrisan <davide.madrisan@gmail.com>
2012-01-19 20:23:54 +01:00

105 lines
2.7 KiB
Bash
Executable File

#!/bin/sh
# rc.sysinit - System initialization control script
# Copyright (c) 2008-2012 by Silvan Calarco <silvan.calarco@mambasoft.it>
# Modified by Davide Madrisan <davide.madrisan@gmail.com>
#
. /etc/sysconfig/rc
# first look for an embedded rc.sysinit
if [ -r $rc_base/init.d/rc.sysinit.embedded ]; then
. $rc_base/init.d/rc.sysinit.embedded
exit 0
fi
. $rc_functions
[ -e /etc/locale.conf ] && . /etc/locale.conf || . /etc/sysconfig/i18n
LC_ALL=$LANG
TEXTDOMAIN=initscripts
TEXTDOMAINDIR=/usr/share/locale/
trap "" INT QUIT TSTP
runlevel=sysinit
rex="[0-9][0-9]"
# detect kernel command line parameters
# $CMDLINE may be exported from mkinitramfs
[ "$CMDLINE" ] || {
[ -e /proc/cmdline ] || {
mount -n -t proc proc /proc
fin=/proc/cmdline
}
[ "$fin" -a -e $fin ] && CMDLINE="`cat $fin`" || CMDLINE=""
}
debug=0 # debug must be defined
for cmd in $CMDLINE; do
case "$cmd" in
debug) debug=1 ;;
debug=*) debug=${cmd/debug=/} ;;
esac
done
[ $debug -gt 0 ] && logfile="/dev/console" || logfile="/dev/null"
if [ ! -d $rc_base/rc$runlevel.d ]; then
echo $"$rc_base/rc$runlevel.d does not exist"
exit 1
fi
# set dns-resolving safe hostname for sysinit to successfully run
hostname localhost
startservices="`ls -1 $rc_base/rc$runlevel.d/S* 2>/dev/null`"
startservicesnum=`echo $startservices | wc -w`
i=0
for servicefile in $startservices; do
# write log to file as soon as writable filesystem is available
[ $logfile = "/dev/null" -a -w "/run" ] && {
logfile="/run/.sysinit.start"
> $logfile
}
if [ "$previous" != "N" ]; then
service=${servicefile#$rc_base/rc$runlevel.d/S$rex}
stop=$rc_base/rc$runlevel.d/K$rex$service
prev_start=$rc_base/rc$previous.d/S$rex$service
[ -f "$prev_start" ] && [ ! -f "$stop" ] && continue
fi
check_link $servicefile || continue
[ -x /bin/date ] &&
echo $"Begin sysinit $service at `/bin/date`" >> $logfile
progress=`expr 5 + $i \* 45 / $startservicesnum`
$PLYMOUTH update --status="$progress"
if [ "$service" = "postplug" ]; then
$servicefile start
else
$servicefile start >> $logfile 2>&1
fi
error_value=$?
if [ $error_value -ne 0 ]; then
echo "
You should not be reading this error message.
It means that an unforseen error took place in $servicefile,
which exited with a return value of $error_value
" >> $logfile
fi
[ -x /bin/date ] &&
echo $"End sysinit $service at `/bin/date`" >> $logfile
i=`expr $i + 1`
done
# rootfs should now be mounted rw, we can move logs there and umount tmpfs...
[ $debug -eq 0 ] && mv $logfile /var/log/initd.sysinit.start
# ...and remove garbage temp files
rm -f /tmp/.runlevel.start.* 2>/dev/null
rm -f /var/lock/subsys/local