#------------------------------------------------------------------------------
# /etc/rc.d/rc990.menu - prepare bootmenu
#
# Creation:    12.11.2003 tobig
# Last Update: $Id: rc990.menu 10644 2005-12-18 11:12:59Z arwin $
#------------------------------------------------------------------------------

if [ "$OPT_MENU" = yes ]
then
    begin_script MENU "preparing MENU ..."
    if [ "$MENU_LANGUAGE" = "" ]
    then    
        echo "$LOCALE" > /var/run/menu.lang
    else
        echo "$MENU_LANGUAGE" > /var/run/menu.lang
    fi       

    a=1
    b=1
    for i in /etc/menu/*
    do
        # save german menu entries
        message="`grep "# de:" $i | cut -f 2 -d :`"
        if [ "$message" = "" ]
        then
            default="`grep "# default:" $i | cut -f 2 -d :`"
            message="`grep "# $default:" $i | cut -f 2 -d :`"
        fi
        echo "$a:$message:$i" >>/var/run/menu.de."$b"

        # save english menu entries
        message="`grep "# en:" $i | cut -f 2 -d :`"
        if [ "$message" = "" ]
        then
            default="`grep "# default:" $i | cut -f 2 -d :`"
            message="`grep "# $default:" $i | cut -f 2 -d :`"
        fi
        echo "$a:$message:$i" >>/var/run/menu.en."$b"

        # save french menu entries
        message="`grep "# fr:" $i | cut -f 2 -d :`"
        if [ "$message" = "" ]
        then
            default="`grep "# default:" $i | cut -f 2 -d :`"
            message="`grep "# $default:" $i | cut -f 2 -d :`"
        fi
        echo "$a:$message:$i" >>/var/run/menu.fr."$b"

        # save dutch menu entries
        message="`grep "# nl:" $i | cut -f 2 -d :`"
        if [ "$message" = "" ]
        then
            default="`grep "# default:" $i | cut -f 2 -d :`"
            message="`grep "# $default:" $i | cut -f 2 -d :`"
        fi
        echo "$a:$message:$i" >>/var/run/menu.nl."$b"

        if [ "$a" = "9" ]
        then
            a=1
            b=`expr $b + 1`
        else
            a=`expr $a + 1`
        fi
    done

    cat <<TEXTENDE >>/.profile

tty > /dev/null
if [ "\$?" = "0" ]
then
    . /usr/local/bin/menu.sh
fi
TEXTENDE
    end_script
fi
