#!/bin/sh
T_PX=$1
if [ "$COLOR" = "on" -o -r /tmp/SeTcolor ]; then
 dialog --title "SELECTION 1.5 CONFIGURATION" --yesno \
"Selection is a program that allows you to do cut and paste\n\
on the virtual consoles using a mouse. If you choose to\n\
have it run at boot time, the line:\n\
\n\
    selection -t $MTYPE &\n\
\n\
will be added to the end of your /etc/rc.d/rc.local.\n\
\n\
Running selection with a bus mouse can cause problems with\n\
XFree86 2.0.  If XFree86 2.0 refuses to start and complains\n\
that it cannot open the mouse then you might want to comment\n\
the line out of /etc/rc.d/rc.local.  Would you like to add\n\
\n\
    selection -t $MTYPE &\n\
\n\
to /etc/rc.d/rc.local so that selection will load at boot\n\
time?" 22 65
 if [ $? = 0 ]; then
  if fgrep "Running sele" $T_PX/etc/rc.d/rc.local 1> /dev/null 2> /dev/null ; then
   echo > /dev/null
  else
   echo "# Running selection" >> $T_PX/etc/rc.d/rc.local
   echo 'echo "Running selection..."' >> $T_PX/etc/rc.d/rc.local
   echo "selection -t $MTYPE &" >> $T_PX/etc/rc.d/rc.local
  fi
 fi
else # no color!
 cat << EOF
Configuration of 'Selection 1.5':

"Selection" is a program that allows you to do cut and paste on the
virtual consoles using a mouse. If you choose to have it run at boot
time, the line "selection -t $MTYPE &" will be added to the end of
your /etc/rc.d/rc.local.

Running selection with a bus mouse can cause problems with XFree86 2.0.
If XFree86 2.0 refuses to start and complains that it cannot open the
mouse then you might want to comment the line out of /etc/rc.d/rc.local.

Would you like to add "selection -t $MTYPE &" to /etc/rc.d/rc.local so that
EOF
 echo -n "selection will load at boot time ([y]es, [n]o)? "
 while [ 0 ]; do
  read SL;
  if [ "$SL" = "y" ]; then
   echo
   echo "Configuring selection..."
   if fgrep "Running sele" $T_PX/etc/rc.d/rc.local 1> /dev/null 2> /dev/null ; then
    echo 
    echo "Already found in /etc/rc.d/rc.local. Skipping..."
   else
    echo "# Running selection" >> $T_PX/etc/rc.d/rc.local
    echo 'echo "Running selection..."' >> $T_PX/etc/rc.d/rc.local
    echo "selection -t $MTYPE &" >> $T_PX/etc/rc.d/rc.local
   fi
   echo
   break;
  elif [ "$SL" = "n" ]; then
   echo
   break;
  fi
  echo
  echo "Unknown response. Answer y or n."
 done
fi
