#!/bin/sh

mkdir /dev/.initramfs
/bin/showenv > /dev/.initramfs/kern

exec </dev/console >/dev/console 2>&1

. /scripts/functions

for f in /lib/initrd/modules/*; do
	m="${f#*-}"
	[ -x "$f" -a -n "$m" ] ||
		continue

	[ -z "$IGNORE" ] || [ -n "${IGNORE##*,$m,*}" ] ||
		continue

	run_scripts "pre/$m"

	. "$f"
	[ -z "$msg" ] ||
		verbose "$msg"

	[ -z "$STOP" ] || [ "$STOP" != ',all,' -a -n "${STOP##*,$m,*}" ] ||
		shell

	run_module "$m" "$@" ||
		shell "Stage '$m' failed"

	run_scripts "post/$m"
done
