#!/bin/sh
# $Id: dbman,v 1.3 1999/04/30 16:13:47 henryk Exp $
# dbman add or remove Lexmark entries from RedHat's printtool
#       printer database.
# Written by Henryk Paluch. Based on idea of Peter Samuel
#

prdb=/usr/lib/rhs/rhs-printfilters/printerdb
#prdb=printerdb

# subroutines
addlexmark()
{
cat >> $prdb << .EOF.

##LEXMARKDRVSTART
# Lexmark 7000, 7200
StartEntry: Lexmark7000
    GSDriver: lex7000
    Description: {Lexmark 7000, 7200 BW}
    About: { \\
	     This driver supports the Lexmark 7000, 7200 and 5000 ink \\
             "GDI" printers. It prints Black and White only. \\
            Do *NOT* check 'Fast Text Printing' field. \\
	   }
    Resolution: {300} {300} {}
    Resolution: {600} {600} {tested}
    Resolution: {1200} {1200} {}
    BitsPerPixel: {1} {Normal B&W printing}
EndEntry
StartEntry: Lexmark5700
    GSDriver: lex5700
    Description: {Lexmark 5700 BW}
    About: { \\
	     This driver supports the Lexmark 5700 ink \\
             "GDI" printers. It prints Black and White only. \\
            Do *NOT* check 'Fast Text Printing' field. \\
	   }
    Resolution: {300} {300} {}
    Resolution: {600} {600} {tested}
    Resolution: {1200} {1200} {}
    BitsPerPixel: {1} {Normal B&W printing}
EndEntry
#
##LEXMARKDRVEND

.EOF.
}

removelexmark()
{
  sed '/LEXMARKDRVSTART$/,/LEXMARDRVEND$/d' < $prdb > $prdb.new
  mv -f $prdb $prdb.old
  mv -f $prdb.new $prdb
}

### MAIN ###
if [ $# != 1 ];then
  echo "Usage: $0  [ -i ] | [ -e ]"
  echo "     -i    install Lexmark entries to $prdb"
  echo "     -e    erase Lexmark entries from $prdb"
  exit 1
fi

if [ ! -w $prdb ];then
  echo "Can not modify $prdb"
  exit 1
fi


case $1 in
       -i)
        removelexmark
        addlexmark
        ;;
       -e)
        removelexmark
        ;;
       *)
        echo "Unknown option $1";
        exit 1
        ;;
esac



