lprsetup.sh 4.6 KB

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