2011-04-26 12:26:24 +02:00
|
|
|
#!/bin/sh
|
|
|
|
# rc.sysinit - System initialization control script
|
|
|
|
|
|
|
|
# Copyright (c) 2008-2011 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
|
2011-09-01 13:59:50 +02:00
|
|
|
[ -e /etc/locale.conf ] && . /etc/locale.conf || . /etc/sysconfig/i18n
|
2011-04-26 12:26:24 +02:00
|
|
|
LC_ALL=$LANG
|
|
|
|
TEXTDOMAIN=initscripts
|
|
|
|
TEXTDOMAINDIR=/usr/share/locale/
|
|
|
|
|
|
|
|
trap "" SIGINT SIGQUIT SIGTSTP
|
|
|
|
|
|
|
|
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 ] || {
|
|
|
|
logfile="/dev/.sysinit.start"
|
2011-11-14 19:38:35 +01:00
|
|
|
> $logfile
|
2011-04-26 12:26:24 +02:00
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
|
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...
|
2011-11-14 19:38:35 +01:00
|
|
|
[ $debug -eq 0 ] && mv $logfile /var/log/initd.sysinit.start
|
2011-04-26 12:26:24 +02:00
|
|
|
|
|
|
|
# ...and remove garbage temp files
|
|
|
|
rm -f /tmp/.runlevel.start.* 2>/dev/null
|
|
|
|
rm -f /var/lock/subsys/local
|