[17625] | 1 | #!/bin/sh
|
---|
| 2 | # $Id: lprsetup.sh 6300 2005-12-28 19:56:24Z giles $
|
---|
| 3 | #
|
---|
| 4 | # BSD PRINT FILTER SETUP utility for Ghostscript - used and tested on
|
---|
| 5 | # SunOS 4.1.3, but I hope it will be useful on other BSD systems
|
---|
| 6 | # See documentation for usage
|
---|
| 7 | #
|
---|
| 8 |
|
---|
| 9 | DEVICES="bjt600.32 bjc600.32 bjc600.24 bjc600.24.3 bjc600.16 bjc600.8 bjc600.8.1 bjc600.1 bjc600.dq"
|
---|
| 10 | #FILTERS="if nf tf gf vf df cf rf"
|
---|
| 11 | FILTERS="if"
|
---|
| 12 |
|
---|
| 13 | # The port your printer is on
|
---|
| 14 | PRINTERDEV=/dev/lp1
|
---|
| 15 | # The kind of printer (accepted values: 'parallel' and 'serial')
|
---|
| 16 | PRINTERTYPE=parallel
|
---|
| 17 |
|
---|
| 18 | GSDIR=/usr/local/lib/ghostscript
|
---|
| 19 | GSFILTERDIR=$GSDIR/filt
|
---|
| 20 | SPOOLDIR=/var/spool
|
---|
| 21 | GSIF=unix-lpr.sh
|
---|
| 22 | PCAP=printcap.insert
|
---|
| 23 |
|
---|
| 24 | PATH=/bin:/usr/bin:/usr/ucb
|
---|
| 25 | export PATH
|
---|
| 26 |
|
---|
| 27 | if [ ! -w $GSDIR ]; then
|
---|
| 28 | echo "$GSDIR must be writable to create filter directory"
|
---|
| 29 | exit 1
|
---|
| 30 | fi
|
---|
| 31 |
|
---|
| 32 | echo "
|
---|
| 33 | Making links in the filter directory $GSFILTERDIR ...
|
---|
| 34 | "
|
---|
| 35 |
|
---|
| 36 | #
|
---|
| 37 | # Make the directory for holding the filter and links
|
---|
| 38 | #
|
---|
| 39 | if [ -d $GSFILTERDIR ]; then
|
---|
| 40 | echo "$GSFILTERDIR already exists - not created"
|
---|
| 41 | else
|
---|
| 42 | mkdir $GSFILTERDIR
|
---|
| 43 | fi
|
---|
| 44 | rm -f $GSFILTERDIR/direct
|
---|
| 45 | ln -s . $GSFILTERDIR/direct
|
---|
| 46 | rm -f $GSFILTERDIR/indirect
|
---|
| 47 | ln -s . $GSFILTERDIR/indirect
|
---|
| 48 |
|
---|
| 49 | #
|
---|
| 50 | # Create a link from each filtertype to the real filter script
|
---|
| 51 | #
|
---|
| 52 | for filter in $FILTERS
|
---|
| 53 | do
|
---|
| 54 | rm -f $GSFILTERDIR/gs$filter
|
---|
| 55 | ln -s ../$GSIF $GSFILTERDIR/gs$filter
|
---|
| 56 | done
|
---|
| 57 |
|
---|
| 58 | #
|
---|
| 59 | # Create a link from each device to the filter directory
|
---|
| 60 | #
|
---|
| 61 | for device in $DEVICES
|
---|
| 62 | do
|
---|
| 63 | dualqueue=
|
---|
| 64 | case "$device" in
|
---|
| 65 | *.dq) device=`basename $device .dq` ; dualqueue=t ;;
|
---|
| 66 | esac
|
---|
| 67 | rm -f $GSFILTERDIR/$device
|
---|
| 68 | if [ $dualqueue ]; then
|
---|
| 69 | rm -f $GSFILTERDIR/indirect/$device
|
---|
| 70 | ln -s . $GSFILTERDIR/indirect/$device
|
---|
| 71 | else
|
---|
| 72 | rm -f $GSFILTERDIR/direct/$device
|
---|
| 73 | ln -s . $GSFILTERDIR/direct/$device
|
---|
| 74 | fi
|
---|
| 75 | done
|
---|
| 76 |
|
---|
| 77 | #
|
---|
| 78 | # Create a basic printcap insert - this is made in the CURRENT directory
|
---|
| 79 | #
|
---|
| 80 | rm -f $PCAP
|
---|
| 81 | cat > $PCAP << EOF
|
---|
| 82 | # This is an example printcap insert for Ghostscript printers
|
---|
| 83 | # You will probably want either to change the names for each printer
|
---|
| 84 | # below (first line for each device) to something more sensible, or
|
---|
| 85 | # to add additional name entries (eg cdjcolor for cdj500.24)
|
---|
| 86 | # The example is shown set up for $PRINTERTYPE printers - you will need
|
---|
| 87 | # to alter the entries for different or networked remote printer,
|
---|
| 88 | # eg. a remote network printer would have a line something like:
|
---|
| 89 | # :lp=:rm=artemis:rp=LPT1:
|
---|
| 90 | # for a PC called artemis, replacing the serial port settings
|
---|
| 91 | #
|
---|
| 92 | # NB/ This is only an example - it is unlikely to be complete or exactly
|
---|
| 93 | # correct for your system, but is designed to illustrate filter names
|
---|
| 94 | # corresponding to the accompanying bsd-if print filter
|
---|
| 95 | #
|
---|
| 96 | EOF
|
---|
| 97 |
|
---|
| 98 | (
|
---|
| 99 | previous=undefined
|
---|
| 100 | for device in $DEVICES
|
---|
| 101 | do
|
---|
| 102 | dualqueue=
|
---|
| 103 | case "$device" in
|
---|
| 104 | *.dq) device=`basename $device .dq` ; dualqueue=t ;;
|
---|
| 105 | esac
|
---|
| 106 | base="`echo $device | sed 's/\.[0-9][0-9]*$//'`"
|
---|
| 107 | base="`echo $base | sed 's/\.[0-9][0-9]*$//'`"
|
---|
| 108 | #
|
---|
| 109 | # If device listed with '.dq' suffix, we set up a separate output queue
|
---|
| 110 | #
|
---|
| 111 | if [ $dualqueue ]; then
|
---|
| 112 | if [ $base != $previous ]; then
|
---|
| 113 | previous=$base
|
---|
| 114 | echo "\
|
---|
| 115 | # Entry for raw device $base.raw
|
---|
| 116 | $base.raw|Raw output device $base:\\
|
---|
| 117 | :lp=$PRINTERDEV:\\"
|
---|
| 118 | if test "$PRINTERTYPE" = serial
|
---|
| 119 | then
|
---|
| 120 | echo "br#19200:xc#0177777:\\"
|
---|
| 121 | echo ":ms=-parity,ixon,-opost:\\"
|
---|
| 122 | fi
|
---|
| 123 | echo ":sd=$SPOOLDIR/$base/raw:\\
|
---|
| 124 | :mx#0:sf:sh:rs:"
|
---|
| 125 | fi
|
---|
| 126 | echo "\
|
---|
| 127 | # Entry for device $device (output to $base.raw)
|
---|
| 128 | $device|Ghostscript device $device:\\
|
---|
| 129 | :lp=/dev/null:\\"
|
---|
| 130 | else
|
---|
| 131 | echo "\
|
---|
| 132 | # Entry for device $device
|
---|
| 133 | $device|Ghostscript device $device:\\
|
---|
| 134 | :lp=$PRINTERDEV:\\"
|
---|
| 135 | if test "$PRINTERTYPE" = serial
|
---|
| 136 | then
|
---|
| 137 | echo "br#19200:xc#0177777:\\"
|
---|
| 138 | echo ":ms=-parity,ixon,-opost:\\"
|
---|
| 139 | fi
|
---|
| 140 | fi
|
---|
| 141 | echo "\
|
---|
| 142 | :sd=$SPOOLDIR/$base:\\
|
---|
| 143 | :lf=$SPOOLDIR/$base/logfile:\\
|
---|
| 144 | :af=$SPOOLDIR/$base/acct:\\"
|
---|
| 145 | for filter in $FILTERS
|
---|
| 146 | do
|
---|
| 147 | if [ $dualqueue ]; then
|
---|
| 148 | echo "\
|
---|
| 149 | :$filter=$GSFILTERDIR/indirect/$device/gs$filter:\\"
|
---|
| 150 | else
|
---|
| 151 | echo "\
|
---|
| 152 | :$filter=$GSFILTERDIR/direct/$device/gs$filter:\\"
|
---|
| 153 | fi
|
---|
| 154 | done
|
---|
| 155 | echo "\
|
---|
| 156 | :mx#0:sf:sh:rs:"
|
---|
| 157 | done
|
---|
| 158 | ) >> $PCAP
|
---|
| 159 |
|
---|
| 160 | echo "
|
---|
| 161 | Example printcap insert file \"$PCAP\" now created"
|
---|
| 162 |
|
---|
| 163 | #
|
---|
| 164 | # Remind the user what's still to do
|
---|
| 165 | #
|
---|
| 166 |
|
---|
| 167 | echo "
|
---|
| 168 | NB/ You will need to create the following directories, with
|
---|
| 169 | appropriate permissions, and do 'touch logfile' and 'touch acct'
|
---|
| 170 | in the top level directories (ie. not the 'raw' ones):
|
---|
| 171 | "
|
---|
| 172 | (
|
---|
| 173 | for device in $DEVICES
|
---|
| 174 | do
|
---|
| 175 | dualqueue=
|
---|
| 176 | case "$device" in
|
---|
| 177 | *.dq) device=`basename $device .dq` ; dualqueue=t ;;
|
---|
| 178 | esac
|
---|
| 179 | base="`echo $device | sed 's/\.[0-9][0-9]*$//'`"
|
---|
| 180 | base="`echo $base | sed 's/\.[0-9][0-9]*$//'`"
|
---|
| 181 | echo " $SPOOLDIR/$base"
|
---|
| 182 | if [ $dualqueue ]; then
|
---|
| 183 | echo " $SPOOLDIR/$base/raw"
|
---|
| 184 | fi
|
---|
| 185 | done
|
---|
| 186 | ) | sort -u
|
---|
| 187 |
|
---|
| 188 | echo "
|
---|
| 189 | + + + "
|
---|