home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1994 January / usenetsourcesnewsgroupsinfomagicjanuary1994.iso / sources / misc / volume12 / psf2 / part04 / Install.unix next >
Encoding:
Text File  |  1990-05-19  |  10.3 KB  |  442 lines

  1. :
  2. #    Install psf filters on AT&T Unix 3.2.2  (install.unix)
  3. #
  4. # NOTE:  if a different version of unix is used, this script
  5. #     may need modification.....
  6. #
  7. #    If AT&T Unix 3.2.2 is used and FACE is available, then
  8. #    the FACE printer database can be updated if the
  9. #    option "-f" is provided on the command line.  The -f 
  10. #    should be used for both installation and removal of psf.
  11. #
  12. #        Install.unix -f
  13. #
  14. #    note:      this script records configuration parameters in
  15. #        various ".cfg" files in the current directory.
  16. #        it also expects some .cfg files to be created
  17. #        by "selectdef".
  18.  
  19. PATH=.:/bin:/usr/bin:/etc
  20.  
  21. #   ----------------------------------------------
  22. #   beginning of things that may need modification
  23.  
  24.  
  25. #  Define the destination directory of the psf binaries and scripts
  26. #  and the print spooler directory
  27.  
  28. BINDIR="/usr/local/bin"
  29. SPOOLDIR="/usr/spool/lp"
  30.  
  31. #  Unix lp printer systems files...
  32. #  The directory structure follows AT&T unix 3.2.2 conventions.
  33. #  Other unix systems may be different.
  34. #  If you are not using AT&T Unix with FACE installed, then
  35. #  ignore the reference to DATABASE.
  36.  
  37. DEFDIR="/usr/spool/lp/model/psfprint.def"
  38. MODEL="$SPOOLDIR/model"
  39. DATABASE="/usr/vmsys/admin/PS/PORTSET/database"
  40.  
  41. #  Specify the man pages directory.  If you are using a system
  42. #  without man pages, ignore these entires.
  43. #
  44. #  Xenix uses man directories that look like /usr/man/man.1
  45. #  If your directories do NOT use the dot (e.g.  man1)
  46. #  format, then remove the "." in the definitions below.
  47.  
  48. MANDIR="/usr/man/man."
  49. CATDIR="/usr/man/cat."
  50. MANCHAP="1"
  51.  
  52. #   ------------------------------------------
  53. #   The following should not need modification
  54.  
  55. DEFFILES="defs/*.def"
  56. PAGESIZE="undefined"
  57. PNAME="undefined"
  58. MODELNAME="psf"
  59.  
  60. #  Create an entry line that will go into the FACE printer
  61. #  selection data base in $DATABASE  (for AT&T unix 3.2.2)
  62. #  If the $DATABASE file does not exist, then the following
  63. #  is ignored.
  64.  
  65. PRINTERDBS="Postscript-PSF            435_table    psf    postscript    tabs ixon ixoff onlcr"
  66. PRINTERID="Postscript-PSF"
  67.  
  68. case ${1} in
  69. -f)    ;;
  70. *)    DATABASE="z9+notHeRe"
  71.     ;;
  72. esac
  73.  
  74. #   PSF distribution files
  75.  
  76. BINARIES="psf pnf pmf psd psbanner psdetect"
  77. MANS="psf.1 pnf.1 pmf.1 psd.1 psmbox.1 psman.1 psnroff.1"
  78. DOCS="psf.doc pnf.doc pmf.doc psd.doc psmbox.doc psman.doc psnroff.doc"
  79. SCRIPTS="psmbox psman psmandouble psnroff"
  80.  
  81. #   See if the man-page directory really exists
  82.  
  83. HAVEMAN=
  84. if test ! -d $MANDIR$MANCHAP
  85. then
  86.     MANCHAP="Not.Allowed"
  87.     HAVEMAN="(missing directory)"
  88. fi
  89.  
  90. #    get existing psf installation parameters
  91.  
  92. if test -f Pmanchap.cfg
  93. then
  94.     MANCHAP=`cat -s Pmanchap.cfg`
  95. fi
  96.  
  97. if test -f Pbindir.cfg
  98. then
  99.     BINDIR=`cat -s Pbindir.cfg`
  100. fi
  101.  
  102. if test -f PPagesize.cfg
  103. then
  104.     PAGESIZE=`cat -s Ppagesize.cfg`
  105. fi
  106. if test -f Ppsfprint.cfg
  107. then
  108.     PNAME=`cat -s Ppsfprint.cfg`
  109. fi
  110.  
  111. # Define return values
  112.  
  113. : ${OK=0} ${FAIL=1} ${STOP=10} ${HALT=11}
  114.  
  115.     
  116. # Print an error message
  117. error() {
  118.     echo "\nError: $*" >&2
  119.     return 1
  120. }
  121.  
  122. # Prompt with mesg, return non-zero on q
  123. prompt() {
  124.     while    echo "\n${mesg}or enter q to $quit: \c" >&2
  125.     do    read cmd
  126.         case $cmd in
  127.         +x|-x)    set $cmd                    ;;
  128.         Q|q)    return 1                    ;;
  129.         !*)    eval `expr "$cmd" : "!\(.*\)"`            ;;
  130.         "")    # If there is an argument use it as the default
  131.             # else loop until 'cmd' is set
  132.             [ "$1" ] && { 
  133.                 cmd=$1
  134.                 return 0
  135.             }
  136.             : continue
  137.             ;;
  138.         *)    return 0                    ;;
  139.         esac
  140.     done
  141. }
  142.  
  143.  
  144. showstats () {
  145.     echo "\nPSF INSTALLATION OPTIONS SELECTED"
  146.     echo "--------------------------------"
  147.     echo "printer selected from:   $PNAME"
  148.     echo "printer page size is:    $PAGESIZE"
  149.     echo "psf default options:     $PSFOPT"
  150.     echo "banner options:          $BANNEROPT"
  151.     echo "binaries and scripts in: $BINDIR"
  152.     echo "man pages in chapter:    $MANCHAP"
  153. }
  154.  
  155. #   Copy the psf binares and scripts to target binary directory 
  156.  
  157. createprinter () { 
  158.     bdir="$BINDIR" 
  159.     echo " "
  160.     echo "Install PSF binaries and"
  161.     ./query "   scripts in which directory [$bdir]? "
  162.     read bdir
  163.     case "$bdir" in
  164.     '')    ;;
  165.     *)    BINDIR="$bdir"
  166.         ;;
  167.     esac
  168.     if test ! -d $BINDIR
  169.     then
  170.         echo "\nDirectory $BINDIR does not exist."
  171.         echo "Create the directory and re-start the installation.\n"
  172.         exit $FAIL
  173.     fi
  174.     echo "$BINDIR" > Pbindir.cfg
  175.     cp $BINARIES $BINDIR
  176.     cp $SCRIPTS  $BINDIR
  177.     rm -f psf.model
  178.     sed "s@BINARY@$BINDIR@g" psfunix.LP | sed "s@OPTIONS@$PSFOPT@g" \
  179.         | sed "s@BANNER@$BANNEROPT@g" > psf.model
  180.     chmod +rw psf.model
  181.     echo "psf binaries and scripts have been copied to $BINDIR"
  182.     showstats
  183.     return 0
  184. }
  185.  
  186.  
  187. #   Copy the psf model and control files to the spool directory.
  188.  
  189. movefiles () {
  190.     cp psf.model $MODEL/$MODELNAME
  191.     cp $PNAME $DEFDIR
  192.     chown lp $MODEL/$MODELNAME $DEFDIR
  193.     chgrp bin $MODEL/$MODELNAME $DEFDIR
  194.  
  195. #    If the FACE printer database exits, add the user provided the
  196. #    -u option, then add a postscript printer to the database
  197.  
  198.  
  199.     if test -f $DATABASE 
  200.     then
  201.         echo "$PRINTERDBS" >> $DATABASE
  202.         echo "FACE printer file $DATABASE",
  203.         echo "    has been updated with a psf printer definition."
  204.     fi
  205.     echo "lp spooler files are copied to:"
  206.     echo "    $MODEL/$MODELNAME"
  207.     echo "    $DEFDIR"
  208.     showstats
  209.     return 0
  210. }
  211.  
  212.  
  213. #   Set up default page sizes for psf to be placed in the
  214. #   lp spooling script files
  215.  
  216. getsizes () {
  217.     PAGESIZE=`cat -s Ppagesize.cfg`
  218.     PNAME=`cat -s Ppsfprint.cfg`
  219.     cp $PNAME psfprint.def
  220.     case $PAGESIZE in
  221.     DEFAULT)    PSFOPT= ;;
  222.     *)        PSFOPT=`echo -g $PAGESIZE` ;;
  223.     esac
  224.     case $PAGESIZE in
  225.     DEFAULT)    BANNEROPT= ;;
  226.     *)        BANNEROPT=`echo -g $PAGESIZE` ;;
  227.     esac
  228.     return 0
  229. }
  230.  
  231. replaceprinter () { 
  232.     selectdef $DEFFILES
  233.     case $? in
  234.     0)    ;;
  235.     *)    return $?
  236.     esac
  237.     getsizes
  238.     return 0
  239. }
  240.     
  241.  
  242. manpages () { 
  243.     echo "\nNormally, man pages are not installed in AT&T unix 3.2.* systems."
  244.     echo "If you have an on-line man system using 'man', then you may proceed"
  245.     echo "with the man page installation.  If you do not have the man system,"
  246.     echo "then specify 'none' for the man page chapter..."    
  247.     cdir="$MANCHAP"
  248.     echo " "
  249.     ./query "Which chapter should be used for the PSF man pages [$cdir]? "
  250.     read cdir
  251.     case "$cdir" in
  252.     '')    ;;
  253.     none)    return 0
  254.         ;;
  255.     *)    MANCHAP="$cdir"
  256.         ;;
  257.     esac
  258.     if test ! -d $MANDIR$MANCHAP
  259.     then
  260.         echo "\nDirectory $MANDIR$MANCHAP does not exist."
  261.         echo "Select a different directory or quit and create the"
  262.         echo "desired directory.\n"
  263.         return 0
  264.     fi
  265.  
  266.     cp  pmf.1 $MANDIR$MANCHAP/pmf.$MANCHAP
  267.     cp  pnf.1 $MANDIR$MANCHAP/pnf.$MANCHAP
  268.     cp  psf.1 $MANDIR$MANCHAP/psf.$MANCHAP
  269.     cp  psd.1 $MANDIR$MANCHAP/psd.$MANCHAP
  270.     cp  psman.1 $MANDIR$MANCHAP/psman.$MANCHAP
  271.     cp  psnroff.1 $MANDIR$MANCHAP/psnroff.$MANCHAP
  272.     cp  psmbox.1 $MANDIR$MANCHAP/psmbox.$MANCHAP
  273.     man $MANCHAP pmf > /dev/null
  274.     man $MANCHAP pnf > /dev/null
  275.     man $MANCHAP psd > /dev/null
  276.     man $MANCHAP psf > /dev/null
  277.     man $MANCHAP psman > /dev/null
  278.     man $MANCHAP psnroff > /dev/null
  279.     man $MANCHAP psmbox > /dev/null
  280.     echo "$MANCHAP" > Pmanchap.cfg
  281.     echo "\nPSF man pages have been installed in $MANDIR$MANCHAP"
  282.     return 0
  283. }
  284.  
  285. #   if the man-page directory exists print the manuals with
  286. #   nroff output.  if it does not exist, print from the
  287. #   pre-formatted print files (using psf, of course...)
  288. #   If the man page directory exists, ASSUME that nroff also exists...
  289.  
  290. printman () {
  291.     if test ! -d $MANDIR$MANCHAP
  292.     then
  293.         psf -2l 66 $DOCS | lp
  294.     else
  295.     psnroff -man $MANS
  296.     fi
  297.     return 0
  298. }
  299.  
  300. removeall () {
  301.     cdir="$MANCHAP"
  302.     echo " "
  303.     ./query "Remove PSF man pages from chapter [$cdir]? "
  304.     read cdir
  305.     case "$cdir" in
  306.     '')    ;;
  307.     *)    MANCHAP="$cdir"
  308.         ;;
  309.     esac
  310.     if test ! -d $MANDIR$MANCHAP
  311.     then
  312.         echo "\nDirectory $MANDIR$MANCHAP does not exist."
  313.         exit $FAIL
  314.     fi
  315.  
  316.     bdir="$BINDIR" 
  317.     echo " "
  318.     ./query "Remove PSF binaries+scripts from directory [$bdir]? "
  319.     read bdir
  320.     case "$bdir" in
  321.     '')    ;;
  322.     *)    BINDIR="$bdir"
  323.         ;;
  324.     esac
  325.     if test ! -d $BINDIR
  326.     then
  327.         echo "\nDirectory $BINDIR does not exist."
  328.         exit 1
  329.     fi
  330.  
  331.     rm -f  $MANDIR$MANCHAP/pmf.$MANCHAP
  332.     rm -f  $MANDIR$MANCHAP/pnf.$MANCHAP
  333.     rm -f  $MANDIR$MANCHAP/psf.$MANCHAP
  334.     rm -f  $MANDIR$MANCHAP/psd.$MANCHAP
  335.     rm -f  $MANDIR$MANCHAP/psman.$MANCHAP
  336.     rm -f  $MANDIR$MANCHAP/psnroff.$MANCHAP
  337.     rm -f  $MANDIR$MANCHAP/psmbox.$MANCHAP
  338.  
  339.     rm -f  $CATDIR$MANCHAP/pmf.$MANCHAP
  340.     rm -f  $CATDIR$MANCHAP/pnf.$MANCHAP
  341.     rm -f  $CATDIR$MANCHAP/psf.$MANCHAP
  342.     rm -f  $CATDIR$MANCHAP/psd.$MANCHAP
  343.     rm -f  $CATDIR$MANCHAP/psman.$MANCHAP
  344.     rm -f  $CATDIR$MANCHAP/psnroff.$MANCHAP
  345.     rm -f  $CATDIR$MANCHAP/psmbox.$MANCHAP
  346.  
  347.     thisdir=`pwd`
  348.  
  349.     cd $BINDIR
  350.     rm $BINARIES $SCRIPTS
  351.  
  352.     cd $thisdir
  353.     
  354.     rm $MODEL/$MODELNAME
  355.     rm $DEFDIR
  356.  
  357. #    If the FACE printer database exits, remove the psf printer
  358. #NOTE should test to ensure that the copy was OK
  359. #^^^^
  360. #    if test -f $PRINTERDBS
  361. #    then
  362. #        grep -v "$PRINTERID" $DATABASE > /tmp/Pdbs.Temp.Q
  363. #        cp /tmp/Pdbs.Temp.Q $DATABASE
  364. #    fi
  365.     if test -f $DATABASE
  366.     then
  367.         grep "$PRINTERID" $DATABASE > /dev/null
  368.         case $? in
  369.         0)    echo "\nThe FACE printer data base file:"
  370.             echo "    $DATABASE"
  371.             echo "should be manually edited to remove the reference to the"
  372.             echo "psf printer identified as $PRINTERID"        
  373.             ;;
  374.         *)    ;;
  375.         esac
  376.     fi
  377.  
  378.     return 0
  379. }
  380.  
  381.  
  382. #
  383. # main()
  384. #
  385. echo "\n\tPSF: Postscript print filter installation\n"
  386. echo "Please ensure that the binary directory and other file references"
  387. echo "are consistent between this install script and the Makefile.\n"
  388. echo "NB: Install the printer with FACE and/or lpadmin befor printing manuals.\n"
  389. echo "Some of the following defaults (+) may be modified during installation.\n"
  390. echo "+ Binary directory:             $BINDIR"
  391. echo "  Spooling directory:           $SPOOLDIR"
  392. echo "  Printer model file:           $MODEL/$MODELNAME"
  393. echo "  Printer model name:           $MODELNAME"
  394. if test -f $DATABASE
  395. then
  396.     echo "  FACE printer database file:   $DATABASE"
  397.     echo "  Printer title in FACE is:     $PRINTERID"
  398. fi
  399.  
  400. if test -d $MANDIR$MANCHAP
  401. then
  402.     echo "+ Man-page directory:           $MANDIR$MANCHAP"
  403.     if test -d $CATDIR$MANCHAP
  404.     then
  405.         echo "                                $CATDIR$MANCHAP"
  406.     fi
  407. fi
  408.  
  409. while  
  410.   mesg="\t1. Select printer type,  make printer model files
  411.     2. Move psf binaries and scripts to $BINDIR
  412.     3. Move psf files to $SPOOLDIR
  413.     4. Install man pages in $MANDIR$MANCHAP   $HAVEMAN
  414.     5. Print man pages
  415.     6. Remove psf software and files from binary and spool directories
  416.  
  417. Select an option "
  418.   quit=quit
  419. do
  420.   prompt
  421.   choice=$cmd
  422.   quit="return to the previous menu"
  423.   case $choice in
  424.   1)    replaceprinter
  425.     ;;
  426.   2)    [ -r Ppagesize.cfg ] && [ -r Ppsfprint.cfg ] && [ -r $PNAME ] && createprinter
  427.     ;;
  428.   3)    movefiles
  429.       ;;
  430.   4)    manpages
  431.     ;;
  432.   5)      printman
  433.       ;;
  434.   6)    removeall
  435.       ;;
  436.   [qQ]) break ;;
  437.   *)    error "unknown option: \"$choice\""
  438.     ;;
  439.   esac
  440. done
  441. exit $OK
  442.