</section>
<section>
<title>Main Loop</title>
- <para>Now the main loop of <command>99base/init</command> begins. Here we loop until <command>udev</command> has settled and all scripts in <filename>initqueue-finished</filename> returned true. In this loop there are three hooks, where scripts can be inserted by calling <command>/sbin/initqueue</command>.
+ <para>Now the main loop of <command>99base/init</command> begins. Here we loop until <command>udev</command> has settled and all scripts in <filename>initqueue/finished</filename> returned true. In this loop there are three hooks, where scripts can be inserted by calling <command>/sbin/initqueue</command>.
</para>
<section>
<title>Initqueue</title>
<title>Initqueue settled</title>
<para>This hooks gets executed every time <command>udev</command> has settled.</para>
</section>
+ <section>
+ <title>Initqueue timeout</title>
+ <para>This hooks gets executed, when the main loop counter becomes half of the rd.retry counter.</para>
+ </section>
<section>
<title>Initqueue finished</title>
<para>This hook is called after <command>udev</command> has settled and if all scripts herein return <errorcode>0</errorcode> the main loop will be ended.</para>
<para><function>install()</function>:</para>
<programlisting>inst_hook cmdline 20 "$moddir/parse-insmodpost.sh"
inst_simple "$moddir/insmodpost.sh" /sbin/insmodpost.sh</programlisting>
- <para>The <filename>pase-instmodpost.sh</filename> parses the kernel command line for a argument <envar>rd.driver.post</envar>, blacklists the module from being autoloaded and installs the hook <filename>insmodpost.sh</filename> in the <filename>initqueue-settled</filename>.</para>
+ <para>The <filename>pase-instmodpost.sh</filename> parses the kernel command line for a argument <envar>rd.driver.post</envar>, blacklists the module from being autoloaded and installs the hook <filename>insmodpost.sh</filename> in the <filename>initqueue/settled</filename>.</para>
<para><filename>parse-insmodpost.sh</filename>:</para>
<programlisting>for p in $(getargs rd.driver.post=); do
echo "blacklist $p" >> /etc/modprobe.d/initramfsblacklist.conf
[ -n "$_do_insmodpost" ] && /sbin/initqueue --settled --unique --onetime /sbin/insmodpost.sh
unset _do_insmodpost
</programlisting>
- <para><filename>insmodpost.sh</filename>, which is called in the <filename>initqueue-settled</filename> hook will just modprobe the kernel modules specified in all <envar>rd.driver.post</envar> kernel command line parameters. It runs after <command>udev</command> has settled and is only called once (<parameter>--onetime</parameter>).</para>
+ <para><filename>insmodpost.sh</filename>, which is called in the <filename>initqueue/settled</filename> hook will just modprobe the kernel modules specified in all <envar>rd.driver.post</envar> kernel command line parameters. It runs after <command>udev</command> has settled and is only called once (<parameter>--onetime</parameter>).</para>
<para><filename>insmodpost.sh</filename>:</para>
<programlisting>. /lib/dracut-lib.sh
RDRETRY=$(getarg rd.retry 'rd_retry=')
RDRETRY=${RDRETRY:-20}
RDRETRY=$(($RDRETRY*2))
-
-i=0
+export RDRETRY
+main_loop=0
+export main_loop
while :; do
check_finished && break
fi
done
- i=$(($i+1))
- [ $i -gt $RDRETRY ] \
+ if [ $main_loop -gt $(($RDRETRY/2)) ]; then
+ for job in $hookdir/initqueue/timeout/*.sh; do
+ [ -e "$job" ] || break
+ job=$job . $job
+ main_loop=0
+ done
+ fi
+
+ main_loop=$(($main_loop+1))
+ [ $main_loop -gt $RDRETRY ] \
&& { flock -s 9 ; emergency_shell "No root device \"$root\" found"; } 9>/.console_lock
done
unset job
unset queuetriggered
+unset main_loop
+unset RDRETRY
# reset cdrom polling
for cdrom in /sys/block/sr*; do
mkdir -m 0755 -p ${initdir}/lib/dracut
mkdir -m 0755 -p ${initdir}/lib/dracut/hooks
for _d in $hookdirs emergency \
- initqueue initqueue/finished initqueue/settled; do
+ initqueue initqueue/timeout initqueue/finished initqueue/settled; do
mkdir -m 0755 -p ${initdir}/lib/dracut/hooks/$_d
done