#!/bin/sh

PREREQ=""
prereqs()
{
	echo "$PREREQ"
}
case $1 in
# get pre-requisites
prereqs)
	prereqs
	exit 0
	;;
esac

silent()
{
	if test -c /dev/null; then
		"$@" >/dev/null 2>&1
	else
		"$@" 2>&1 | read dummyvar
	fi
}

test -x /sbin/splashy || exit
SPLASH=false
SINGLE=false
FBMODESET=false
for x in $(cat /proc/cmdline); do
    case $x in
        single)
            SINGLE=true
        ;;
        splash)
            SPLASH=true
        ;;
        nosplash)
            SPLASH=false
        ;;
        vga=*|video=*)
            FBMODESET=true
        ;;
    esac
done
test $SINGLE = "false" || exit
test $SPLASH = "true" || exit
test $FBMODESET = "true" || exit

depmod -a
silent modprobe fbcon
silent modprobe vesafb

if [ -s /proc/fb ]; then
        while read fbno desc; do
                mknod /dev/fb${fbno} c 29 ${fbno}
        done < /proc/fb
else
        mknod /dev/fb0 c 29 0
fi

for i in 0 1 2 3 4 5 6 7 8; do
	test -c /dev/tty${i} || \
            mknod /dev/tty${i} c 4 ${i}
done

if [ -x /sbin/splashy_chvt ]; then
	/sbin/splashy_chvt 8
fi

# if resume is set we assume Splashy starts from there by uswsusp or
# similar software:
if [ "x${resume}" != "x" ]; then
	exit
fi

/sbin/splashy boot

