#!/bin/sh

# Install print filters
if [ ! -d /usr/lib/rhs/rhs-printfilters ]
then
  mkdir /usr/lib/rhs/rhs-printfilters
fi
cp -f filters/* /usr/lib/rhs/rhs-printfilters

# Notify installer that non-x86 Linux systems need to recompile rewindstdin
SYSTEM=`uname -s`
if [ ! $SYSTEM = "Linux" ]
then
  echo "** You are using a non-Linux system.  If you wish to use the built-in"
  echo "** printer drivers, you will need to compile the filters/rewindstdin.c"
  echo "** on your system.  See the README for more information on how to do so."
fi 

# Set initial permissions for security
touch /etc/lpd.conf 
if [ -f /etc/lpd.perms ]
then
  mv -f /etc/lpd.perms /etc/lpd.perms.bak
fi
cp -f lpd.perms /etc/lpd.perms

# install lprngtool in /usr/bin, if needed
cp -f lprngtool /usr/bin/
if [ ! -f /usr/bin/lpr ]
then
  ln -s /usr/bin/lp /usr/bin/lpr
fi

# link printtool, if needed
if [ ! -s /usr/bin/printtool ]
then
  if [ -f /usr/bin/printtool ]
  then
    mv -f /usr/bin/printtool /usr/bin/printtool.lpr
    ln -s /usr/bin/lprngtool /usr/bin/printtool
  fi
fi

# Set the default lprngtool.conf file, if not already defined
if [ -f /etc/lprngtool.conf ]
then
  cp lprngtool.conf /etc/lprngtool.conf
fi

echo "Please run 'lprngtool' now to set up printers and print queues."

