#!/bin/sh

if [ ! $DISPLAY = "" ]; then
DCMD="Xdialog --wrap" 
CMD="rxvt -e "
else
DCMD="dialog"
CMD=""
fi


TMP=/var/log/setup/tmp
if [ ! -d $TMP ]; then

mkdir -p $TMP
fi

while [ 0 ]; do

$DCMD --backtitle "Vector Linux ...at the speed of light." --title "XBOOT Boot configuration setup" \
--menu \
"Welcome to Vector Linux's Boot Mode menu.\n\
CAUTION - Make Sure you have tested X before choosing GUI mode.\n\
 Use the cursor or [+] [-] keys to navigate the menu.\n\
 Press the [enter] key  to make a selection."  18 76 7 \
"GUI"    "Setup the system to boot directly into GUI mode ......" \
"TEXT"   "Setup the system to boot into normal TEXT mode  ......" \
"EXIT"   "To quit the XBOOT Setup .............................." 2> $TMP/xpick
 if [ $? = 1 -o $? = 255 ]; then
  rm -f $TMP/xpick
 clear
  exit 0
 fi
 MAINSELECT="`cat $TMP/xpick`"
 rm -f $TMP/xpick

  if [ "$MAINSELECT" = "GUI" ]; then
    cat /etc/inittab | while read LINE; do
    if echo $LINE | grep initdefault 1> /dev/null ; then
    echo "id:5:initdefault:" >> /etc/inittab.new
    else
    echo $LINE >> /etc/inittab.new
    fi
    done
    mv /etc/inittab.new /etc/inittab

$DCMD --title "GUI BOOT ACTIVATED" \
 --msgbox "The System will boot directly to GUI mode on \
the next boot of the system." 10 60
  fi
  if [ "$MAINSELECT" = "TEXT" ]; then
    cat /etc/inittab | while read LINE; do
    if echo $LINE | grep initdefault 1> /dev/null ; then
    echo "id:2:initdefault:" >> /etc/inittab.new
    else
    echo $LINE >> /etc/inittab.new
    fi
    done
    mv /etc/inittab.new /etc/inittab

$DCMD --title "TEXT BOOT ACTIVATED" \
 --msgbox "The System will boot to normal TEXT mode on \
the next boot of the system." 10 60
  fi

  if [ "$MAINSELECT" = "EXIT" ]; then
  break
  fi
  done
  clear
   exit 0

