#/bin/sh
#This Shell Script Will Install Postscript Printing 
#For HP Deskjet Printers and Textfile Filters
#by: Todd Burgess (tburgess@uoguelph.ca)

echo This Will Install Postscript and Text Filters for HP Deskjet Printers
echo
echo -n "Do you want to continue? [Y/n] " 
read answer
if [ "$answer" = "n" ]; then
  exit 1 
fi

echo -n "Should I back-up the current /etc/printcap ? [Y/n] "
read answer

if [ "$answer" != "n" ]; then
  echo -n "Enter the file to save to [/etc/printcap.bak]: "
  read answer 
  if [ -z $answer ]; then
    cp /etc/printcap /etc/printcap.bak
  else
    cp /etc/printcap $answer
  fi
fi
echo Creating New /etc/printcap
cp printcap /etc/printcap

echo Copying Print Filters to /usr/local/bin
cp psjetfilter /usr/local/bin/psjetfilter
cp lpfilter /usr/local/bin/lpfilter

echo Creating Spool Directories
mkdir /var/spool/lpd/lp
mkdir /var/spool/lpd/psjet
 
echo Checking GID for Spool Directories
chgrp lp /var/spool/lpd/lp
chgrp lp /var/spool/lpd/psjet

echo Checking Permissions for Spool Directories
chmod 775 /var/spool/lpd/lp
chmod 775 /var/spool/lpd/psjet

echo Checking Permissions for Print Filters
chmod 755 /usr/local/bin/lpfilter
chmod 755 /usr/local/bin/psjetfilter

echo
echo All Done!

