init: add initqueue-finished
/initqueue-finished/*.sh are scripts, which return != 0, if the main loop still has pending jobs to do.master
parent
fc3c64c8d4
commit
8238850caa
|
|
@ -36,6 +36,12 @@ source_all() {
|
|||
for f in "/$1"/*.sh; do [ -f "$f" ] && . "$f"; done
|
||||
}
|
||||
|
||||
check_finished() {
|
||||
local f
|
||||
for f in /initqueue-finished/*.sh; do [ -f "$f" ] && { ( . "$f" ) || return 1; } ; done
|
||||
return 0
|
||||
}
|
||||
|
||||
source_conf() {
|
||||
local f
|
||||
[ "$1" ] && [ -d "/$1" ] || return
|
||||
|
|
@ -109,10 +115,12 @@ incol2() {
|
|||
}
|
||||
|
||||
udevsettle() {
|
||||
local exit_if_exists;
|
||||
|
||||
[ -z "$UDEVVERSION" ] && UDEVVERSION=$(udevadm --version)
|
||||
|
||||
if [ $UDEVVERSION -ge 143 ]; then
|
||||
udevadm settle --exit-if-exists=/initqueue/work --exit-if-exists=/dev/root
|
||||
udevadm settle --exit-if-exists=/initqueue/work $settle_exit_if_exists
|
||||
else
|
||||
udevadm settle --timeout=30
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -106,64 +106,42 @@ getarg 'rdbreak=initqueue' && emergency_shell "Break before initqueue"
|
|||
|
||||
i=0
|
||||
while :; do
|
||||
# bail out, if we have mounted the root filesystem
|
||||
[ -d "$NEWROOT/proc" ] && break;
|
||||
|
||||
# check if root can be mounted
|
||||
[ -e /dev/root ] && break;
|
||||
|
||||
check_finished && break
|
||||
|
||||
udevsettle
|
||||
|
||||
# bail out, if we have mounted the root filesystem
|
||||
[ -d "$NEWROOT/proc" ] && break;
|
||||
# check if root can be mounted
|
||||
[ -e /dev/root ] && break;
|
||||
|
||||
unset queuetriggered
|
||||
check_finished && break
|
||||
|
||||
if [ -f /initqueue/work ]; then
|
||||
rm /initqueue/work
|
||||
queuetriggered="1"
|
||||
fi
|
||||
|
||||
for job in /initqueue/*.sh; do
|
||||
[ -e "$job" ] || break
|
||||
job=$job . $job
|
||||
|
||||
# bail out, if we have mounted the root filesystem
|
||||
[ -d "$NEWROOT/proc" ] && break;
|
||||
# check if root can be mounted
|
||||
[ -e /dev/root ] && break;
|
||||
check_finished && break 2
|
||||
done
|
||||
|
||||
[ -n "$queuetriggered" ] && continue
|
||||
$UDEV_QUEUE_EMPTY >/dev/null 2>&1 || continue
|
||||
|
||||
if $UDEV_QUEUE_EMPTY >/dev/null 2>&1; then
|
||||
modprobe scsi_wait_scan && rmmod scsi_wait_scan
|
||||
|
||||
modprobe scsi_wait_scan && rmmod scsi_wait_scan
|
||||
$UDEV_QUEUE_EMPTY >/dev/null 2>&1 || continue
|
||||
|
||||
$UDEV_QUEUE_EMPTY >/dev/null 2>&1 || continue
|
||||
for job in /initqueue-settled/*.sh; do
|
||||
[ -e "$job" ] || break
|
||||
job=$job . $job
|
||||
check_finished && break 2
|
||||
done
|
||||
|
||||
unset queuetriggered
|
||||
for job in /initqueue-settled/*.sh; do
|
||||
[ -e "$job" ] || break
|
||||
$UDEV_QUEUE_EMPTY >/dev/null 2>&1 || continue
|
||||
|
||||
queuetriggered="1"
|
||||
|
||||
job=$job . $job
|
||||
|
||||
# bail out, if we have mounted the root filesystem
|
||||
[ -d "$NEWROOT/proc" ] && break 2;
|
||||
|
||||
# check if root can be mounted
|
||||
[ -e /dev/root ] && break 2;
|
||||
done
|
||||
|
||||
# no more udev jobs and queues empty.
|
||||
sleep 0.5
|
||||
i=$(($i+1))
|
||||
[ $i -gt 20 ] \
|
||||
&& { flock -s 9 ; emergency_shell "No root device found"; } 9>/.console_lock
|
||||
fi
|
||||
# no more udev jobs and queues empty.
|
||||
sleep 0.5
|
||||
i=$(($i+1))
|
||||
[ $i -gt 20 ] \
|
||||
&& { flock -s 9 ; emergency_shell "No root device found"; } 9>/.console_lock
|
||||
done
|
||||
unset job
|
||||
unset queuetriggered
|
||||
|
|
|
|||
|
|
@ -9,6 +9,7 @@ fi
|
|||
inst "$moddir/init" "/init"
|
||||
inst "$moddir/initqueue" "/sbin/initqueue"
|
||||
mkdir -p ${initdir}/initqueue
|
||||
mkdir -p ${initdir}/initqueue-finished
|
||||
mkdir -p ${initdir}/initqueue-settled
|
||||
mkdir -p ${initdir}/tmp
|
||||
# Bail out if switch_root does not exist
|
||||
|
|
|
|||
Loading…
Reference in New Issue