DIALOG=/usr/bin/dialog
$DIALOG --backtitle "Vesa Frame Buffer Configuration - Red Hat, Inc. (c) 2000" --clear \
        --title "Resolution Selection" \
        --radiolist "
Press SPACE to select a resolution.\
" 13 41 5 \
640x480 "" on \
800x600 "" off \
1024x768 "" off \
1280x1024 "" off \
1600x1200 "" off 2>/tmp/fbconf

res=`cat /tmp/fbconf`

case $? in
        1) exit ;;
        255) exit ;;
        *);;
esac

if [ -s /tmp/fbconf ]; then

$DIALOG --backtitle "Vesa Frame Buffer Configuration - Red Hat, Inc. (c) 2000" --clear \
        --title "Color Depth Selection" \
        --radiolist "
Press SPACE to select a color depth.\
" 12 41 4 \
8 "256 Colors" on \
15 "32K Colors" off \
16 "64K Colors" off \
24 "16.7 Million Colors" off 2>/tmp/fbconf

depth=`cat /tmp/fbconf`

case $? in
        1) exit ;;
        255) exit ;;
        *);;
esac

if [ -s /tmp/fbconf ]; then

images=`cat -n /etc/lilo.conf | grep -v \# | grep image | awk ' { print $1; } '`
COUNT=2
for i in $images
do
        NEXT=`echo $images | awk ' { print $'$COUNT'; } '`
        COUNT=`expr $COUNT + 1`
        if [ "$NEXT" = "" ] ; then
                STOP=",NR==2048"
        else
                NEXT=`expr $NEXT - 1`
                STOP=",NR=="$NEXT
        fi
        newlabel=`cat -n /etc/lilo.conf | grep -v \# | awk ' NR=='$i''$STOP' { print $0; } ' | awk -F\= ' /label=/ { print $2; } '`
        label=`echo $label $newlabel`
done
COUNT=1
status="on"
for i in $label
do
	labeltitle=`echo $label | awk ' { print $'$COUNT'; } '`
	new_image=`echo $labeltitle "Image"$COUNT $quote $status`
	images_list=`echo $images_list $new_image` 
	COUNT=`expr $COUNT + 1`
	status="off"
done

if [ -s /tmp/fbconf ]; then

$DIALOG --backtitle "Vesa Frame Buffer Configuration - Red Hat, Inc. (c) 2000" --clear \
        --title "Kernel Image Selection" \
        --radiolist "
Press SPACE to the select the lilo
image for the FrameBuffer Console.\
" 16 43 8 \
`echo $images_list` 2>/tmp/fbconf

image=`cat /tmp/fbconf`

case $? in
        1) exit ;;
        255) exit ;;
        *);;
esac

if [ -s /tmp/fbconf ];then 

$DIALOG --backtitle "Vesa Frame Buffer Configuration - Red Hat, Inc. (c) 2000" --clear \
        --title "Configure X Frame Buffer" \
        --yesno "\nDo you want to configure the\nFrame Buffer X Server?" 8 33 2>/tmp/fbconf

case $? in
        255) exit ;;

	0)
		clear
		echo "Configuring FrameBuffer Console and FrameBuffer X."
		echo ""
		fb_x_server
		fb_setup_x $depth
		fb_lilo $image $res $depth
	;;
	1)
		clear
		echo "Configuring FrameBuffer Console without FrameBuffer X."
		echo ""
		fb_lilo $image $res $depth
	;;
        *);;
esac
fi fi fi fi
