"Fossies" - the Fresh Open Source Software Archive

Member "apsfilter/SETUP.in" (9 Jul 2006, 67029 Bytes) of archive /linux/misc/old/apsfilter-7.2.8.tar.gz:


As a special service "Fossies" has tried to format the requested text file into HTML format (style: standard) with prefixed line numbers. Alternatively you can here view or download the uninterpreted source code file.

    1 #! @shell@
    2 # -*- sh -*-
    3 
    4 #
    5 # $ApsCVS: src/apsfilter/SETUP.in,v 1.123.2.20 2006/07/09 15:54:22 andreas Exp $
    6 #
    7 # apsfilter setup tool
    8 #
    9 # written by Andreas Klemm <andreas@apsfilter.org>
   10 # modified for V6.0 by Michael Loßin <phallobst@web.de>
   11 #
   12 
   13 #
   14 # exit status 0 on successfull printer installation
   15 # exit status 1 indicates failures or if the user simply quit the program
   16 #
   17 
   18 umask 022
   19 
   20 PATH="/usr/local/bin:/usr/local/sbin:/usr/sbin:/sbin:/usr/bin:/bin"
   21 : ${TMPDIR:=/tmp} ${AWK:=@awk@}
   22 
   23 APS_TMPDIR="$TMPDIR/apsfilter$$"
   24 rm -rf "$APS_TMPDIR"
   25 mkdir -m 700 "$APS_TMPDIR"
   26 if [ $? -ne 0 ]; then
   27     APS_TMPDIR=`mktemp -q -d "$TMPDIR/apsfilter.XXXXXX"` || \
   28 	echo 1>&2 "SETUP error: couldn't create temporary directory"
   29     chmod 700 "$APS_TMPDIR"
   30 fi
   31 export TEMP="$APS_TMPDIR" TMPDIR="$APS_TMPDIR" PATH
   32 
   33 trap 'rm -rf "$APS_TMPDIR"' 0
   34 
   35 # on BSD systems and most other Unices lpd runs under permissions "daemon"
   36 # spooldirs have the permissions "root:daemon"
   37 # to enable lpd to read config files for remote printing
   38 # we have to use "640" as permission for the config file
   39 #
   40 PASSWD_PROTECT=640
   41 
   42 #
   43 # display text with a pager like "more"
   44 #
   45 do_pager()
   46 {
   47     case "$1" in
   48 	-)		${PAGER-more} ;;
   49 	*.Z)		zcat "$1" | ${PAGER-more} ;;
   50 	*.gz|*.z)	gzip -cd "$1" | ${PAGER-more} ;;
   51 	*)		${PAGER-more} < "$1" ;;
   52     esac
   53 }             
   54 
   55 ##############################################################################
   56 # Copyright note and license
   57 ##############################################################################
   58 do_copyright()
   59 {
   60     clear
   61     cat << !EOM
   62       _/_/                         _/_/ _/ _/   _/
   63    _/    _/ _/_/_/     _/_/_/   _/        _/ _/_/_/_/   _/_/   _/  _/_/
   64   _/_/_/_/ _/    _/ _/_/     _/_/_/_/ _/ _/   _/     _/_/_/_/ _/_/
   65  _/    _/ _/    _/     _/_/   _/     _/ _/   _/     _/       _/
   66 _/    _/ _/_/_/   _/_/_/     _/     _/ _/     _/_/   _/_/_/ _/
   67         _/
   68        _/
   69 
   70     Hi, welcome to the apsfilter setup and thanks for using apsfilter!
   71 
   72     Before we begin with the setup, I'd like to make you familiar
   73     with the apsfilters license:
   74     1. apsfilter follows the GNU public license (GPL), see COPYRIGHT
   75     2. and this little "Postcard License":
   76 
   77 	"I'd like to get a postcard from you! I'm interested in,
   78 	 who is using apsfilter, where you live, and where in the
   79 	 world apsfilter is doing it's job."
   80 
   81     Please send me an e-mail to  apsfilter-snailmail@apsfilter.org  to
   82     get my postal address; we'll get there later in this setup...
   83 
   84 !EOM
   85     echo $n "Accept license [Y|y|J|j|N|n] ? $c"; read answer
   86     echo
   87     case $answer in
   88 	Y|y|J|j)
   89 	    echo "License accepted, thanks!"
   90 	    echo
   91 	    sleep 2
   92 	    ;;
   93 	*)
   94 	    echo "License not accepted -- sorry, terminating setup..."
   95 	    exit 1
   96 	    ;;
   97     esac
   98 }
   99 
  100 ##############################################################################
  101 # Request snail mail address for "Postcard License"
  102 ##############################################################################
  103 do_request_snailmail()
  104 {
  105     clear
  106     cat << !EOM
  107     _/      _/          _/ _/                         _/_/
  108    _/_/  _/_/   _/_/_/    _/              _/_/_/   _/       _/_/_/
  109   _/  _/  _/ _/    _/ _/ _/ _/_/_/_/_/ _/       _/_/_/_/ _/    _/
  110  _/      _/ _/    _/ _/ _/            _/         _/     _/    _/
  111 _/      _/   _/_/_/ _/ _/              _/_/_/   _/       _/_/_/ _/
  112                                                             _/
  113                                                        _/_/
  114 
  115 Is Internet Mail up and running on *this* machine to request my postal
  116 address to follow the rules of the "Postcard License" ?
  117 
  118 !EOM
  119     echo $n "Request my snail mail address now [Y|y|N|n] ? $c"; read answer
  120     echo
  121     case $answer in
  122 	Y|y|J|j)
  123 	    # Find out mail address...
  124 	    while [ -z "$EMAIL_OK" ]; do
  125 		echo
  126 		echo "To what address may I send you my postal address?" 
  127 		echo "Does mail to \"$USER@$HOST\" reach you?"
  128 		echo
  129 		echo "Enter RETURN to accept or type in your"
  130 		echo $n "complete mail address: $c"; read $read_r answer
  131 		if [ -z "$answer" ]; then
  132 		    # use $USER@$HOST
  133 		    REPLYTO="$USER@$HOST"
  134 		    echo
  135 		    echo "Thanks, using $REPLYTO ..."
  136 		    sleep 2
  137 		    echo
  138 		    EMAIL_OK=true
  139 		else
  140 		    # check for fqdn and use his address
  141 		    case $answer in
  142 			*@*.*)
  143 			    REPLYTO="$answer"
  144 			    echo "using $REPLYTO ..."
  145 			    sleep 2
  146 			    EMAIL_OK=true
  147 			    ;;
  148 			*)
  149 			    echo
  150 			    echo "!!! $answer is not a valid !!!"
  151 			    echo "!!! e-mail address....     !!!"
  152 			    sleep 2
  153 			    ;;
  154 		    esac
  155 		fi
  156 	    done
  157 
  158 	    { 
  159 		echo "To: apsfilter-snailmail@apsfilter.org"
  160 		echo "Reply-To: $REPLYTO"
  161 		echo "Subject: get snailmail for apsfilter version @VERSION@"
  162 	    } | "@sendmail@" apsfilter-snailmail@apsfilter.org
  163 	    touch "$CONF_DIR/.requested_snailmail"
  164 	    ;;
  165 	*)
  166 	    echo
  167 	    echo "o.k. for now ..."
  168 	    echo
  169 	    echo "... but please don't forget to request it later ..."
  170 	    sleep 4
  171 	    ;;
  172     esac
  173 }
  174 
  175 ##############################################################################
  176 # START SEQUENCE
  177 # - introduce apsfilter, version, copyright
  178 ##############################################################################
  179 do_start()
  180 {
  181     clear
  182     cat << !EOM
  183         ================================================================
  184 			  A P S F I L T E R  V @VERSION@
  185 			*** The Unix Print Solution ***
  186         ================================================================
  187 
  188                        copyright Andreas Klemm, 1993-2002
  189 
  190                               andreas@apsfilter.org
  191 
  192 			    http://www.apsfilter.org/
  193 
  194                     ----------------------------------------
  195                       for Unix systems with BSD compatible 
  196                           line printer scheduler (lpd)
  197 				or with LPRng
  198                        FreeBSD / NetBSD / OpenBSD / BSDI
  199                         Linux and other flavours of Unix
  200                     ----------------------------------------
  201 
  202 			++++ INSTALLATION PROGRAM ++++
  203 
  204                         [ press <RETURN> to continue ]
  205 !EOM
  206     read answer
  207     clear
  208     cat << !EOM
  209         ================================================================
  210           A P S F I L T E R   S E T U P               -- PROGRAM INFO --
  211         ================================================================
  212 
  213         This SETUP script supports the user/administrator by
  214 
  215 		- configuring serial/parallel/remote printers
  216 		- creating printer spool directories as needed
  217 		- auto-creation of printcap config-file
  218 		  for apsfilter (add / overwrite printer)
  219 		- setting up apsfilter (which gs driver to use,
  220 		  paper size, print resolutions and color depth)
  221 		- printing a test page (settings may be modified
  222 		  until successfull ouput of a testpage)
  223 		- saves some SETUP settings in apsfilterrc config file
  224 
  225         it does not:
  226 
  227 		- complete printer management in printcap
  228 		  (delete/modify printer)
  229         ----------------------------------------------------------------
  230 
  231                         [ press <RETURN> to continue ]
  232 !EOM
  233     read answer
  234 }
  235 
  236 ##############################################################################
  237 # Check which ghostscript release we have
  238 # Now we can offer gs version dependent
  239 #	- driver description
  240 #	- driver selection
  241 ##############################################################################
  242 do_check_gs_version()
  243 {
  244     GS_VERSION=`gs --version`
  245     case $GS_VERSION in
  246 	7*)
  247 	    GS_BASE=7.00 ;;
  248 	6.[5-9]*)
  249 	    GS_BASE=6.50 ;;
  250 	*)
  251 	    GS_BASE=6.50
  252 
  253 	    cat <<EOF
  254 Found ghostscript version $GS_VERSION ...
  255 You have to upgrade at least to gs version 6.50!
  256 But you should upgrade to gs 7.00 for full driver support
  257 prior installing printers with SETUP.
  258 EOF
  259 	    echo $n "Do you you want to continue? [Y/n] $c"; read answer
  260 	    case $answer in
  261 		N|n)
  262 		    echo "o.k., terminating."
  263 		    exit 1
  264 		    ;;
  265 	    esac
  266 	    ;;
  267     esac
  268 }
  269 
  270 ##############################################################################
  271 # if user selects a "non-PS printer" and if ghostscript is not installed
  272 # (needed by do_choose_driver)
  273 ##############################################################################
  274 warn_about_missing_gs()
  275 {
  276     clear
  277     cat << !EOM
  278     ================================================================
  279     A P S F I L T E R   S E T U P                      -- WARNING --
  280     ================================================================
  281 
  282     Attention 
  283     =========
  284     As I see now, you are installing apsfilter for a printer that needs
  285     gs (ghostscript) as postscript emulator, but apsfilter's SETUP was
  286     unable to locate the ghostscript emulator.
  287 
  288     One reason might be that ghostscript is installed in an unusual
  289     directory and SETUP was unable to auto-detect this path.
  290 
  291     Then please add this path at the top of SETUP and run it again.
  292 
  293     Otherwise you have to get the ghostscript sources and fonts
  294     and install ghostscript by hand and run setup again afterwards.
  295 !EOM
  296     exit 1
  297 }
  298 
  299 ##############################################################################
  300 # Show the ghostscript devices that are compiled into gs (pretty-print).
  301 ##############################################################################
  302 
  303 show_gs_devices()
  304 {
  305     {
  306 	echo "Devices known to ghostscript version $GS_VERSION:"; echo
  307 	gs -q -dNODISPLAY -c "devicenames == quit" | tr -d "/[]" | \
  308 	tr " " "\n" | sort | pr -5 -t -w 80
  309     } | do_pager -
  310 }
  311 
  312 ##############################################################################
  313 # Loop until suitable driver found and confirmed by the user
  314 ##############################################################################
  315 do_choose_driver()
  316 {
  317     clear
  318     cat << !EOM
  319 			PRINTER DRIVER SELECTION
  320 
  321     Please select the type of printer you want to install:
  322 
  323     1)  PostScript printer (generic)
  324     2)  PostScript printer (with ghostscript drivers)
  325     3)  printer driver natively supported by ghostscript
  326     4)  gimp-print (stp driver; version 4.2.x)
  327     5)  gimp-print (ijs driver; version 4.2.1 and later)
  328     6)  hpdj
  329     7)  pcl3 (successor to hpdj)
  330     8)  IBM Omni
  331     9)  various HP Deskjet drivers
  332     10) PPA printer
  333     11) official HP DeskJet drivers (hpijs 0.97)
  334     12) official HP DeskJet drivers (hpijs 1.1 and later)
  335     13) Epson printer (official drivers)
  336     14) Lexmark inkjet printer
  337     15) miscellaneous other drivers
  338     16) non-printer devices (caution! -- read the handbook)
  339     17) sound (let apsfilter act as jukebox)
  340     0)  return to main menu
  341 
  342 !EOM
  343     echo $n "Your choice: $c"; read answer
  344     case $answer in
  345 	1)	PRINTER=PS; return ;;
  346 	2)	PRINTER=PSgs
  347 		check_for_gs_support pswrite psgray psmono || do_choose_driver
  348 		return ;;
  349 	3)	PRINTER_LIST=setup/printer-$GS_BASE ;;
  350 	4)	PRINTER_LIST=setup/printer-stp ;;
  351 	5)	PRINTER_LIST=setup/printer-gimp ;;
  352 	6)	PRINTER_LIST=setup/printer-hpdj ;;
  353 	7)	PRINTER_LIST=setup/printer-pcl3 ;;
  354 	8)	PRINTER_LIST=setup/printer-omni ;;
  355 	9)	PRINTER_LIST=setup/printer-cdj ;;
  356 	10)	PRINTER_LIST=setup/printer-ppa ;;
  357 	11)	PRINTER_LIST=setup/printer-hpijs ;;
  358 	12)	PRINTER_LIST=setup/printer-ijs ;;
  359 	13)	PRINTER_LIST=setup/printer-epson ;;
  360 	14)	PRINTER_LIST=setup/printer-lexmark ;;
  361 	15)	PRINTER_LIST=setup/printer-misc ;;
  362 	16)	PRINTER_LIST=setup/non-printer ;;
  363 	17)	PRINTER_LIST=setup/sound ;;
  364 	*)	return ;;
  365     esac
  366 
  367     # for sanity checks in while loop
  368     # no of entries in PRINTER_LIST
  369     MAXNO=`grep -c -v "^#" $PRINTER_LIST`
  370 
  371     clear
  372     cat <<!EOM
  373 
  374 Choose printer driver from the following list; remember the number.
  375 
  376 Hint: Navigation in more:
  377     SPACE    - page down
  378     b        - backward one screen
  379     RETURN   - line forward
  380     /pattern - search for pattern (i.e.: driver name)
  381     k        - backward one line
  382     G        - jump to end of file
  383     1G       - jump to beginning of file
  384     q        - quit browsing file
  385     h        - help
  386 
  387 Press <RETURN> to continue
  388 !EOM
  389     read answer
  390 
  391     PRINTER=""
  392     while [ -z "$PRINTER" ]; do
  393 	# list available gs driver preceeded by number
  394 	grep -v "^#" $PRINTER_LIST \
  395 	    | "$AWK" -F "|" '{ printf("%d - %s [%s]\n", FNR, $1, $2) }' \
  396 	    | do_pager -
  397 	echo "Which driver do you want to choose?"
  398 	echo "[Hit RETURN to see the list again, enter 0 to choose new type.]"
  399 	echo
  400 	echo $n "Enter number: $c"; read answer
  401 	if [ -z "$answer" ]; then
  402 	    : # show the list again
  403 	elif [ $answer = 0 ]; then
  404 	    # choose a different printer type
  405 	    do_choose_driver
  406 	    return
  407 	elif [ $answer -lt 1 -o $answer -gt $MAXNO ]; then
  408 	    echo "wrong selection: enter value between 1 and $MAXNO !"
  409 	    sleep 2
  410 	else
  411 	    # get the driver specified by number
  412 	    PRINTER="`grep -v "^#" $PRINTER_LIST \
  413 			| "$AWK" -F "|" "{ if (FNR == $answer) print \\$2 }"`"
  414 	fi
  415 
  416 	# check if gs has this driver compiled in
  417 	if [ -n "$PRINTER" ]; then
  418 	    case "$PRINTER" in
  419 		# print-to-file drivers
  420 		bmp)	check_for_gs_support bmp32b bmpgray bmpmono ;;
  421 		jpeg)	check_for_gs_support jpeg jpeggray ;;
  422 		pcx)	check_for_gs_support pcx24b pcxgray pcxmono ;;
  423 		png)	check_for_gs_support png16m pnggray pngmono ;;
  424 		pnm)	check_for_gs_support ppmraw pgmraw pbmraw ;;
  425 		tiff)	check_for_gs_support tiff24nc tiffpack ;;
  426 
  427 		# printer drivers
  428 		*.upp)	check_for_gs_support uniprint ;;
  429 		ppa/*|printiva|lexmark1100)
  430 			check_for_gs_support ppmraw pgmraw pbmraw ;;
  431 		gimp/*)
  432 			check_for_gs_support ijs ;;
  433 		stp/*|omni/*|hpdj/*|pcl3/*|hpijs/*|ijs/*)
  434 			check_for_gs_support "${PRINTER%%/*}" ;;
  435 		lexmark2030|lexmark2070|samsung85)
  436 			check_for_gs_support pbmraw ;;
  437 		lexmark2050c|lexmark2070c|lexmarkZ11)
  438 			check_for_gs_support bitcmyk ;;
  439 		cjet)
  440 			check_for_gs_support ljet3 ;;
  441 		ljet4l)
  442 			check_for_gs_support ljet4 ;;
  443 		stylewriter)
  444 			check_for_gs_support bitcmyk pbmraw ;;
  445 		pips/*)
  446 			check_for_gs_support png16m pnggray pngmono ;;
  447 		st800)
  448 			check_for_gs_support stcolor ;;
  449 		bjc50|bjc70|bjc4000|bjc7000)
  450 			check_for_gs_support bjc600 ;;
  451 
  452 		sound)	# set all other variables to default to sound
  453 			INTERFACE=sound
  454 			XRESOL=sound
  455 			YRESOL=sound
  456 			RESOLUTION=sound
  457 			COLOR=sound
  458 			QUALITY=sound
  459 			METHOD=sound
  460 			PAPER=sound
  461 			;;
  462 
  463 		# simple default for printer and non-printer devices
  464 		*)	check_for_gs_support "$PRINTER" ;;
  465 	    esac
  466 	fi
  467 
  468 	if [ -n "$PRINTER" ]; then
  469 	    echo
  470 	    echo "You selected driver: $PRINTER"
  471 	    echo
  472 	    echo "Driver $PRINTER supports the following printer(s):"
  473 	    grep "|$PRINTER$" $PRINTER_LIST
  474 	    echo
  475 	    echo $n "Do you want to use $PRINTER? [Y|n] $c"; read answer
  476 	    case $answer in
  477 		N|n)	PRINTER="" ;;
  478 	    esac
  479 	fi
  480     done
  481 }
  482 
  483 check_for_gs_support()
  484 {
  485     local req
  486 
  487     # check for gs
  488     type gs >/dev/null 2>&1 || warn_about_missing_gs
  489 
  490     for req; do
  491 	# check if gs has driver compiled in
  492 	if ! gs -h | sed -e '1,/Available devices:/d' -e '/Search path:/,$ d' \
  493 		| grep -w "$req" >/dev/null; then
  494 	    cat <<EOF
  495 
  496 Error: Your gs version doesn't have driver "$req" compiled in...
  497 Select another driver or build a new gs version with complete or customized
  498 driver support.
  499 
  500 Now you'll see a list of drivers supported by your gs version...
  501 
  502 Press <RETURN> to continue
  503 EOF
  504 	    read answer
  505 	    show_gs_devices
  506 	    # to enter selection loop
  507 	    PRINTER=""
  508 	    return 1
  509 	fi
  510     done
  511     return 0
  512 }
  513 
  514 ##############################################################################
  515 # called by do_setup_interface (parallel setup)
  516 ##############################################################################
  517 do_ask_parallel_device()
  518 {
  519     clear
  520     cat << !EOM
  521         ----------------------------------------------------------------
  522         A P S F I L T E R   Parallel Interface Settings     -- Device --
  523         ----------------------------------------------------------------
  524 
  525 	Depending on your flavour of Unix, you have to enter the
  526 	*full path* to your parallel Interface. In case of trouble please
  527 	contact your local system administrator or read your operating
  528 	systems technical documentation, FreeBSD handbook or Linux HowTo.
  529 	Some examples:
  530 
  531 	FreeBSD, NetBSD, OpenBSD:   LPT1: /dev/lpt0   LPT2: /dev/lpt1
  532 		USB under *BSD:           /dev/ulpt0        /dev/ulpt1
  533 		USB (no reset):           /dev/unlpt0       /dev/unlpt1
  534 	Linux:                      LPT1: /dev/lp0    LPT2: /dev/lp1
  535 		with devfsd:              /dev/printers/0   /dev/printers/1
  536 		USB under Linux:          /dev/usb/lp0      /dev/usb/lp1
  537 	SunOS4:                           /dev/bpp0         /dev/bpp1
  538 
  539 	currently selected:               Interface:  [$INTERFACE]
  540                                           Device:     [$DEVICE]	
  541 
  542 !EOM
  543     echo $n "Full path of parallel print device: $c"; read $read_r answer
  544     [ "$answer" ] && DEVICE="$answer"
  545 
  546     if [ ! -c "$DEVICE" ]; then
  547 	echo; echo "Warning! Device node '$DEVICE' is not a character"
  548 	echo $n "device. Proceed anyway (y/n)? $c"; read $read_r answer
  549 	[ "$answer" != y -a "$answer" != Y ] && unset DEVICE
  550     fi
  551 }
  552 
  553 ##############################################################################
  554 # called by do_setup_interface (remote printer setup)
  555 ##############################################################################
  556 do_ask_remote_printer()
  557 {
  558     clear
  559     cat << !EOM
  560         ----------------------------------------------------------------
  561         A P S F I L T E R   Remote Printer SETUP via lpd print protocol
  562         ----------------------------------------------------------------
  563 
  564 	If you have FreeBSD (3.x or later) with an enhanced lpd or
  565 	another Unix System with LPRng, it's possible to use apsfilter
  566 	with remote printer. Restrictions of original Berkeley lpd
  567 	made it impossible in the past, to use lineprinter input filter
  568 	when printing to a remote printer.
  569 
  570 	Please enter the full qualified hostname or IP address of the
  571 	remote system as well as the remote printer name.
  572 	See the manpage: printcap(5). Fields "rm" and "rp"
  573 
  574 	currently selected:
  575 	machine name for remote printer : [ $rm ]
  576 	remote printer name             : [ $rp ]	
  577 
  578 !EOM
  579     echo $n "Machine name for remote printer: $c"; read $read_r rm
  580     echo
  581     echo "Hint for remote printing onto network printer with HP JetDirect card"
  582     echo "Enter 'raw' as remote printer queuename !"
  583     echo
  584     echo $n "Remote Printer Name: $c"; read $read_r rp
  585     [ "$rm" ] && DEVICE="$rm"
  586 }
  587 
  588 ##############################################################################
  589 # called by do_setup_interface (samba printer setup)
  590 ##############################################################################
  591 do_ask_samba_printer()
  592 {
  593     clear
  594     cat << !EOM
  595         ----------------------------------------------------------------
  596         A P S F I L T E R   Samba Printer SETUP
  597         ----------------------------------------------------------------
  598 
  599 	Take care that smbclient is in apsfilters search path.
  600 	You can fine tune paths in $CONF_DIR/apsfilterrc.
  601 	See smbclient manual page for more options if needed.
  602 
  603 	currently selected:
  604 	NetBIOS name of Windows Server  : [ $SMB_SERVER ]
  605 	Windows Server IP               : [ $SMB_IP ]	
  606 	Printer Share  Name             : [ $SMB_PRINTER ]	
  607 	Workgroup                       : [ $SMB_WORKGROUP ]	
  608 	Windows Username                : [ $SMB_USER ]	
  609 	Windows Password                : [ $SMB_PASSWD ]	
  610 
  611 	(you can fine tune some more values in the smbclient.conf
  612 	file in the printer's configuration directory later)
  613 
  614 !EOM
  615     echo $n "NetBIOS name of Windows Server: $c"; read $read_r SMB_SERVER
  616     echo $n "Windows Server IP Address     : $c"; read $read_r SMB_IP
  617     echo $n "Printer Share Name            : $c"; read $read_r SMB_PRINTER
  618     echo $n "Workgroup Name                : $c"; read $read_r SMB_WORKGROUP
  619     echo $n "Print as Windows GUEST user (no: use real account)? [y/n] $c"
  620     read answer
  621     case $answer in
  622 	n|N)
  623 	    echo $n "Windows Username              : $c"
  624 	    read $read_r SMB_USER
  625 	    echo $n "Windows Password              : $c"
  626 	    read $read_r SMB_PASSWD
  627 	    ;;
  628 	*)
  629 	    echo "O.K. using user GUEST, to print on Windows Printer..."
  630 	    SMB_USER=""; SMB_PASSWD=""
  631 	    ;;
  632     esac
  633 
  634     [ "$SMB_SERVER" ] && DEVICE="$SMB_SERVER"
  635 }
  636 
  637 ##############################################################################
  638 # called by do_setup_interface (netware printer setup)
  639 ##############################################################################
  640 do_ask_netware_printer()
  641 {
  642     clear
  643     cat << !EOM
  644         ----------------------------------------------------------------
  645         A P S F I L T E R   NetWare Printer SETUP
  646         ----------------------------------------------------------------
  647 
  648 	Take care that ncprint/nprint is in apsfilters search path.
  649 	You can fine tune paths in $CONF_DIR/apsfilterrc.
  650 	See ncprint/nprint manual page for more options if needed.
  651 
  652 	currently selected:
  653 	NetWare server name  : [ $NCP_SERVER ]
  654 	Printer queue name   : [ $NCP_PRINTER ]
  655 	NetWare username     : [ $NCP_USER ]
  656 	NetWare password     : [ $NCP_PASSWD ]
  657 
  658 	(you can fine tune some more values in the netware.conf
  659 	file in the printer's configuration directory later)
  660 
  661 !EOM
  662     echo $n "NetWare server name  : $c"; read $read_r NCP_SERVER
  663     echo $n "Printer queue name   : $c"; read $read_r NCP_PRINTER
  664     echo $n "NetWare username     : $c"; read $read_r NCP_USER
  665     echo $n "NetWare password     : $c"; read $read_r NCP_PASSWD
  666 
  667     [ "$NCP_SERVER" ] && DEVICE="$NCP_SERVER"
  668 }
  669 
  670 ##############################################################################
  671 # called by do_setup_interface (apple remote printer setup)
  672 ##############################################################################
  673 do_ask_atalk_printer()
  674 {
  675     clear
  676     cat << !EOM
  677         ----------------------------------------------------------------
  678         A P S F I L T E R   AppleTalk Remote Printer SETUP
  679         ----------------------------------------------------------------
  680 
  681 	Take care that pap is installed in apsfilters search path.
  682 	You can fine tune paths in $CONF_DIR/apsfilterrc.
  683 	See pap manual page for more options if needed.
  684 
  685 	currently selected:
  686 	NBP name of Apple Printer  : [ $PAP_NBPNAME ]
  687 
  688 !EOM
  689     echo $n "Name (NBP Name) of Apple Printer: $c"; read $read_r PAP_NBPNAME
  690 
  691     [ "$PAP_NBPNAME" ] && DEVICE="$PAP_NBPNAME"
  692 }
  693 
  694 ##############################################################################
  695 # Some routines for serial interface options, line discipline...
  696 ##############################################################################
  697 do_read_serial_device()
  698 {
  699     clear
  700     cat << !EOM
  701         ----------------------------------------------------------------
  702         A P S F I L T E R   Serial Interface Settings       -- Device --
  703         ----------------------------------------------------------------
  704 
  705 	Depending on your flavour of Unix, you have to enter the
  706 	*full path* to your serial Interface. In case of trouble please
  707 	contact your local system administrator or read your operating
  708 	systems technical documentation, FreeBSD handbook or Linux HowTo.
  709 	Some examples:
  710 
  711 	FreeBSD, NetBSD, OpenBSD:   COM1: /dev/cuaa0  COM2: /dev/cuaa1
  712 	Linux:                      COM1: /dev/ttyS0  COM2: /dev/ttyS1
  713 	SunOS4:                           /dev/ttya         /dev/ttyb
  714 
  715 	currently selected:                    Interface: [$INTERFACE]
  716                                                Device   : [$DEVICE]
  717 !EOM
  718     echo $n "Your choice? $c"; read $read_r answer
  719     [ "$answer" ] && DEVICE="$answer"
  720 
  721     if [ ! -c "$DEVICE" ]; then
  722 	echo; echo "Warning! Device node '$DEVICE' is not a character"
  723 	echo $n "device. Proceed anyway (y/n)? $c"; read $read_r answer
  724 	[ "$answer" != y -a "$answer" != Y ] && unset DEVICE
  725     fi
  726 }
  727 
  728 do_read_serial_baud()
  729 {
  730     clear
  731     cat << !EOM
  732         ----------------------------------------------------------------
  733         A P S F I L T E R   Serial Interface Settings     -- Baudrate --
  734         ----------------------------------------------------------------
  735 
  736 	The Baud Rate is the transfer rate at which the asynchronous
  737 	serial interface is sending bits from the computer to the printer.
  738 
  739 	The higher the Baudrate the better and shorter your cable should
  740 	be. I recommend 5m cable as a maximum for 38400 Baud and perhaps
  741 	2-3m for speeds higher than that. It depends heavily on the
  742 	quality of your cables, interfaces, handshaking and printer.
  743 
  744 	Another rule of thumb is, that hardware handshaking works best
  745 	with higher Baudrates, but needs a special cable depending on
  746 	your machine and the printer.
  747 
  748 	Valid and useable Baudrates are (a good starting point is 9600)
  749 
  750 	1) 4800		2) 9600		3) 19200
  751 	4) 38400	5) 57600	6) 115200
  752 
  753 	Please note: you have to configure your printer as well for that
  754 	speed and don't forget to power off and on the printer after that.
  755 
  756 !EOM
  757     echo $n "Your choice? $c"; read answer
  758     case $answer in
  759 	1)  BAUDRATE=4800      	;;
  760 	2)  BAUDRATE=9600	;;
  761 	3)  BAUDRATE=19200	;;
  762 	4)  BAUDRATE=38400	;;
  763 	5)  BAUDRATE=57600	;;
  764 	6)  BAUDRATE=115200	;;
  765     esac
  766 }
  767 
  768 do_read_serial_handshake()
  769 {
  770     clear
  771     cat << !EOM
  772         ----------------------------------------------------------------
  773         A P S F I L T E R   Serial Interface Settings  -- Handshaking --
  774         ----------------------------------------------------------------
  775 
  776 	There are two possible handshaking methods, often called
  777 	Hardware and Software handshaking. This determines, how
  778 	the printer tells your computers start or stop sending data
  779 	to avoid data lossage.
  780 
  781 	Directly forget about using ghostscript as Postscript Emulator
  782 	with the software handshaking (xon/xoff protocol), because gs
  783 	(ghostscript) sends a binary data stream to the printer containing
  784 	these start/stop characters. But I will allow you to select this
  785 	as an option, you'll certainly know better than I what you want.
  786 
  787 	Hardware handshaking isn't as standardized as it could. So
  788 	different computer/printers use different pins/signals of the
  789 	serial interface, to stop/start the data transfer. You'll
  790 	certainly need a special printer cable !
  791 
  792 	1 - software handshaking (xon/xoff, 3 wires, avoid this)
  793 	2 - hardware handshaking (crtscts, RTS/CTS flow control)
  794 
  795 !EOM
  796     echo $n "Your choice? $c"; read answer
  797     case $answer in
  798 	1)  HANDSHAKE="ixon,ixoff,ixany,-crtscts"
  799 	    HANDSHAKE_FOR_COMMAND="ixon ixoff ixany -crtscts"
  800 	    ;;
  801 	2)  HANDSHAKE="-ixon,-ixoff,-ixany,crtscts"
  802 	    HANDSHAKE_FOR_COMMAND="-ixon -ixoff -ixany crtscts"
  803 	    ;;
  804     esac
  805 }
  806 
  807 do_read_serial_wordlength()
  808 {
  809     clear
  810     cat << !EOM
  811         ----------------------------------------------------------------
  812         A P S F I L T E R   Serial Interface Settings   -- Wordlength --
  813         ----------------------------------------------------------------
  814 
  815 	Computer and Printer must have the same settings how many
  816 	"bits" long a "data word" is.
  817 
  818 	We have to use "8 Bit" long data words, otherwise it isn't
  819 	possible to transmit characters above a value of 127.
  820 	We need 8 Bit here!
  821 
  822 	1)	8 Bit		(a must !)
  823 	2)	7 Bit		(please do not use this !)
  824 
  825 !EOM
  826     echo $n "Your choice? $c"; read answer
  827     case $answer in
  828 	1)  WORDLENGTH=8; WORDLENGTH_COMMAND=cs8 ;;
  829 	2)  WORDLENGTH=7; WORDLENGTH_COMMAND=cs7 ;;
  830     esac
  831 }
  832 
  833 do_read_serial_parity()
  834 {
  835     clear
  836     cat << !EOM
  837         ----------------------------------------------------------------
  838         A P S F I L T E R   Serial Interface Settings       -- Parity --
  839         ----------------------------------------------------------------
  840 
  841 	Computer and Printer must have the same settings if they
  842 	use parity or not. Parity is a kind of a checksum to detect
  843 	garbage on the line.
  844 
  845 	Usually we use no parity. If there is a need for parity,
  846 	you have to decide if you use even or odd parity.
  847 
  848 	1)	no parity	(take this)
  849 	2)	even
  850 	3)	odd
  851 
  852 !EOM
  853     echo $n "Your choice? $c"; read answer
  854     case $answer in
  855 	1)  PARITY="no parity"; PARITY_COMMAND=-parenb ;;
  856 	2)  PARITY="even"; PARITY_COMMAND="parenb -parodd" ;;
  857 	3)  PARITY="odd"; PARITY_COMMAND="parenb parodd" ;;
  858     esac
  859 }
  860 
  861 do_read_serial_stopbits()
  862 {
  863     clear
  864     cat << !EOM
  865         ----------------------------------------------------------------
  866         A P S F I L T E R   Serial Interface Settings    -- Stop Bits --
  867         ----------------------------------------------------------------
  868 
  869 	Your computer and printer must have the same amount of stopbits
  870 	configured that are sent/accepted after transmitting a "Data
  871 	word" - and parity information, if you selected one -.
  872 
  873 	Standard is to use one stopbit. Please configure your printer's
  874 	serial interface to use one stopbit, if possible, otherwise use
  875 	two stopbits.
  876 
  877 	1)	1 Stopbit
  878 	2)	2 Stopbits
  879 
  880 !EOM
  881     echo $n "Your choice? $c"; read answer
  882     case $answer in
  883 	1)  STOPBITS=1; STOPBIT_COMMAND=-cstopb ;;
  884 	2)  STOPBITS=2; STOPBIT_COMMAND=cstopb ;;
  885     esac
  886 }
  887 
  888 ##############################################################################
  889 # called by do_setup_interface (serial setup)
  890 ##############################################################################
  891 do_ask_serial_settings()
  892 {
  893     clear
  894     cat << !EOM
  895         ----------------------------------------------------------------
  896         A P S F I L T E R   S E T U P    -- Serial Interface Settings --
  897         ----------------------------------------------------------------
  898 
  899 	Important for a successfull configuration is, that the computers
  900 	_and_ the printers interface do have exactly the same settings !
  901 
  902 	Operating system dependent
  903 	   1) Printer device			[$DEVICE]
  904 
  905 	General operating characteristics
  906 	   2) Baud rate				[$BAUDRATE]
  907 	   3) Handshaking			[$HANDSHAKE]
  908 
  909 	Data format
  910 	   4) Data Word Length (in bits)	[$WORDLENGTH]
  911 	   5) Parity				[$PARITY]
  912 	   6) Stopbits				[$STOPBITS]
  913 	   7) Startbits (UNIMPLEMENTED)		[$STARTBITS]
  914 
  915 !EOM
  916     echo $n "Your choice? $c"; read answer
  917     case $answer in
  918 	1)  do_read_serial_device	;;
  919 	2)  do_read_serial_baud		;;
  920 	3)  do_read_serial_handshake	;;
  921 	4)  do_read_serial_wordlength	;;
  922 	5)  do_read_serial_parity	;;
  923 	6)  do_read_serial_stopbits	;;
  924     esac
  925 }
  926 
  927 ##############################################################################
  928 # Print Device serial or parallel?
  929 ##############################################################################
  930 do_setup_interface()
  931 {
  932     clear
  933     cat << !EOM
  934         ----------------------------------------------------------------
  935         A P S F I L T E R   S E T U P              -- Interface Setup --
  936         ----------------------------------------------------------------
  937 
  938 	The easiest way, to connect a printer to your computer is by
  939 	using the parallel interface, because it's usually *faster*,
  940 	more standardized and therefore much easier to configure.
  941 	 When configuring a serial printer, the installation dialogue
  942 	asks you many questions about how to configure the serial
  943 	interface of your computer, so that it works well with your
  944 	printers current settings.
  945 	 When using the serial interface, then you have to choose special
  946 	cables, depending on the communication protocol between computer
  947 	and printer (hardware/software handshaking). Many pitfalls here !
  948 
  949 	currently selected:               Interface:  [$INTERFACE]
  950                                           Device:     [$DEVICE]	
  951 	configure local / remote printer
  952 	1) local parallel/USB		2) local serial
  953 	3) Unix/network printer (lpd)	4) Windows / NT (samba)
  954 	5) AppleTalk                    6) Novell NetWare
  955 	7) Sound (Jukebox)
  956 
  957 !EOM
  958     echo $n "Your choice? $c"; read answer
  959     case $answer in
  960 	2)  INTERFACE=serial; do_ask_serial_settings ;;
  961 	3)  INTERFACE=network; do_ask_remote_printer ;;
  962 	4)  INTERFACE=samba; do_ask_samba_printer ;;
  963 	5)  INTERFACE=atalk; do_ask_atalk_printer ;;
  964 	6)  INTERFACE=netware; do_ask_netware_printer ;;
  965 	7)  INTERFACE=sound ;;
  966 	*)  INTERFACE=parallel; do_ask_parallel_device ;;
  967     esac
  968     [ "$DEVICE" ] || unset INTERFACE
  969 }
  970 
  971 ##############################################################################
  972 # Choose the print resolution
  973 ##############################################################################
  974 do_choose_resolution()
  975 {
  976     clear
  977     cat << !EOM
  978         ----------------------------------------------------------------
  979         A P S F I L T E R   S E T U P             -- Print Resolution --
  980         ----------------------------------------------------------------
  981 
  982 	You can set the default printing resolution here, but keep in
  983 	mind that the quality setting (right now: $QUALITY) has
  984 	greater priority for most drivers.
  985 
  986 	You must set the resolution in this dialog for PostScript
  987 	printers (PS, PSgs) and for drivers that don't have a driver
  988 	script (e.g. uniprint profiles).
  989 
  990 	Some typical settings to play with:
  991 
  992 	1) 150dpi	2) 300dpi	3) 600dpi	4) 1200dpi
  993 	5) 180dpi	6) 360dpi	7) 360x180dpi	8) 720dpi
  994 	9) sound
  995 
  996 	c) custom settings
  997 
  998 !EOM
  999     echo $n "Your choice? $c"; read answer
 1000     case $answer in
 1001 	1)  XRESOL=150;  YRESOL=150 ;;
 1002 	2)  XRESOL=300;  YRESOL=300 ;;
 1003 	3)  XRESOL=600;  YRESOL=600 ;;
 1004 	4)  XRESOL=1200; YRESOL=1200 ;;
 1005 	5)  XRESOL=180;  YRESOL=180 ;;
 1006 	6)  XRESOL=360;  YRESOL=360 ;;
 1007 	7)  XRESOL=360;  YRESOL=180 ;;
 1008 	8)  XRESOL=720;  YRESOL=720 ;;
 1009 	9)  XRESOL="sound" ;;
 1010 	*)  # custom settings
 1011 	    echo $n "Please input x-resolution in dpi: $c"; read XRESOL
 1012 	    echo $n "Please input y-resolution in dpi: $c"; read YRESOL
 1013 	    if [ -z "$XRESOL" ]; then
 1014 		if [ -z "$YRESOL" ]; then
 1015 		    XRESOL=300; YRESOL=300
 1016 		else
 1017 		    XRESOL=$YRESOL
 1018 		fi
 1019 	    else
 1020 		[ "$YRESOL" ] || YRESOL=$XRESOL
 1021 	    fi
 1022 	    ;;
 1023     esac
 1024     if [ "$XRESOL" == "sound" ]; then
 1025 	RESOLUTION="sound"
 1026     else
 1027 	RESOLUTION=${XRESOL}x${YRESOL}
 1028     fi
 1029 }
 1030 
 1031 ##############################################################################
 1032 # Choose default color mode
 1033 ##############################################################################
 1034 do_choose_color()
 1035 {
 1036     clear
 1037     cat << !EOM
 1038         ----------------------------------------------------------------
 1039         A P S F I L T E R   S E T U P                  -- Color Setup --
 1040         ----------------------------------------------------------------
 1041 
 1042 	Please choose whether you want to print in full color, grayscale
 1043 	or monochrome mode. Not all drivers support all of these three
 1044 	modes.
 1045 
 1046 	If you don't know what to do, use "full color".
 1047 
 1048 	1)	full color mode		(usually 24bpp or 32bpp)
 1049 	2)	grayscale mode		(usually 3bpp, 4bpp or 8bpp)
 1050 	3)	monochrome mode		(usually 1bpp)
 1051 	4)	sound
 1052 
 1053 	0)	keep setting [$COLOR]
 1054 
 1055 !EOM
 1056     echo $n "Your choice? $c"; read answer
 1057     case $answer in
 1058 	1)	COLOR=full ;;
 1059 	2)	COLOR=gray ;;
 1060 	3)	COLOR=mono ;;
 1061 	4)	COLOR=sound ;;
 1062     esac
 1063 }
 1064 
 1065 ##############################################################################
 1066 # Choose default printing quality
 1067 ##############################################################################
 1068 do_choose_quality()
 1069 {
 1070     clear
 1071     cat << !EOM
 1072         ----------------------------------------------------------------
 1073         A P S F I L T E R   S E T U P                -- Quality Setup --
 1074         ----------------------------------------------------------------
 1075 
 1076 	This sets the printing quality. Usually, this has an impact on
 1077 	the printing resolution and the dithering quality. For some
 1078 	drivers, some modes are merely aliases for other modes.
 1079 
 1080 	1)	draft	(usually: lowest resolution, fastest dithering)
 1081 	2)	low	(usually: low resolution, fast dithering)
 1082 	3)	medium	(usually: medium resolution, normal dithering)
 1083 	4)	high	(usually: high resolution, good dithering)
 1084 	5)	photo	(usually: highest resolution, best dithering)
 1085 	6)	sound
 1086 
 1087 	0)	keep setting [$QUALITY]
 1088 
 1089 !EOM
 1090     echo $n "Your choice? $c"; read answer
 1091     case $answer in
 1092 	1)	QUALITY=draft ;;
 1093 	2)	QUALITY=low ;;
 1094 	3)	QUALITY=medium ;;
 1095 	4)	QUALITY=high ;;
 1096 	5)	QUALITY=photo ;;
 1097 	6)	QUALITY=sound ;;
 1098     esac
 1099 }
 1100 
 1101 ##############################################################################
 1102 # Choose default printing method
 1103 ##############################################################################
 1104 do_choose_method()
 1105 {
 1106     clear
 1107     cat << !EOM
 1108         ----------------------------------------------------------------
 1109         A P S F I L T E R   S E T U P                 -- Method Setup --
 1110         ----------------------------------------------------------------
 1111 
 1112 	Please choose how apsfilter should handle the incoming data.
 1113 
 1114 	1)	auto	(automatic data conversion)
 1115 	2)	ascii	(treat everything as text)
 1116 	3)	raw	(do not modify data; ignores paper size,
 1117 			 quality, color and resolution settings)
 1118 	4)	sound	(use apsfilter as mp3 jukebox)
 1119 
 1120 	0)	keep setting [$METHOD]
 1121 
 1122 !EOM
 1123     echo $n "Your choice? $c"; read answer
 1124     case $answer in
 1125 	1)	METHOD=auto ;;
 1126 	2)	METHOD=ascii ;;
 1127 	3)	METHOD=raw ;;
 1128 	4)	METHOD=sound ;;
 1129     esac
 1130 }
 1131 
 1132 ##############################################################################
 1133 # Choose paper size
 1134 ##############################################################################
 1135 do_setup_paper_format()
 1136 {
 1137     clear
 1138     cat << !EOM
 1139 	----------------------------------------------------------------
 1140         A P S F I L T E R   S E T U P                 -- Paper Format --
 1141         ----------------------------------------------------------------
 1142 
 1143 	What paper format do you want to use for printing?
 1144 
 1145 	1) DIN A4	(21.0cm x 29.7cm)
 1146 	2) DIN A3	(29.7cm x 42.0cm)
 1147 	3) US letter	( 8.5in x 11.0in)
 1148 	4) US legal	( 8.5in x 14.0in)
 1149 	5) US tabloid	(11.0in x 17.0in)
 1150 	6) US ledger	(17.0in x 11.0in)
 1151 	7) Sound
 1152 
 1153 !EOM
 1154     echo $n "Your choice? $c"; read answer
 1155     case $answer in
 1156 	1)  PAPER=a4 ;;
 1157 	2)  PAPER=a3 ;;
 1158 	3)  PAPER=letter ;;
 1159 	4)  PAPER=legal ;;
 1160 	5)  PAPER=tabloid ;;
 1161 	6)  PAPER=ledger ;;
 1162 	7)  PAPER=sound ;;
 1163     esac
 1164 }
 1165 
 1166 do_print_test_page()
 1167 {
 1168     local sv_printer sv_resolution gs_device paper
 1169 
 1170     sv_printer=$PRINTER; sv_resolution=$RESOLUTION
 1171     [ "$PAPER" = tabloid ] && paper=11x17 || paper="$PAPER"
 1172 
 1173     # the tmp file containing the print data
 1174     # a) PS content if you have a PS printer
 1175     # b) gs output (translated PS file) using printer driver of your choice
 1176 
 1177     TESTOUT="$APS_TMPDIR/test_page.aps"
 1178 
 1179     ### call driver script to adjust options
 1180     unset GS_FEATURES POST_FILTER POST_FILTER_OPTS
 1181     DRIVER_SCRIPT="$PRINTER"
 1182     if [ ! -e "driver/$DRIVER_SCRIPT" ]; then
 1183 	# get the script name from the mapping file
 1184 	DRIVER_SCRIPT=$(grep ":$PRINTER:" "driver/MAPPING" | sed "s/:.*//")
 1185     fi
 1186     if [ -n "$DRIVER_SCRIPT" -a -e "driver/$DRIVER_SCRIPT" ]; then
 1187 	. "driver/$DRIVER_SCRIPT"
 1188     fi
 1189 
 1190     # construct test print command, that will be evaluated later; idea is to
 1191     # separate time to create print data and actual time to print it
 1192 
 1193     case "$PRINTER" in
 1194 	omni/*|hpijs/*)
 1195 	    GS_FEATURES="$GS_FEATURES -sDeviceName=${PRINTER#*/}"
 1196 	    PRINTER=${PRINTER%%/*} ;;
 1197 	stp/*|hpdj/*)
 1198 	    GS_FEATURES="$GS_FEATURES -sModel=${PRINTER#*/}"
 1199 	    PRINTER=${PRINTER%%/*} ;;
 1200 	pcl3/*)
 1201 	    GS_FEATURES="$GS_FEATURES -sSubdevice=${PRINTER#pcl3/}"
 1202 	    PRINTER=pcl3 ;;
 1203 	gimp/*)
 1204 	    GS_FEATURES="$GS_FEATURES -sDeviceModel='${PRINTER#gimp/}' \
 1205 		-sIjsServer=ijsgimpprint -dIjsUseOutputFD"
 1206 	    PRINTER=ijs ;;
 1207 	ijs/*)
 1208 	    GS_FEATURES="$GS_FEATURES -sDeviceModel='${PRINTER#ijs/}' \
 1209 		-sIjsServer=hpijs -dIjsUseOutputFD"
 1210 	    PRINTER=ijs ;;
 1211     esac
 1212     case "$PRINTER" in
 1213 	PS)
 1214 	    # real PS printer
 1215 	    CREATE_TESTPAGE_CMD="cp setup/test.ps '$TESTOUT'"
 1216 	    ;;
 1217 	*.upp)
 1218 	    # uniprint profiles
 1219 	    CREATE_TESTPAGE_CMD="gs -q -dBATCH -dNOPAUSE -dPARANOIDSAFER \
 1220 		-dSAFER @$PRINTER -sPAPERSIZE=$paper -sOutputFile='$TESTOUT' \
 1221 		setup/test.ps"
 1222 	    ;;
 1223 	sound)
 1224 	    CREATE_TESTPAGE_CMD=""
 1225 	    ;;
 1226 	*)
 1227 	    # generic drivers
 1228 	    CREATE_TESTPAGE_CMD="gs -q -dBATCH -dNOPAUSE -dPARANOIDSAFER \
 1229 		-dSAFER -r$RESOLUTION -sDEVICE=$PRINTER -sPAPERSIZE=$paper \
 1230 		$GS_FEATURES $PS_INIT -sOutputFile='$TESTOUT' setup/test.ps"
 1231 	    ;;
 1232     esac
 1233 
 1234     # reset settings (might have been mangled by the driver script)
 1235     PRINTER=$sv_printer; RESOLUTION=$sv_resolution
 1236 
 1237     # maybe we need an additional filter (e.g. pnm2ppa)
 1238     if [ "$POST_FILTER" ]; then
 1239 	if type "$POST_FILTER" > /dev/null 2>&1; then
 1240 	    CREATE_TESTPAGE_CMD="$CREATE_TESTPAGE_CMD | '$POST_FILTER' \
 1241 		$POST_FILTER_OPTS"
 1242 	else
 1243 	    echo
 1244 	    echo "ERROR: additional filter '$POST_FILTER' was not found;"
 1245 	    echo "       can't create test page"
 1246 	    echo
 1247 	    echo "[ press RETURN to continue ]"
 1248 	    read answer
 1249 	    return
 1250 	fi
 1251     fi
 1252 
 1253     # Tell the magic command ...
 1254     echo
 1255     echo "Printing Test page using:"
 1256     echo "$CREATE_TESTPAGE_CMD"
 1257     echo
 1258     echo $n "Ok to print testpage? [y/n] $c"; read answer
 1259     case $answer in
 1260 	N|n)
 1261 	    # do nothing
 1262 	    ;;
 1263 	*)
 1264 	    # print...
 1265 	    echo
 1266 	    echo "Creating test page..."
 1267 	    {
 1268 		date
 1269 		echo "$PRINTER $RESOLUTION $QUALITY $COLOR"
 1270 		echo "Time for ghostscript:"
 1271 	    }  >> "$CONF_DIR/perf.log"
 1272 
 1273 	    # for time to be saved into logfile
 1274 	    # stderr has to be redir. before pipe
 1275 	    eval time $CREATE_TESTPAGE_CMD 2>&1 | tee -a "$CONF_DIR/perf.log"
 1276 
 1277 	    # check if command was successful
 1278 	    # only then print
 1279 	    EXIT_STATUS=$?
 1280 	    if [ "$EXIT_STATUS" = 0 ]; then
 1281 		echo
 1282 		echo "Printing test page... "
 1283 		echo "Time for printer:" >> "$CONF_DIR/perf.log"
 1284 		if [ "$INTERFACE" = samba ]; then
 1285 		    if [ -n "$SMB_USER" ]; then
 1286 			export PASSWD="$SMB_PASSWD"
 1287 			SMB_LOGIN="-U ${SMB_USER}"
 1288 		    else
 1289 			SMB_LOGIN=""
 1290 		    fi
 1291 		    PRINT_TESTP_CMD="smbclient < '$TESTOUT' \
 1292 			'//${SMB_SERVER}/${SMB_PRINTER}' ${SMB_IP:+-I $SMB_IP} \
 1293 			${SMB_LOGIN} ${SMB_WORKGROUP:+-W} ${SMB_WORKGROUP} \
 1294 			-b 1400	-N -c 'print -'"
 1295 		elif [ "$INTERFACE" = netware ]; then
 1296 		    # hide password in temporary configuration file
 1297 		    if type ncprint >/dev/null 2>&1; then
 1298 			PRINT_TESTP_CMD=ncprint
 1299 			{
 1300 			    echo "[${NCP_SERVER}:${NCP_USER}]"
 1301 			    echo "password=$NCP_PASSWD"
 1302 			} > "$APS_TMPDIR/.nwfsrc"
 1303 			chmod $PASSWD_PROTECT "$APS_TMPDIR/.nwfsrc"
 1304 		    else
 1305 			PRINT_TESTP_CMD=nprint
 1306 			echo "$NCP_SERVER/$NCP_USER ${NCP_PASSWD:--}" \
 1307 			    > "$APS_TMPDIR/.nwclient"
 1308 			chmod $PASSWD_PROTECT "$APS_TMPDIR/.nwclient"
 1309 		    fi
 1310 		    PRINT_TESTP_CMD="$PRINT_TESTP_CMD < '$TESTOUT' \
 1311 			-S $NCP_SERVER -U $NCP_USER -q $NCP_PRINTER"
 1312 		elif [ "$INTERFACE" = atalk ]; then
 1313 		    PRINT_TESTP_CMD="pap -e -p '$PAP_NBPNAME' < '$TESTOUT'"
 1314 		elif [ "$INTERFACE" = network ]; then
 1315 		    PRINT_TESTP_CMD="lpr -P'${rp}@${rm}' '$TESTOUT'"
 1316 		else
 1317 		    PRINT_TESTP_CMD="cat '$TESTOUT' > $DEVICE"
 1318 		fi
 1319 
 1320 		ls -l "$TESTOUT" | tee -a "$CONF_DIR/perf.log"
 1321 		# temporarily set HOME for NetWare printing commands
 1322 		HOME="$APS_TMPDIR" eval time $PRINT_TESTP_CMD 2>&1 | \
 1323 		    tee -a "$CONF_DIR/perf.log"
 1324 		echo "[ press RETURN to continue ]"
 1325 		read answer
 1326 	    else
 1327 		echo "last command terminated with exit status: $EXIT_STATUS"
 1328 		echo "Error creating testpage!"
 1329 		echo "[ press RETURN to continue ]"
 1330 		read answer
 1331 	    fi
 1332 	    ;;
 1333     esac
 1334     # remove temporary files
 1335     rm -f "$TESTOUT" "$APS_TMPDIR/.nwfsrc" "$APS_TMPDIR/.nwclient"
 1336 }
 1337 
 1338 do_print_test_menue()
 1339 {
 1340     clear
 1341     cat << !EOM
 1342         ----------------------------------------------------------------
 1343         A P S F I L T E R   S E T U P                    -- Test Page --
 1344         ----------------------------------------------------------------
 1345 
 1346 	In most cases it's relatively easy to choose a suitable
 1347 	ghostscript driver from the list of supported printers.
 1348 
 1349 	If you're printer is not in the list of supported printers:
 1350 	    - guess a suitable driver by "trial and error"
 1351 	    - consult your printers handbook to what ghostscript printer
 1352 	      driver your printer "claims" to be compatible
 1353 
 1354 	If this test produces unacceptable results, then please choose
 1355 	another driver or try another (perhaps lower) print quality,
 1356 	because it might be a memory problem. Only use print resolutions
 1357 	that are supported by your printer, consult the printers manual!
 1358 
 1359 	Creating the test output might take some time, please be patient.
 1360 
 1361 	T)  Print a test page
 1362 	*)  Back to main menue
 1363 
 1364 !EOM
 1365     echo $n "Your choice? $c"; read answer
 1366     case $answer in
 1367 	t|T)  do_print_test_page ;;
 1368     esac
 1369 }
 1370 
 1371 do_view_perflog()
 1372 {
 1373     if [ -f "$CONF_DIR/perf.log" ]; then
 1374 	do_pager "$CONF_DIR/perf.log"
 1375     else
 1376 	do_pager - << !EOM
 1377 
 1378 You'll have to print a test page first.
 1379 
 1380 !EOM
 1381     fi
 1382 }
 1383 
 1384 do_save_environment()
 1385 {
 1386     #
 1387     # Save some settings for another SETUP attempt ...
 1388     # Gooood for testing ;-))
 1389     #
 1390     cat > "$CONF_DIR/SETUP.cfg" <<EOF
 1391 PRINTER='$PRINTER'
 1392 RESOLUTION='$RESOLUTION'
 1393 COLOR='$COLOR'
 1394 PAPER='$PAPER'
 1395 METHOD='$METHOD'
 1396 QUALITY='$QUALITY'
 1397 INTERFACE='$INTERFACE'
 1398 DEVICE='$DEVICE'
 1399 BAUDRATE='$BAUDRATE'
 1400 HANDSHAKE='$HANDSHAKE'
 1401 WORDLENGTH='$WORDLENGTH'
 1402 PARITY='$PARITY'
 1403 STARTBITS='$STARTBITS'
 1404 STOPBITS='$STOPBITS'
 1405 SMB_SERVER='$SMB_SERVER'
 1406 SMB_IP='$SMB_IP'
 1407 SMB_PRINTER='$SMB_PRINTER'
 1408 SMB_WORKGROUP='$SMB_WORKGROUP'
 1409 SMB_USER='$SMB_USER'
 1410 SMB_PASSWD='$(echo $SMB_PASSWD | sed "s/'/'\\\''/g")'
 1411 NCP_SERVER='$NCP_SERVER'
 1412 NCP_PRINTER='$NCP_PRINTER'
 1413 NCP_USER='$NCP_USER'
 1414 NCP_PASSWD='$(echo $NCP_PASSWD | sed "s/'/'\\\''/g")'
 1415 rm='$rm'
 1416 rp='$rp'
 1417 EOF
 1418     if [ "${SMB_PASSWD}${NCP_PASSWD}" ]; then
 1419 	echo "read protect SETUP.cfg, since it contains password..."
 1420 	chmod $PASSWD_PROTECT "$CONF_DIR/SETUP.cfg"
 1421 	chown root:$LP_GROUP "$CONF_DIR/SETUP.cfg"
 1422     fi
 1423 }
 1424 
 1425 do_main_menue()
 1426 {
 1427     MENU_DONE=""
 1428 
 1429     while [ -z "$MENU_DONE" ]; do
 1430 	# printer that need a special PS init file in GS_LIBDIR
 1431 	case $PRINTER in
 1432 	    stcolor)	PS_INIT=stcolor.ps ;;
 1433 	    *)		PS_INIT="" ;;
 1434 	esac
 1435 
 1436 	clear
 1437 	#
 1438 	# display the main menu
 1439 	#
 1440 	cat << !EOM
 1441         ==================================================================
 1442           A P S F I L T E R   S E T U P                   -- MAIN MENUE --
 1443         ==================================================================
 1444 
 1445 	(D)	Available Device Drivers in your gs binary
 1446 	(R)	Read Ghostscript driver documentation        (devices.txt)
 1447 
 1448 	(1)	Printer Driver Selection		[$PRINTER]
 1449 	(2)	Interface Setup				[$INTERFACE]
 1450 	(3)	Paper Format				[$PAPER]
 1451 	(4)	Printing Quality			[$QUALITY]
 1452 	(5)	Color Mode				[$COLOR]
 1453 	(6)	Print Resolution in "dots per inch"	[$RESOLUTION]
 1454 	(7)	Default Printing Method			[$METHOD]
 1455 
 1456 !EOM
 1457 
 1458 	if [ -z "$PRINTER" -o -z "$INTERFACE" -o -z "$PAPER" ]; then
 1459 		# you need to set PRINTER, INTERFACE and PAPER before
 1460 		# anything else can be done
 1461 		unset proceed
 1462 		cat << !EOM
 1463 	(A)	Abort installation (don't do anything)
 1464 	(Q)	==> Finish installation
 1465 
 1466 !EOM
 1467 	else
 1468 		proceed=true
 1469 		cat << !EOM
 1470 	(T)	Print Test Page
 1471 	(V)	View performance log (times of print attempts)
 1472 
 1473 	(A)	Abort installation (don't do anything)
 1474 	(I)	==> Install printer with values shown above - repeat this
 1475 		    step for installing multiple printers
 1476 	(Q)	==> Finish installation
 1477 
 1478 !EOM
 1479 	fi
 1480 	echo $n "        Your choice? $c"; read answer
 1481 	case $answer in
 1482 	    d|D)	show_gs_devices ;;
 1483 	    r|R)	do_pager setup/devices-$GS_BASE ;;
 1484 	    1)		do_choose_driver ;;
 1485 	    2)		do_setup_interface ;;
 1486 	    3)		do_setup_paper_format ;;
 1487 	    4)		do_choose_quality ;;
 1488 	    5)		do_choose_color ;;
 1489 	    6)		do_choose_resolution ;;
 1490 	    7)		do_choose_method ;;
 1491 	    t|T)	[ "$proceed" ] && do_print_test_menue ;;
 1492 	    v|V)	[ "$proceed" ] && do_view_perflog ;;
 1493 	    a|A)	exit 1 ;;
 1494 	    i|I)	[ "$proceed" ] && MENU_DONE=true ;;
 1495 	    q|Q)	FINISH_SETUP=true; MENU_DONE=true ;;
 1496 	esac
 1497     done
 1498 }
 1499 
 1500 ##############################################################################
 1501 # full check for permissions of files and directories
 1502 # only call this when being root
 1503 ##############################################################################
 1504 do_check_permissions()
 1505 {
 1506     clear
 1507     echo "Checking permissions of $APS_BASEDIR"
 1508 
 1509     DIR_OWNER=`ls -lgd | "$AWK" '{ print $3 }'`
 1510     DIR_GROUP=`ls -lgd | "$AWK" '{ print $4 }'`
 1511     case $DIR_OWNER in
 1512 	root|daemon|bin|lp)
 1513 	    # ok, secure directory owner found
 1514 	    echo "found dir owner=$DIR_OWNER, ok!" ;;
 1515 	*)
 1516 	    # set secure directory owner
 1517 	    echo "found dir owner=$DIR_OWNER, not ok!"
 1518 	    echo "setting dir owner=bin!"
 1519 	    DIR_OWNER=bin ;;
 1520     esac
 1521     case $DIR_GROUP in
 1522 	root|wheel|other|bin|lp)
 1523 	    # ok, secure directory group found
 1524 	    echo "found dir group=$DIR_GROUP, ok!" ;;
 1525 	*)
 1526 	    # set secure directory group
 1527 	    echo "found dir group=$DIR_OWNER, not ok!"
 1528 	    echo "setting dir group=bin!"
 1529 	    DIR_GROUP=bin ;;
 1530     esac
 1531 
 1532     # after having set sane defaults, fix permissions
 1533     echo $n "changing permissions of $APS_BASEDIR... $c"
 1534     chmod 555 .
 1535     chown -R $DIR_OWNER:$DIR_GROUP .
 1536     find . -type d -print | xargs chmod 555
 1537     find . -type f -print | xargs chmod a+r,a-w
 1538     echo "done."
 1539     echo
 1540     echo "Now we are checking file permissions in spooldir"
 1541 
 1542     set -- `ls -ld "$SPOOL"`
 1543     LP_OWNER=$3; LP_GROUP=$4
 1544 
 1545     while [ ! "$PERM_OK" ]; do
 1546 	echo
 1547 	echo "Your line printer scheduler's spooldir seems to be: $SPOOL"
 1548 	echo
 1549 	ls -ld "$SPOOL"
 1550 	echo
 1551 	echo "The Owner of your spooldir seems to be: $LP_OWNER"
 1552 	echo "The Group of your spooldir seems to be: $LP_GROUP"
 1553 	echo
 1554 	echo $n "Is this correct? [y/n] $c"; read answer
 1555 	case $answer in
 1556 	    n|N)
 1557 		# ask the user
 1558 		echo $n "Path of Spool Dir? [default: $SPOOL] $c"
 1559 		read $read_r answer
 1560 		[ "$answer" ] && SPOOL="$answer"
 1561 		mkdir -p "$SPOOL"
 1562 
 1563 		echo $n "Owner of Spool Dir? [default: $LP_OWNER] $c"
 1564 		read $read_r answer
 1565 		[ "$answer" ] && LP_OWNER="$answer"
 1566 
 1567 		echo $n "Group of Spool Dir? [default: $LP_GROUP] $c"
 1568 		read $read_r answer
 1569 		[ "$answer" ] && LP_GROUP="$answer"
 1570 		;;
 1571 	    *)
 1572 		# o.k., do nothing
 1573 		PERM_OK=1
 1574 		;;
 1575 	esac
 1576     done
 1577 }
 1578 
 1579 ##############################################################################
 1580 # Save printcap
 1581 #	- save the original printcap		-> printcap.orig
 1582 #	- make a work copy of the printcap file -> printcap.old
 1583 ##############################################################################
 1584 do_save_printcaps()
 1585 {
 1586     echo
 1587     if [ -f "@printcap@" ]; then
 1588 	if [ ! -f "@printcap@.orig" ]; then
 1589 	    echo "saving original printcap -> @printcap@.orig"
 1590 	    cp "@printcap@" "@printcap@.orig"
 1591 	fi
 1592 	echo "creating a working copy of printcap -> @printcap@.old"
 1593 	cp "@printcap@" "@printcap@.old"
 1594     else
 1595 	touch "@printcap@"
 1596     fi
 1597 }
 1598 
 1599 ##############################################################################
 1600 # Was printcap already created by apsfilter?
 1601 # If so: keep entries or overwrite?
 1602 ##############################################################################
 1603 do_check_for_old_apsfilter_installation()
 1604 {
 1605     if [ -d "$CONF_DIR" ]; then
 1606 	if [ -d "$CONF_DIR/basedir" ]; then
 1607 	    OLD_BASEDIR=$(ls -l "$CONF_DIR/basedir" | sed 's/.*-> //')
 1608 	    if [ "$APS_BASEDIR" != "$OLD_BASEDIR" ]; then
 1609 		echo
 1610 		echo "WARNING! A previous installation of apsfilter is located"
 1611 		echo "in '$OLD_BASEDIR'."
 1612 		echo
 1613 		echo $n "Do you want to continue? $c"; read answer
 1614 		case $answer in
 1615 		    n|N)  exit 1 ;;
 1616 		esac
 1617 	    fi
 1618 	fi
 1619 	echo
 1620 	echo "It seems you have configured a printer with this script before."
 1621 	echo
 1622 	echo "Do you want to (a)dd another printer entry or"
 1623 	echo "            to (o)verwrite the existing entries?"
 1624 	echo $n "a/o? $c"; read answer
 1625 	
 1626 	case $answer in
 1627 	    o|O)
 1628 		echo "Ok, erasing old apsfilter entries..."
 1629 		sed -e "/# APS.*BEGIN/,/# APS.*END/ d" \
 1630 		    < "@printcap@.old" > "@printcap@"
 1631 		chmod 644 "@printcap@"
 1632 		;;
 1633 	    *)
 1634 		echo "Ok, adding another apsfilter printer..."
 1635 		;;
 1636 	esac
 1637     fi
 1638 }
 1639 
 1640 ##############################################################################
 1641 # The real work:
 1642 #	- create printer configuration directory under $CONF_DIR
 1643 #	- install filter link in that directory
 1644 #	- create printer specific configuration file
 1645 ##############################################################################
 1646 
 1647 do_install_filter()
 1648 {
 1649     clear
 1650 
 1651     #
 1652     # Determine highest number of Apsfilter Printer in printcap
 1653     #
 1654     PRINTER_ENTRIES=`grep "APS.*_BEGIN" "@printcap@" | sort -n`
 1655     PRINTER_ENTRIES=${PRINTER_ENTRIES##*printer}
 1656     N=`expr ${PRINTER_ENTRIES:-0} + 1` 
 1657 
 1658     { # create printer start label
 1659 	echo "# APS${N}_BEGIN:printer$N"
 1660 	echo "# - don't delete start label for apsfilter printer$N"
 1661 	echo "# - no other printer defines between BEGIN and END LABEL"
 1662     } >> "@printcap@"
 1663 
 1664     while :; do
 1665 	# set printer queue name; use "lp" if not already present
 1666 	if grep -E "^lp[|:]|^[^#].*\|lp[|:]" "@printcap@" >/dev/null; then
 1667 	    nr=1  # get a free "aps$nr" printer name
 1668 	    while grep -E "^aps${nr}[|:]|^[^#].*\|aps${nr}[|:]" "@printcap@" >/dev/null; do
 1669 		nr=`expr $nr + 1`
 1670 	    done
 1671 	    QUEUE="aps$nr"
 1672 	else
 1673 	    QUEUE=lp
 1674 	fi
 1675 	cat <<EOF
 1676 
 1677 Please enter a printer queue name for printer '$PRINTER'.
 1678 The default name is '$QUEUE'.
 1679 
 1680 EOF
 1681 	echo $n "Your choice: $c"; read $read_r answer
 1682 	[ "$answer" ] && QUEUE="$answer"
 1683 
 1684 	if grep -E "^${QUEUE}[|:]|^[^#].*\|${QUEUE}[|:]" "@printcap@" >/dev/null
 1685 	then
 1686 	    echo
 1687 	    echo "I'm sorry, but '$QUEUE' is already in use."
 1688 	else
 1689 	    break
 1690 	fi
 1691     done
 1692 
 1693     # create configuration directory for this printer and cd into it
 1694     mkdir -p "$CONF_DIR/$QUEUE"
 1695     cd "$CONF_DIR/$QUEUE"
 1696 
 1697     # printer name in printcap
 1698     echo "** creating printcap entry for printer $QUEUE..."
 1699 
 1700     { # append following output to printcap
 1701 
 1702 	echo "$QUEUE|$PRINTER;r=$RESOLUTION;q=$QUALITY;c=$COLOR;p=$PAPER;m=$METHOD:\\"
 1703 
 1704 	# interface configuration
 1705 	case $INTERFACE in
 1706 	    parallel)
 1707 		echo "    :lp=$DEVICE:\\"
 1708 		;;
 1709 	    serial)
 1710 		echo "    :lp=$DEVICE:\\"
 1711 		echo "    :br#$BAUD:\\"
 1712 		echo "    :ms=ixon,-imaxbel,-ixany,-ixoff,-crtscts:\\"
 1713 		;;
 1714 	    network)
 1715 		echo "    :lp=:\\"
 1716 		echo "    :rm=$rm:\\"
 1717 		echo "    :rp=$rp:\\"
 1718 		;;
 1719 	    samba|atalk|netware|sound)
 1720 		echo "    :lp=/dev/null:\\"
 1721 		;;
 1722 	esac
 1723 
 1724 	# filter and spooldir configuration in printcap
 1725 	echo "    :if=$CONF_DIR/basedir/bin/apsfilter:\\"
 1726 	SPOOLDIR="$SPOOL/$QUEUE"
 1727 	echo "    :sd=$SPOOLDIR:\\"
 1728 
 1729 	# logfile configuration in printcap
 1730 	echo "    :lf=$SPOOLDIR/log:\\"
 1731 
 1732 	# accounting file configuration in printcap
 1733 	echo "    :af=$SPOOLDIR/acct:\\"
 1734 
 1735 	# no size limitation for printjob in printcap
 1736 	echo "    :mx#0:\\"
 1737 
 1738 	# suppress formfeed when printing raw
 1739 	[ "$METHOD" = raw ] && echo "    :sf:\\"
 1740 
 1741 	# last entry, suppress printing of burst page
 1742 	echo "    :sh:"
 1743 
 1744 	# create printer end label
 1745 	echo "# APS${N}_END - don't delete this"
 1746     } >> "@printcap@"
 1747 
 1748     # create spooldir in Unix filesystem
 1749     echo "   creating spooldir ..."
 1750     mkdir -m 755 -p "$SPOOLDIR"
 1751     # maybe chmod knows "--reference" to clone the permissions
 1752     chmod --reference="$SPOOL" "$SPOOLDIR" 2>/dev/null
 1753 
 1754     # create needed empty files under Spooldir
 1755     : > "$SPOOLDIR/log"
 1756     : > "$SPOOLDIR/acct"
 1757 
 1758     # that's needed specially for Linux Slackware
 1759     : > "$SPOOLDIR/lock"
 1760     chmod 664 "$SPOOLDIR/lock"
 1761 
 1762     # set sane permissions for spooldir
 1763     [ `id -u` -eq 0 ] && chown -R $LP_OWNER:$LP_GROUP "$SPOOLDIR"
 1764 
 1765     if [ "$INTERFACE" = samba ]; then
 1766 	echo "   creating samba config file ..."
 1767 
 1768 	{ # write all output to smbclient.conf
 1769 
 1770 	    echo "SMB_SERVER='$SMB_SERVER'"
 1771 	    echo "SMB_IP='$SMB_IP'"
 1772 	    echo "SMB_PRINTER='$SMB_PRINTER'"
 1773 	    echo "SMB_WORKGROUP='$SMB_WORKGROUP'"
 1774 	    echo "SMB_BUFFER=1400"
 1775 	    echo "SMB_FLAGS='-N'"
 1776 
 1777 	    # print on remote windows machine as real user...
 1778 	    if [ "$SMB_USER" ]; then
 1779 		echo "SMB_USER='$SMB_USER'"
 1780 		echo "SMB_PASSWD='$(echo $SMB_PASSWD | sed "s/'/'\\\''/g")'"
 1781 	    fi
 1782 
 1783 	} > smbclient.conf
 1784 
 1785 	# protect smbclient file, if it contains password information
 1786 	if [ "$SMB_PASSWD" ]; then
 1787 	    echo "   read protect password information..."
 1788 	    chmod $PASSWD_PROTECT smbclient.conf
 1789 	    chown $LP_OWNER:$LP_GROUP smbclient.conf
 1790 	fi
 1791     elif [ "$INTERFACE" = atalk ]; then
 1792 	echo "   creating AppleTalk config file ..."
 1793 	echo "PAP_NBPNAME='$PAP_NBPNAME'" > pap.conf
 1794     elif [ "$INTERFACE" = netware ]; then
 1795 	echo "   creating NetWare config file ..."
 1796 	{
 1797 	    echo "NCP_SERVER='$NCP_SERVER'"
 1798 	    echo "NCP_PRINTER='$NCP_PRINTER'"
 1799 	    echo "NCP_USER='$NCP_USER'"
 1800 	    echo "NCP_PASSWD='$(echo $NCP_PASSWD | sed "s/'/'\\\''/g")'"
 1801 	} > netware.conf
 1802 
 1803 	# protect netware file if it contains password information
 1804 	if [ "$NCP_PASSWD" ]; then
 1805 	    echo "   read protect password information..."
 1806 	    chmod $PASSWD_PROTECT netware.conf
 1807 	    chown $LP_OWNER:$LP_GROUP netware.conf
 1808 	fi
 1809     fi
 1810 
 1811     # Save some settings from this SETUP session
 1812     echo "   remember SETUP settings in printers apsfilterrc file..."
 1813 
 1814     {
 1815 	echo "#"
 1816 	echo "# don't delete these settings"
 1817 	echo "#"
 1818 	echo "PRINTER='$PRINTER'"
 1819 	echo "PAPERSIZE='$PAPER'"
 1820 	echo "METHOD='$METHOD'"
 1821 	echo "QUALITY='$QUALITY'"
 1822 	echo "COLOR='$COLOR'"
 1823 	echo "RESOLUTION='$RESOLUTION'"
 1824 	echo "# apsfilter as jukebox"
 1825 	echo "# important if audio playback device is a network print queue"
 1826 	echo "# INTERFACE='network'"
 1827 	echo "INTERFACE='$INTERFACE'"
 1828 	echo
 1829 	echo "#"
 1830 	echo "# additional configuration follows"
 1831 	echo "# insert settings as seen in $CONF_DIR/apsfilterrc"
 1832 	echo "#"
 1833 	[ "$PS_INIT" ] && echo "PS_INIT='$PS_INIT'"
 1834     } > apsfilterrc
 1835 
 1836     # in case LPRng is used: checkpc does a nice cleanup
 1837     type checkpc > /dev/null 2>&1 && checkpc -f >/dev/null 2>&1
 1838 
 1839     echo "** done."
 1840     echo
 1841     echo $n "[ press <RETURN> to continue ] $c"; read answer
 1842     cd "$APS_BASEDIR"
 1843 }
 1844 
 1845 
 1846 #
 1847 # print error message and quit
 1848 #
 1849 fail()
 1850 {
 1851     echo >&2 "SETUP error: $@"
 1852     exit 1
 1853 }
 1854 
 1855 #####################################################
 1856 #####################################################
 1857 #####################################################
 1858 ####                                             ####
 1859 ####                 M A I N                     ####
 1860 ####                                             ####
 1861 #####################################################
 1862 #####################################################
 1863 #####################################################
 1864 
 1865 export APS_BASEDIR="@datadir@/apsfilter"
 1866 cd "$APS_BASEDIR"
 1867 CONF_DIR="@sysconfdir@/apsfilter"
 1868 SPOOL="@spooldir@"
 1869 
 1870 # check read/write permissions
 1871 [ -w . ] || fail "no write access to $APS_BASEDIR"
 1872 if [ -d "$CONF_DIR" ]; then
 1873     [ -w "$CONF_DIR" ] || fail "no write access to $CONF_DIR"
 1874 elif [ -d "@sysconfdir@" ]; then
 1875     [ -w "@sysconfdir@" ] || fail "no write access to @sysconfdir@"
 1876 else
 1877     mkdir -p "@sysconfdir@" || fail "couldn't create @sysconfdir@"
 1878 fi
 1879 if [ -f "@printcap@" ]; then
 1880     [ -r "@printcap@" -a -w "@printcap@" ] || fail "no r/w access to @printcap@"
 1881 fi
 1882 printcap_dir=`dirname "@printcap@"`
 1883 if [ -d "$printcap_dir" ]; then
 1884     [ -w "$printcap_dir" ] || fail "no write access to $printcap_dir"
 1885 else
 1886     mkdir -p "$printcap_dir" || fail "couldn't create $printcap_dir"
 1887 fi
 1888 if [ -d "$SPOOL" ]; then
 1889     [ -w "$SPOOL" ] || fail "no write access to $SPOOL"
 1890 else
 1891     mkdir -p "$SPOOL" || fail "couldn't create $SPOOL"
 1892     [ `id -u` -eq 0 ] && { chown lp "$SPOOL" || chown daemon "$SPOOL"; }
 1893 fi
 1894 
 1895 
 1896 # check if we must use the "-r" flag for "read" operations
 1897 if echo dummy | read -r dummy 2>/dev/null; then
 1898     read_r="-r"
 1899 else
 1900     unset read_r
 1901 fi
 1902 
 1903 # how to suppress newlines on echo
 1904 if echo "\c" | grep -c . >/dev/null; then
 1905     n='-n'; c=''
 1906 else
 1907     n=''; c='\c'
 1908 fi
 1909 
 1910 do_check_gs_version
 1911 do_copyright
 1912 
 1913 # some people got nerved, me too ;-)
 1914 if [ -f "$CONF_DIR/.requested_snailmail" ]; then
 1915     echo "You already requested my snailmail address to write a postcard"
 1916     echo $n "Request it again? [y/n] $c"; read answer
 1917     case $answer in
 1918 	y|Y|j|J)    do_request_snailmail ;;
 1919     esac
 1920 else
 1921     do_request_snailmail
 1922 fi
 1923 
 1924 do_start
 1925 
 1926 # provide some (more or less) sane default values
 1927 PRINTER=
 1928 PAPER=
 1929 INTERFACE=
 1930 DEVICE=
 1931 QUALITY=medium
 1932 COLOR=full
 1933 RESOLUTION=300x300
 1934 METHOD=auto
 1935 MEDIA=plain
 1936 
 1937 # read old settings from SETUP.cfg if present
 1938 [ -f "$CONF_DIR/SETUP.cfg" ] && . "$CONF_DIR/SETUP.cfg"
 1939 
 1940 # do a full check when being root
 1941 [ `id -u` -eq 0 ] && do_check_permissions
 1942 
 1943 # prepare filter installation
 1944 clear
 1945 do_save_printcaps
 1946 do_check_for_old_apsfilter_installation
 1947 
 1948 # Create - an apsfilter directory under /etc (if not already present)
 1949 #        - a link $CONF_DIR/basedir -> APS_BASEDIR
 1950 #        - a global configuration file (if not already present)
 1951 mkdir -p -m 755 "$CONF_DIR"
 1952 rm -f "$CONF_DIR/basedir"
 1953 ln -s "$APS_BASEDIR" "$CONF_DIR/basedir"
 1954 [ -f "$CONF_DIR/apsfilterrc" ] || cp template/apsfilterrc "$CONF_DIR"
 1955 
 1956 
 1957 #
 1958 # Main loop
 1959 #
 1960 do_main_menue
 1961 while [ -z "$FINISH_SETUP" ]; do
 1962     do_install_filter
 1963     do_main_menue
 1964 done
 1965 
 1966 
 1967 ##############################################################################
 1968 # End of creating
 1969 # - printcap entries
 1970 # - filesystem operations (spooldir, symlink, ... -creation)
 1971 ##############################################################################
 1972 
 1973 ##############################################################################
 1974 #
 1975 # now proceed with installation, save environment
 1976 
 1977 do_save_environment
 1978 
 1979 clear
 1980 cat <<EOF
 1981 
 1982 Finished creating/updating @printcap@ and $CONF_DIR/ ...
 1983 
 1984 
 1985 To let the printer scheduler know of the new printers, it has to be
 1986 restarted. Be sure that no print jobs are in the queue.
 1987 
 1988 For LPRng use:  lpc reread
 1989 For *BSD  use:  lpc restart all
 1990 
 1991 For Linux BSD-lpr use the vendor supplied script, i.e.:
 1992     /etc/rc.d/init.d/lpd restart
 1993 or similar.
 1994 
 1995 
 1996 Now some important news/information follow...
 1997 
 1998 Please read them carefully!
 1999 
 2000 [ press <RETURN> to continue ]
 2001 EOF
 2002 read answer
 2003 
 2004 clear
 2005 cat << !EOM
 2006     _/      _/
 2007    _/_/    _/   _/_/   _/      _/      _/   _/_/_/
 2008   _/  _/  _/ _/_/_/_/ _/      _/      _/ _/_/
 2009  _/    _/_/ _/         _/  _/  _/  _/       _/_/
 2010 _/      _/   _/_/_/     _/      _/     _/_/_/
 2011 
 2012 	See the ANNOUNCE and ChangeLog files for more informations.
 2013 	New: read the manual pages apsfilter(1) and apsfilterrc(5)
 2014 
 2015 	New CLASS support (lpr -C) allows you to set one ore more options
 2016 	for gs (PS Emulator), separated by colons (":").
 2017 
 2018 	CLASS support is currently available for some gs drivers. Look into
 2019 	apsfilter script, which driver dependent options are supported.
 2020 
 2021 	Example: stcolor print driver: set 
 2022 		- print resolution to high resolution (720dpi)
 2023 		- color depth to 30 bits per pixel
 2024 
 2025 	  lpr -C high:30bpp file1..fileN
 2026 
 2027 !EOM
 2028 echo $n "[ press <RETURN> to continue ]$c"; read answer
 2029 
 2030 clear
 2031 cat << !EOM
 2032     _/      _/
 2033    _/_/    _/   _/_/   _/      _/      _/   _/_/_/
 2034   _/  _/  _/ _/_/_/_/ _/      _/      _/ _/_/
 2035  _/    _/_/ _/         _/  _/  _/  _/       _/_/
 2036 _/      _/   _/_/_/     _/      _/     _/_/_/
 2037 
 2038 	New: apsfilterrc config files per single printer!
 2039 	New: name and location change in apsfilterrc config files!
 2040 	New: manual page for apsfilter(1) and apsfilterrc(5) config files!
 2041 
 2042 	A) global apsfilter config file, set by admin
 2043 		$CONF_DIR/apsfilterrc
 2044 
 2045 	B) printer specific config file for printer N, set by admin
 2046 		$CONF_DIR/QUEUE/apsfilterrc
 2047 
 2048 	C) user supplied config options on per printer basis, set by admin
 2049 		$CONF_DIR/QUEUE/apsfilterrc.USER
 2050 
 2051 	D) user controllable config file on per printer basis;
 2052 	   *SECURITY*HOLE*, needs USE_USER_CODE set in A), B) or C)
 2053 		$HOME/.apsfilter/apsfilterrc.QUEUE
 2054 
 2055 !EOM
 2056 echo $n "[ press <RETURN> to continue ]$c"; read answer
 2057 
 2058 clear
 2059 cat << !EOM
 2060     _/      _/
 2061    _/_/    _/   _/_/   _/      _/      _/   _/_/_/
 2062   _/  _/  _/ _/_/_/_/ _/      _/      _/ _/_/
 2063  _/    _/_/ _/         _/  _/  _/  _/       _/_/
 2064 _/      _/   _/_/_/     _/      _/     _/_/_/
 2065 
 2066 	For printing ASCII files apsfilter now uses a2ps V. 4.12 or higher.
 2067 	Old patched a2ps and rewindstdin have gone!
 2068 
 2069 	You can also use mpage or recode; see apsfilterrc for this setting.
 2070 
 2071 	remote printing is fully supported by apsfilter:
 2072 	- on Unix remote printer (lpd) and
 2073 	- Windows 95/98/NT/2000 Remote Printer
 2074 
 2075 !EOM
 2076 echo $n "[ press <RETURN> to continue ]$c"; read answer
 2077 
 2078 clear
 2079 cat << !EOM
 2080                                                 _/
 2081    _/  _/_/   _/_/   _/_/_/  _/_/     _/_/   _/_/_/_/   _/_/
 2082   _/_/     _/_/_/_/ _/    _/    _/ _/    _/   _/     _/_/_/_/
 2083  _/       _/       _/    _/    _/ _/    _/   _/     _/
 2084 _/         _/_/_/ _/    _/    _/   _/_/       _/_/   _/_/_/ _/ _/ _/
 2085 
 2086 You need SAMBAs smbclient utility, to print on Windows remote printer.
 2087 SETUP makes the necessary entries in printcap(5).
 2088 
 2089 You need a line printer scheduler (fixed lpd or LPRng) on your system
 2090 that allows to use input filters (printcap: if=...) when printing
 2091 to remote printers (printcap: rm:..., rp:...)
 2092 
 2093 FreeBSD 3.x and later have a fixed lpd, no problem here.
 2094 
 2095 Otherwise use the lpd successor LPRng (lineprinter next generation)
 2096 or configure lpr.conf in the lineprinters spool directory (new!)
 2097 
 2098 !EOM
 2099 echo $n "[ press <RETURN> to continue ]$c"; read answer
 2100 
 2101 clear
 2102 cat << !EOM
 2103     _/_/_/                     _/
 2104    _/    _/   _/_/     _/_/_/      _/_/_/ _/_/_/
 2105   _/    _/ _/_/_/_/ _/_/     _/ _/    _/ _/    _/
 2106  _/    _/ _/           _/_/ _/ _/    _/ _/    _/
 2107 _/_/_/     _/_/_/ _/_/_/   _/   _/_/_/ _/    _/ _/ _/ _/
 2108                                    _/
 2109                               _/_/
 2110 
 2111 Apsfilter can be installed on a Server or Desktop machine. Best is to install
 2112 it on a dedicated Server, where printers are locally connected to, since
 2113 ghostscript Postscript emulation might become a CPU intensive process. The
 2114 faster the CPU, the faster the Postscript emulation and printing in general.
 2115 
 2116 If you want to print on Network printer using the lpd protocol, you should
 2117 install apsfilter on a machine which has a fixed lineprinter scheduler and
 2118 is able to use input filters (apsfilter) when printing to a remote printer.
 2119 FreeBSD 3.x and later has a fixed lpd, otherwise use the lpd successor LPRng.
 2120 
 2121 Since apsfilter 5.2.0 you can also print to Windows remote printers, that
 2122 are printers on Windows machines, which are shared in the network. You need
 2123 to install SAMBA on the Unix apsfilter hosts, who want to use Windows printers.
 2124 
 2125 !EOM
 2126 echo $n "[ press <RETURN> to continue ]$c"; read answer
 2127 
 2128 clear
 2129 cat << !EOM
 2130     _/_/_/
 2131    _/    _/ _/  _/_/   _/_/   _/_/_/  _/_/     _/_/
 2132   _/_/_/   _/_/     _/    _/ _/    _/    _/ _/    _/
 2133  _/       _/       _/    _/ _/    _/    _/ _/    _/
 2134 _/       _/         _/_/   _/    _/    _/   _/_/   _/ _/ _/
 2135 
 2136 I'd really like to get some mails from you, 
 2137 	- why you like apsfilter
 2138 	- how apsfilter saved your or your companies printing problems
 2139 
 2140 Please send apsfilter promotion e-mails to the following e-mail address:
 2141 	apsfilter-promo@apsfilter.org
 2142 
 2143 In return you get the possibility to introduce you and your company
 2144 and how apsfilter solved your or your companies printing problems ;-)
 2145 
 2146 !EOM
 2147 echo $n "[ press <RETURN> to continue ]$c"; read answer
 2148 
 2149 clear
 2150 cat << !EOM
 2151      _/_/_/  _/  _/    _/_/_/    _/    _/
 2152   _/        _/  _/    _/    _/      _/_/_/_/    _/_/_/
 2153  _/_/_/    _/_/_/_/  _/_/_/    _/    _/      _/_/
 2154 _/    _/      _/    _/    _/  _/    _/          _/_/
 2155  _/_/        _/    _/_/_/    _/      _/_/  _/_/_/
 2156 
 2157 Our band "64Bits":
 2158 Please visit our band's homepage, from there you get band
 2159 informations and you can download cool songs.
 2160 
 2161 Official band pages:
 2162 	http://www.64bits.de/
 2163 
 2164 Inofficial band pages:
 2165 	http://www.apsfilter.org/64bits.html
 2166 
 2167 Please send us e-mail, how you find the song, etc.
 2168 Since we only have few time to probe because of job (you know ;-)
 2169 we currently are unable to make live concerts.
 2170 
 2171 So YOU are our virtual audience and we'd LOVE to get some feedback ;-)
 2172 Thanks!
 2173 
 2174 !EOM
 2175 echo $n "[ press <RETURN> to continue ]$c"
 2176 read answer
 2177 
 2178 #
 2179 # This for the last screen with most important infos...
 2180 #
 2181 clear
 2182 cat << !EOM
 2183 
 2184 ============================
 2185 Apsfilter Internet Resources
 2186 ============================
 2187 
 2188 Apsfilter's homepage (News, Updates, Patches, ...):
 2189 
 2190 	http://www.apsfilter.org/
 2191 
 2192 Read the ANNOUNCE file about Apsfilter Internet Resources
 2193 and how to use them:
 2194 
 2195 	- Apsfilter developement machine
 2196 	- Apsfilter mailing lists
 2197 	- Apsfilter CVS repository
 2198 	- Apsfilter Anonymous CVS server
 2199 	- Apsfilter CVS repository browser (cvsweb, enhanced Zeller version)
 2200 
 2201 Please report questions and bugs to the offical apsfilter help channel:
 2202 
 2203 	apsfilter-help@apsfilter.org
 2204 
 2205 *** SETUP done ***
 2206 !EOM
 2207 
 2208 exit 0