#/sbin/sh
#
# This file moves the files into place for running q4 and optionally 
# run q4pxdb on the kernel.
# 
# This script is developed by Kent M. Ostby.
# 
# Check usage

if [ $# -gt 1 ]
then 
  echo "usage: q4prep [-p] "
  echo "Use the '-p' option to run q4pxdb on your kernel during the prep process." 
  exit
fi
if   [ $# -eq 1 ] && [ $1 != "-p" ] 
then
    echo "usage: q4prep [-p] "
    echo "Use the '-p' option to run q4pxdb on your kernel during the prep process." 
    exit
fi
savedir=`pwd`
cd /usr/contrib/lib
if [ -f Q4Lib.tar.Z ]
then
uncompress Q4Lib.tar.Z
fi
cd $savedir
if [ -f /usr/contrib/lib/Q4Lib.tar ]
then
  tar -xf /usr/contrib/lib/Q4Lib.tar
  if [ ! -f ~/.q4rc.pl ] 
  then
  cp q4lib/sample.q4rc.pl ~/.q4rc.pl
  fi
  echo "q4 library files being created  in " `pwd`"/q4lib"
  if [ $# -eq 1 ]
  then 
    echo " "
    echo "Preparing kernel with q4pxdb... this may take several seconds"
    /usr/contrib/bin/q4pxdb vmunix
    echo " "
    echo "You may run q4 when ready"
  else
    echo " "
    echo "you may run q4pxdb(if necessary) and q4 when ready"
  fi
else
  echo "This system is not set up to run Q4. Error occurred"
  exit
fi

