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

  1. :
  2. #    Install psf filters on Xenix 2.*   (install.xenix)
  3. #
  4. #    note:      this script records configuration parameters in
  5. #        various ".cfg" files in the current directory.
  6. #        it also expects some .cfg files to be created
  7. #        by "selectdef".
  8.  
  9. PATH=.:/bin:/usr/bin:/etc
  10.  
  11. INSTALLPOINT="/tmp/psf"
  12.  
  13. # sense if we are running from "install" or from a normal directory
  14. # If from "install" then  $0 == "init.psf".  the normal script file
  15. # name is "installpsf".
  16.  
  17. case $0 in
  18.   *Install.xenix)
  19.       ;;
  20.   *)    cd $INSTALLPOINT
  21.       ;;
  22. esac
  23.  
  24. DEFDIR="/usr/spool/lp/model/psfprint.def"
  25. BINDIR="/usr/local/bin"
  26. SPOOLDIR="/usr/spool/lp"
  27.  
  28. INTERFACE="$SPOOLDIR/interface"
  29. MODEL="$SPOOLDIR/model"
  30. DEFFILES="defs/*.def"
  31. PAGESIZE="undefined"
  32. PNAME="undefined"
  33. BINARIES="psf pnf pmf psd psbanner psdetect"
  34. MANS="psf.1 pnf.1 pmf.1 psd.1 psmbox.1 psman.1 psnroff.1"
  35. SCRIPTS="psmbox psman psmandouble psnroff"
  36. MANCHAP="LOCAL"
  37.  
  38.  
  39. #    get existing psf installation parameters
  40.  
  41. if test -f Pmanchap.cfg
  42. then
  43.     MANCHAP=`cat Pmanchap.cfg`
  44. fi
  45.  
  46. if test -f Pbindir.cfg
  47. then
  48.     BINDIR=`cat Pbindir.cfg`
  49. fi
  50.  
  51. # Define return values
  52.  
  53. : ${OK=0} ${FAIL=1} ${STOP=10} ${HALT=11}
  54.  
  55.     
  56. # Print an error message
  57. error() {
  58.     echo "\nError: $*" >&2
  59.     return 1
  60. }
  61.  
  62. # Prompt with mesg, return non-zero on q
  63. prompt() {
  64.     while    echo "\n${mesg}or enter q to $quit: \c" >&2
  65.     do    read cmd
  66.         case $cmd in
  67.         +x|-x)    set $cmd                    ;;
  68.         Q|q)    return 1                    ;;
  69.         !*)    eval `expr "$cmd" : "!\(.*\)"`            ;;
  70.         "")    # If there is an argument use it as the default
  71.             # else loop until 'cmd' is set
  72.             [ "$1" ] && { 
  73.                 cmd=$1
  74.                 return 0
  75.             }
  76.             : continue
  77.             ;;
  78.         *)    return 0                    ;;
  79.         esac
  80.     done
  81. }
  82.  
  83.  
  84. showstats () {
  85.     echo "\nPSF INSTALLATION OPTIONS SELECTED"
  86.     echo "--------------------------------"
  87.     echo "printer selected from:   $PNAME"
  88.     echo "printer page size is:    $PAGESIZE"
  89.     echo "psf default options:     $PSFOPT"
  90.     echo "banner options:          $BANNEROPT"
  91.     echo "binaries and scripts in: $BINDIR"
  92.     echo "man pages in chapter:    $MANCHAP"
  93. }
  94.  
  95. createprinter () { 
  96.     bdir="$BINDIR" 
  97.     echo " "
  98.     echo "Install PSF binaries and"
  99.     ./query "   scripts in which directory [$bdir]? "
  100.     read bdir
  101.     case "$bdir" in
  102.     '')    ;;
  103.     *)    BINDIR="$bdir"
  104.         ;;
  105.     esac
  106.     if test ! -d $BINDIR
  107.     then
  108.         echo "\nDirectory $BINDIR does not exist."
  109.         echo "Create the directory and re-start the installation.\n"
  110.         exit $FAIL
  111.     fi
  112.     echo "$BINDIR" > Pbindir.cfg
  113.     cp $BINARIES $BINDIR
  114.     cp $SCRIPTS  $BINDIR
  115.     rm -f psf.model
  116.     sed "s@BINARY@$BINDIR@g" psfxenix.LP | sed "s@OPTIONS@$PSFOPT@g" \
  117.         | sed "s@BANNER@$BANNEROPT@g" > psf.model
  118.     chmod +rw psf.model
  119.     cp psf.model $MODEL/psf.model
  120.     cp $PNAME $DEFDIR
  121.     chown lp $MODEL/psf.model $DEFDIR
  122.     chgrp bin $MODEL/psf.model $DEFDIR
  123.  
  124.     showstats
  125.     echo "\nNow use menu item 2 to install this printer with 'mkdev lp'."
  126.     return 0
  127. }
  128.  
  129.  
  130. getsizes () {
  131.     PAGESIZE=`cat Ppagesize.cfg`
  132.     PNAME=`cat Ppsfprint.cfg`
  133.     cp $PNAME psfprint.def
  134.     case $PAGESIZE in
  135.     DEFAULT)    PSFOPT= ;;
  136.     *)        PSFOPT=`echo -g $PAGESIZE` ;;
  137.     esac
  138.     case $PAGESIZE in
  139.     DEFAULT)    BANNEROPT= ;;
  140.     *)        BANNEROPT=`echo -g $PAGESIZE` ;;
  141.     esac
  142.     return 0
  143. }
  144.  
  145. replaceprinter () { 
  146.     selectdef $DEFFILES
  147.     case $? in
  148.     0)    ;;
  149.     *)    return $?
  150.     esac
  151.     getsizes
  152.     return 0
  153. }
  154.     
  155.  
  156. manpages () { 
  157.     echo "\nNormally, PSF man pages for xenix should be placed in the 'LOCAL'"
  158.     echo "chapter.  Some sites prefer to use other chapters."
  159.     cdir="$MANCHAP"
  160.     echo " "
  161.     ./query "Which chapter should be used for the PSF man pages [$cdir]? "
  162.     read cdir
  163.     case "$cdir" in
  164.     '')    ;;
  165.     *)    MANCHAP="$cdir"
  166.         ;;
  167.     esac
  168.     if test ! -d /usr/man/man.$MANCHAP
  169.     then
  170.         echo "\nDirectory /usr/man/man.$MANCHAP does not exist."
  171.         echo "Create the directory and re-start the manual installation.\n"
  172.         exit $FAIL
  173.     fi
  174.  
  175.     cp  pmf.1 /usr/man/man.$MANCHAP/pmf.$MANCHAP
  176.     cp  pnf.1 /usr/man/man.$MANCHAP/pnf.$MANCHAP
  177.     cp  psf.1 /usr/man/man.$MANCHAP/psf.$MANCHAP
  178.     cp  psd.1 /usr/man/man.$MANCHAP/psd.$MANCHAP
  179.     cp  psman.1 /usr/man/man.$MANCHAP/psman.$MANCHAP
  180.     cp  psnroff.1 /usr/man/man.$MANCHAP/psnroff.$MANCHAP
  181.     cp  psmbox.1 /usr/man/man.$MANCHAP/psmbox.$MANCHAP
  182.     man $MANCHAP pmf > /dev/null
  183.     man $MANCHAP pnf > /dev/null
  184.     man $MANCHAP psd > /dev/null
  185.     man $MANCHAP psf > /dev/null
  186.     man $MANCHAP psman > /dev/null
  187.     man $MANCHAP psnroff > /dev/null
  188.     man $MANCHAP psmbox > /dev/null
  189.     echo "$MANCHAP" > Pmanchap.cfg
  190.     echo "\nPSF man pages have been installed in /usr/man/man.$MANCHAP"
  191.     return 0
  192. }
  193.  
  194. printman () {
  195.     if test ! -d /usr/man/man.$MANCHAP
  196.     then
  197.         psf -2l 66 $DOCS | lp
  198.     else
  199.     psnroff -man $MANS
  200.     fi
  201.  
  202.     return 0
  203. }
  204.  
  205. removeall () {
  206.     cdir="$MANCHAP"
  207.     echo " "
  208.     ./query "Remove PSF man pages from chapter [$cdir]? "
  209.     read cdir
  210.     case "$cdir" in
  211.     '')    ;;
  212.     *)    MANCHAP="$cdir"
  213.         ;;
  214.     esac
  215.     if test ! -d /usr/man/man.$MANCHAP
  216.     then
  217.         echo "\nDirectory /usr/man/man.$MANCHAP does not exist."
  218.         exit $FAIL
  219.     fi
  220.  
  221.     bdir="$BINDIR" 
  222.     echo " "
  223.     ./query "Remove PSF binaries+scripts from directory [$bdir]? "
  224.     read bdir
  225.     case "$bdir" in
  226.     '')    ;;
  227.     *)    BINDIR="$bdir"
  228.         ;;
  229.     esac
  230.     if test ! -d $BINDIR
  231.     then
  232.         echo "\nDirectory $BINDIR does not exist."
  233.         exit 1
  234.     fi
  235.  
  236.     rm -f  /usr/man/man.$MANCHAP/pmf.$MANCHAP
  237.     rm -f  /usr/man/man.$MANCHAP/pnf.$MANCHAP
  238.     rm -f  /usr/man/man.$MANCHAP/psf.$MANCHAP
  239.     rm -f  /usr/man/man.$MANCHAP/psd.$MANCHAP
  240.     rm -f  /usr/man/man.$MANCHAP/psman.$MANCHAP
  241.     rm -f  /usr/man/man.$MANCHAP/psnroff.$MANCHAP
  242.     rm -f  /usr/man/man.$MANCHAP/psmbox.$MANCHAP
  243.  
  244.     rm -f  /usr/man/cat.$MANCHAP/pmf.$MANCHAP
  245.     rm -f  /usr/man/cat.$MANCHAP/pnf.$MANCHAP
  246.     rm -f  /usr/man/cat.$MANCHAP/psf.$MANCHAP
  247.     rm -f  /usr/man/cat.$MANCHAP/psd.$MANCHAP
  248.     rm -f  /usr/man/cat.$MANCHAP/psman.$MANCHAP
  249.     rm -f  /usr/man/cat.$MANCHAP/psnroff.$MANCHAP
  250.     rm -f  /usr/man/cat.$MANCHAP/psmbox.$MANCHAP
  251.  
  252.     thisdir=`pwd`
  253.  
  254.     cd $BINDIR
  255.     rm $BINARIES $SCRIPTS
  256.  
  257.     cd $thisdir
  258.     
  259.     rm $MODEL/psf.model
  260.     rm $DEFDIR
  261.  
  262.     return 0
  263. }
  264.  
  265.  
  266. #
  267. # main()
  268. #
  269. echo '\n\tPSF: Postscript print filter installation'
  270. while  
  271.   mesg='\t1. Select printer type, install psf, make printer model.
  272.     2. Install selected printer with  mkdev lp.
  273.     3. Install man pages in /usr/man.
  274.     4. Print man pages.
  275.     5. Remove psf software and files from binary and spool directories.
  276.  
  277. Select an option '
  278.   quit=quit
  279. do
  280.   prompt
  281.   choice=$cmd
  282.   quit="return to the previous menu"
  283.   case $choice in
  284.   1)    # select and install
  285.     replaceprinter
  286.     [ -r Ppagesize.cfg ] && [ -r Ppsfprint.cfg ] && [ -r $PNAME ] && createprinter
  287.     ;;
  288.   2)    mkdev lp
  289.       ;;
  290.   3)    manpages
  291.     ;;
  292.   4)      printman
  293.       ;;
  294.   5)    removeall
  295.       ;;
  296.   [qQ]) break ;;
  297.   *)    error "unknown option: \"$choice\""
  298.     ;;
  299.   esac
  300. done
  301. exit $OK
  302.