#!/bin/sh
T_PX=$1
if [ "$COLOR" = "on" -o -r /tmp/SeTcolor ]; then
 dialog --title "GPM CONFIGURATION" --yesno \
"gpm 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\
    gpm -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.  If XFree86 refuses to start and complains that it\n\
cannot open the mouse then you might want to comment the line\n\
out of /etc/rc.d/rc.local.  Would you like to add\n\
\n\
    gpm -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 gpm" $T_PX/etc/rc.d/rc.local 1> /dev/null 2> /dev/null ; then
   echo > /dev/null
  else
   echo "# Running gpm" >> $T_PX/etc/rc.d/rc.local
   echo 'echo "Running gpm..."' >> $T_PX/etc/rc.d/rc.local
   echo "gpm -t $MTYPE &" >> $T_PX/etc/rc.d/rc.local
  fi
 fi
else # no color!
 cat << EOF
Configuration of 'gpm':

"gpm" 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 "gpm -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.
If XFree86 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 "gpm -t $MTYPE &" to /etc/rc.d/rc.local so that
EOF
 echo -n "gpm 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 gpm" $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 gpm" >> $T_PX/etc/rc.d/rc.local
    echo 'echo "Running gpm..."' >> $T_PX/etc/rc.d/rc.local
    echo "gpm -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
