home *** CD-ROM | disk | FTP | other *** search
- :
- # Install psf filters on AT&T Unix 3.2.2 (install.unix)
- #
- # NOTE: if a different version of unix is used, this script
- # may need modification.....
- #
- # If AT&T Unix 3.2.2 is used and FACE is available, then
- # the FACE printer database can be updated if the
- # option "-f" is provided on the command line. The -f
- # should be used for both installation and removal of psf.
- #
- # Install.unix -f
- #
- # note: this script records configuration parameters in
- # various ".cfg" files in the current directory.
- # it also expects some .cfg files to be created
- # by "selectdef".
-
- PATH=.:/bin:/usr/bin:/etc
-
- # ----------------------------------------------
- # beginning of things that may need modification
-
-
- # Define the destination directory of the psf binaries and scripts
- # and the print spooler directory
-
- BINDIR="/usr/local/bin"
- SPOOLDIR="/usr/spool/lp"
-
- # Unix lp printer systems files...
- # The directory structure follows AT&T unix 3.2.2 conventions.
- # Other unix systems may be different.
- # If you are not using AT&T Unix with FACE installed, then
- # ignore the reference to DATABASE.
-
- DEFDIR="/usr/spool/lp/model/psfprint.def"
- MODEL="$SPOOLDIR/model"
- DATABASE="/usr/vmsys/admin/PS/PORTSET/database"
-
- # Specify the man pages directory. If you are using a system
- # without man pages, ignore these entires.
- #
- # Xenix uses man directories that look like /usr/man/man.1
- # If your directories do NOT use the dot (e.g. man1)
- # format, then remove the "." in the definitions below.
-
- MANDIR="/usr/man/man."
- CATDIR="/usr/man/cat."
- MANCHAP="1"
-
- # ------------------------------------------
- # The following should not need modification
-
- DEFFILES="defs/*.def"
- PAGESIZE="undefined"
- PNAME="undefined"
- MODELNAME="psf"
-
- # Create an entry line that will go into the FACE printer
- # selection data base in $DATABASE (for AT&T unix 3.2.2)
- # If the $DATABASE file does not exist, then the following
- # is ignored.
-
- PRINTERDBS="Postscript-PSF 435_table psf postscript tabs ixon ixoff onlcr"
- PRINTERID="Postscript-PSF"
-
- case ${1} in
- -f) ;;
- *) DATABASE="z9+notHeRe"
- ;;
- esac
-
- # PSF distribution files
-
- BINARIES="psf pnf pmf psd psbanner psdetect"
- MANS="psf.1 pnf.1 pmf.1 psd.1 psmbox.1 psman.1 psnroff.1"
- DOCS="psf.doc pnf.doc pmf.doc psd.doc psmbox.doc psman.doc psnroff.doc"
- SCRIPTS="psmbox psman psmandouble psnroff"
-
- # See if the man-page directory really exists
-
- HAVEMAN=
- if test ! -d $MANDIR$MANCHAP
- then
- MANCHAP="Not.Allowed"
- HAVEMAN="(missing directory)"
- fi
-
- # get existing psf installation parameters
-
- if test -f Pmanchap.cfg
- then
- MANCHAP=`cat -s Pmanchap.cfg`
- fi
-
- if test -f Pbindir.cfg
- then
- BINDIR=`cat -s Pbindir.cfg`
- fi
-
- if test -f PPagesize.cfg
- then
- PAGESIZE=`cat -s Ppagesize.cfg`
- fi
- if test -f Ppsfprint.cfg
- then
- PNAME=`cat -s Ppsfprint.cfg`
- fi
-
- # Define return values
-
- : ${OK=0} ${FAIL=1} ${STOP=10} ${HALT=11}
-
-
- # Print an error message
- error() {
- echo "\nError: $*" >&2
- return 1
- }
-
- # Prompt with mesg, return non-zero on q
- prompt() {
- while echo "\n${mesg}or enter q to $quit: \c" >&2
- do read cmd
- case $cmd in
- +x|-x) set $cmd ;;
- Q|q) return 1 ;;
- !*) eval `expr "$cmd" : "!\(.*\)"` ;;
- "") # If there is an argument use it as the default
- # else loop until 'cmd' is set
- [ "$1" ] && {
- cmd=$1
- return 0
- }
- : continue
- ;;
- *) return 0 ;;
- esac
- done
- }
-
-
- showstats () {
- echo "\nPSF INSTALLATION OPTIONS SELECTED"
- echo "--------------------------------"
- echo "printer selected from: $PNAME"
- echo "printer page size is: $PAGESIZE"
- echo "psf default options: $PSFOPT"
- echo "banner options: $BANNEROPT"
- echo "binaries and scripts in: $BINDIR"
- echo "man pages in chapter: $MANCHAP"
- }
-
- # Copy the psf binares and scripts to target binary directory
-
- createprinter () {
- bdir="$BINDIR"
- echo " "
- echo "Install PSF binaries and"
- ./query " scripts in which directory [$bdir]? "
- read bdir
- case "$bdir" in
- '') ;;
- *) BINDIR="$bdir"
- ;;
- esac
- if test ! -d $BINDIR
- then
- echo "\nDirectory $BINDIR does not exist."
- echo "Create the directory and re-start the installation.\n"
- exit $FAIL
- fi
- echo "$BINDIR" > Pbindir.cfg
- cp $BINARIES $BINDIR
- cp $SCRIPTS $BINDIR
- rm -f psf.model
- sed "s@BINARY@$BINDIR@g" psfunix.LP | sed "s@OPTIONS@$PSFOPT@g" \
- | sed "s@BANNER@$BANNEROPT@g" > psf.model
- chmod +rw psf.model
- echo "psf binaries and scripts have been copied to $BINDIR"
- showstats
- return 0
- }
-
-
- # Copy the psf model and control files to the spool directory.
-
- movefiles () {
- cp psf.model $MODEL/$MODELNAME
- cp $PNAME $DEFDIR
- chown lp $MODEL/$MODELNAME $DEFDIR
- chgrp bin $MODEL/$MODELNAME $DEFDIR
-
- # If the FACE printer database exits, add the user provided the
- # -u option, then add a postscript printer to the database
-
-
- if test -f $DATABASE
- then
- echo "$PRINTERDBS" >> $DATABASE
- echo "FACE printer file $DATABASE",
- echo " has been updated with a psf printer definition."
- fi
- echo "lp spooler files are copied to:"
- echo " $MODEL/$MODELNAME"
- echo " $DEFDIR"
- showstats
- return 0
- }
-
-
- # Set up default page sizes for psf to be placed in the
- # lp spooling script files
-
- getsizes () {
- PAGESIZE=`cat -s Ppagesize.cfg`
- PNAME=`cat -s Ppsfprint.cfg`
- cp $PNAME psfprint.def
- case $PAGESIZE in
- DEFAULT) PSFOPT= ;;
- *) PSFOPT=`echo -g $PAGESIZE` ;;
- esac
- case $PAGESIZE in
- DEFAULT) BANNEROPT= ;;
- *) BANNEROPT=`echo -g $PAGESIZE` ;;
- esac
- return 0
- }
-
- replaceprinter () {
- selectdef $DEFFILES
- case $? in
- 0) ;;
- *) return $?
- esac
- getsizes
- return 0
- }
-
-
- manpages () {
- echo "\nNormally, man pages are not installed in AT&T unix 3.2.* systems."
- echo "If you have an on-line man system using 'man', then you may proceed"
- echo "with the man page installation. If you do not have the man system,"
- echo "then specify 'none' for the man page chapter..."
- cdir="$MANCHAP"
- echo " "
- ./query "Which chapter should be used for the PSF man pages [$cdir]? "
- read cdir
- case "$cdir" in
- '') ;;
- none) return 0
- ;;
- *) MANCHAP="$cdir"
- ;;
- esac
- if test ! -d $MANDIR$MANCHAP
- then
- echo "\nDirectory $MANDIR$MANCHAP does not exist."
- echo "Select a different directory or quit and create the"
- echo "desired directory.\n"
- return 0
- fi
-
- cp pmf.1 $MANDIR$MANCHAP/pmf.$MANCHAP
- cp pnf.1 $MANDIR$MANCHAP/pnf.$MANCHAP
- cp psf.1 $MANDIR$MANCHAP/psf.$MANCHAP
- cp psd.1 $MANDIR$MANCHAP/psd.$MANCHAP
- cp psman.1 $MANDIR$MANCHAP/psman.$MANCHAP
- cp psnroff.1 $MANDIR$MANCHAP/psnroff.$MANCHAP
- cp psmbox.1 $MANDIR$MANCHAP/psmbox.$MANCHAP
- man $MANCHAP pmf > /dev/null
- man $MANCHAP pnf > /dev/null
- man $MANCHAP psd > /dev/null
- man $MANCHAP psf > /dev/null
- man $MANCHAP psman > /dev/null
- man $MANCHAP psnroff > /dev/null
- man $MANCHAP psmbox > /dev/null
- echo "$MANCHAP" > Pmanchap.cfg
- echo "\nPSF man pages have been installed in $MANDIR$MANCHAP"
- return 0
- }
-
- # if the man-page directory exists print the manuals with
- # nroff output. if it does not exist, print from the
- # pre-formatted print files (using psf, of course...)
- # If the man page directory exists, ASSUME that nroff also exists...
-
- printman () {
- if test ! -d $MANDIR$MANCHAP
- then
- psf -2l 66 $DOCS | lp
- else
- psnroff -man $MANS
- fi
- return 0
- }
-
- removeall () {
- cdir="$MANCHAP"
- echo " "
- ./query "Remove PSF man pages from chapter [$cdir]? "
- read cdir
- case "$cdir" in
- '') ;;
- *) MANCHAP="$cdir"
- ;;
- esac
- if test ! -d $MANDIR$MANCHAP
- then
- echo "\nDirectory $MANDIR$MANCHAP does not exist."
- exit $FAIL
- fi
-
- bdir="$BINDIR"
- echo " "
- ./query "Remove PSF binaries+scripts from directory [$bdir]? "
- read bdir
- case "$bdir" in
- '') ;;
- *) BINDIR="$bdir"
- ;;
- esac
- if test ! -d $BINDIR
- then
- echo "\nDirectory $BINDIR does not exist."
- exit 1
- fi
-
- rm -f $MANDIR$MANCHAP/pmf.$MANCHAP
- rm -f $MANDIR$MANCHAP/pnf.$MANCHAP
- rm -f $MANDIR$MANCHAP/psf.$MANCHAP
- rm -f $MANDIR$MANCHAP/psd.$MANCHAP
- rm -f $MANDIR$MANCHAP/psman.$MANCHAP
- rm -f $MANDIR$MANCHAP/psnroff.$MANCHAP
- rm -f $MANDIR$MANCHAP/psmbox.$MANCHAP
-
- rm -f $CATDIR$MANCHAP/pmf.$MANCHAP
- rm -f $CATDIR$MANCHAP/pnf.$MANCHAP
- rm -f $CATDIR$MANCHAP/psf.$MANCHAP
- rm -f $CATDIR$MANCHAP/psd.$MANCHAP
- rm -f $CATDIR$MANCHAP/psman.$MANCHAP
- rm -f $CATDIR$MANCHAP/psnroff.$MANCHAP
- rm -f $CATDIR$MANCHAP/psmbox.$MANCHAP
-
- thisdir=`pwd`
-
- cd $BINDIR
- rm $BINARIES $SCRIPTS
-
- cd $thisdir
-
- rm $MODEL/$MODELNAME
- rm $DEFDIR
-
- # If the FACE printer database exits, remove the psf printer
- #NOTE should test to ensure that the copy was OK
- #^^^^
- # if test -f $PRINTERDBS
- # then
- # grep -v "$PRINTERID" $DATABASE > /tmp/Pdbs.Temp.Q
- # cp /tmp/Pdbs.Temp.Q $DATABASE
- # fi
- if test -f $DATABASE
- then
- grep "$PRINTERID" $DATABASE > /dev/null
- case $? in
- 0) echo "\nThe FACE printer data base file:"
- echo " $DATABASE"
- echo "should be manually edited to remove the reference to the"
- echo "psf printer identified as $PRINTERID"
- ;;
- *) ;;
- esac
- fi
-
- return 0
- }
-
-
- #
- # main()
- #
- echo "\n\tPSF: Postscript print filter installation\n"
- echo "Please ensure that the binary directory and other file references"
- echo "are consistent between this install script and the Makefile.\n"
- echo "NB: Install the printer with FACE and/or lpadmin befor printing manuals.\n"
- echo "Some of the following defaults (+) may be modified during installation.\n"
- echo "+ Binary directory: $BINDIR"
- echo " Spooling directory: $SPOOLDIR"
- echo " Printer model file: $MODEL/$MODELNAME"
- echo " Printer model name: $MODELNAME"
- if test -f $DATABASE
- then
- echo " FACE printer database file: $DATABASE"
- echo " Printer title in FACE is: $PRINTERID"
- fi
-
- if test -d $MANDIR$MANCHAP
- then
- echo "+ Man-page directory: $MANDIR$MANCHAP"
- if test -d $CATDIR$MANCHAP
- then
- echo " $CATDIR$MANCHAP"
- fi
- fi
-
- while
- mesg="\t1. Select printer type, make printer model files
- 2. Move psf binaries and scripts to $BINDIR
- 3. Move psf files to $SPOOLDIR
- 4. Install man pages in $MANDIR$MANCHAP $HAVEMAN
- 5. Print man pages
- 6. Remove psf software and files from binary and spool directories
-
- Select an option "
- quit=quit
- do
- prompt
- choice=$cmd
- quit="return to the previous menu"
- case $choice in
- 1) replaceprinter
- ;;
- 2) [ -r Ppagesize.cfg ] && [ -r Ppsfprint.cfg ] && [ -r $PNAME ] && createprinter
- ;;
- 3) movefiles
- ;;
- 4) manpages
- ;;
- 5) printman
- ;;
- 6) removeall
- ;;
- [qQ]) break ;;
- *) error "unknown option: \"$choice\""
- ;;
- esac
- done
- exit $OK
-