source: trunk/third/transcript/mkprinter.sh @ 9090

Revision 9090, 5.3 KB checked in by ghudson, 28 years ago (diff)
This commit was generated by cvs2svn to compensate for changes in r9089, which included commits to RCS files with non-trunk default branches.
  • Property svn:executable set to *
Line 
1
2#
3# Copyright (c) 1985,1987,1991,1992 Adobe Systems Incorporated. All rights
4# reserved.
5# GOVERNMENT END USERS: See notice of rights in Notice file in release
6# directory.
7# PostScript is a registered trademark of Adobe Systems Incorporated
8# TranScript is a registered trademark of Adobe Systems Incorporated
9# RCSID: $Header: /afs/dev.mit.edu/source/repository/third/transcript/mkprinter.sh,v 1.1.1.1 1996-10-07 20:25:22 ghudson Exp $
10#
11# usage: mkprinter PRINTER TTY COMM
12
13# mkprinter takes PRINTER TTY COMM
14#       where PRINTER is the name by which you want a printer,
15#       TTY is the actual device (/dev/TTY) it is hooked up to, and
16#       COMM is the desired communications program for this printer
17#       (one of pscomm, qmscomm, lpcomm, fpcomm, or ascomm)
18
19if test $# != 3 ; then
20        echo usage: mkprinter PRINTER TTY COMM
21        exit 1
22fi
23
24PRINTER=$1
25TTY=$2
26COMM=$3
27export PRINTER TTY COMM
28
29if  [ -r ./config ]
30then
31    . ./config
32else
33    echo "config file missing!"
34    exit 1
35fi     
36
37if [ -r ./printer ]
38then
39    . ./printer
40else
41    echo "printer file missing!"
42    exit 1
43fi
44
45if [ $COMM = "pscomm" ]
46then
47    if [ $OPSYS = "SYSV" ]
48    then
49        echo "Here is the /etc/inittab line for $TTY"
50        echo "You may need to edit it or use the ttymgmt menu of sysadm"
51        fgrep "${TTY}" /etc/inittab
52    else
53        echo "Here is the line from /etc/ttys for $TTY:"
54        echo "You may need to edit it and do a 'kill -HUP 1' to disable login/getty"
55        fgrep "${TTY}" /etc/ttys
56    fi
57fi
58
59# set up the device itself
60rm -f /dev/${PRINTER}
61# some of the new communications modules don't need a device, so
62# null is specified.  But we don't want it to actually be /dev/null,
63# because that would serialize multiple printers using it, so we create an
64# empty file.
65if [ ${TTY} = "null" ]
66then
67    echo >/dev/${PRINTER}
68else
69    ln /dev/${TTY} /dev/${PRINTER}
70fi
71
72if [ $OPSYS = "SYSV" ]
73then
74    if [ $COMM = "pscomm" ]
75    then
76        # find out what stty string to use
77        CODE=`(stty cs8 9600 cread -clocal -ignbrk brkint -parmrk \
78               inpck -istrip -inlcr -igncr -icrnl -iuclc ixon -ixany ixoff \
79               -opost -isig -icanon -xcase \
80               -echo -echoe -echok -echonl min \^a time \^d
81                stty -g ) </dev/${PRINTER}`
82        export CODE
83    fi
84
85    # create a transcript directory log files
86    PDIR=${SPOOLDIR}/transcript
87    export PDIR
88    if test ! -d $PDIR ; then
89            mkdir $PDIR
90    fi
91    rm -rf ${PDIR}/${PRINTER}-log*
92
93    cp /dev/null ${PDIR}/${PRINTER}-log
94    cp /dev/null ${PDIR}/${PRINTER}.opt
95    echo "PSCOMM=\$PSLIBDIR/$COMM" >>${PDIR}/${PRINTER}.opt
96    echo "export PSCOMM" >>${PDIR}/${PRINTER}.opt
97    chown $SPOOLUSER $PDIR $PDIR/$PRINTER-log ${PDIR}/${PRINTER}.opt
98    chgrp $SPOOLGROUP $PDIR $PDIR/$PRINTER-log ${PDIR}/${PRINTER}.opt
99    chmod 775 $PDIR
100    chmod 664 $PDIR/$PRINTER-log ${PDIR}/${PRINTER}.opt
101
102
103
104    # create the interface spec for this printer
105    sed -e s,XCODEX,${CODE},g \
106        -e s,XSPOOLDIRX,${SPOOLDIR},g \
107        -e s,XPSCOMMX,${COMM},g \
108            $BUILDDIR/lib/psinterface >psinterface
109
110    if [ $SOLARIS = "FALSE" ]
111    then
112      /usr/lib/lpshut
113    fi
114    /usr/lib/lpadmin -x$PRINTER
115    if [ $SOLARIS = "TRUE" ]
116    then
117         /usr/lib/lpadmin -p$PRINTER -cPostScript -Iany -h -ipsinterface \
118                          -v${PDIR}/${PRINTER}-log
119    else
120         /usr/lib/lpadmin -p$PRINTER -cPostScript -h -ipsinterface \
121                          -v${PDIR}/${PRINTER}-log
122    fi
123    /usr/lib/lpsched
124    /usr/lib/accept $PRINTER PostScript
125    enable $PRINTER
126
127    # report what we have done
128    echo "Here are the goods on ${PRINTER}:"
129    ls -lF /dev/${TTY} /dev/${PRINTER}
130    ls -ldF ${PDIR}
131    ls -lF ${PDIR}/${PRINTER}-log ${PDIR}/${PRINTER}.opt
132    lpstat -t
133else
134    # create a spooling directory and log and accounting files
135    rm -rf ${LOGDIR}/${PRINTER}-log* ${ACCTDIR}/${PRINTER}.acct*
136    rm -rf ${SPOOLDIR}/${PRINTER}
137    mkdir ${SPOOLDIR}/${PRINTER}
138    if test ! -d ${LOGDIR} ; then
139            mkdir ${LOGDIR}
140    fi
141    if test ! -d ${ACCTDIR} ; then
142            mkdir ${ACCTDIR}
143    fi 
144    cp /dev/null $LOGDIR/${PRINTER}-log
145    cp /dev/null $ACCTDIR/${PRINTER}.acct
146    chown $SPOOLUSER $SPOOLDIR/$PRINTER $LOGDIR/$PRINTER-log \
147            $ACCTDIR/$PRINTER.acct
148    chgrp $SPOOLGROUP $SPOOLDIR/$PRINTER $LOGDIR/$PRINTER-log \
149            $ACCTDIR/$PRINTER.acct
150    chmod 775 ${SPOOLDIR}/${PRINTER}
151    chmod 664 $LOGDIR/$PRINTER-log $ACCTDIR/$PRINTER.acct
152
153    cp /dev/null ${SPOOLDIR}/${PRINTER}/.options
154    echo "PSCOMM=\$PSLIBDIR/$COMM" >>${SPOOLDIR}/${PRINTER}/.options
155    echo "export PSCOMM" >>${SPOOLDIR}/${PRINTER}/.options
156    chown $SPOOLUSER ${SPOOLDIR}/${PRINTER}/.options
157    chgrp $SPOOLGROUP ${SPOOLDIR}/${PRINTER}/.options
158    chmod 775 ${SPOOLDIR}/${PRINTER}/.options
159
160    # report what we have done
161    echo "Here are the goods on ${PRINTER}:"
162    ls -lgF /dev/${TTY} /dev/${PRINTER}
163    ls -lgdF ${SPOOLDIR}/${PRINTER}
164    ls -lgF ${LOGDIR}/${PRINTER}-log
165    ls -lgF ${ACCTDIR}/${PRINTER}.acct
166    echo " "
167
168    # create a printcap entry for it
169    sed -e s,PSLIBDIR,${PSLIBDIR},g \
170            -e s,PRINTER,${PRINTER},g \
171            -e s,SPOOLDIR,${SPOOLDIR},g \
172            -e s,LOGDIR,${LOGDIR},g \
173            -e s,ACCTDIR,${ACCTDIR},g \
174            $SRCDIR/etc/printcap.proto >printcap.new
175
176    if fgrep -s /dev/${PRINTER} /etc/printcap ; then
177            echo "There seems to be an existing printcap entry for $PRINTER."
178    fi
179    echo "Examine printcap.new and edit /etc/printcap to include it."
180fi
Note: See TracBrowser for help on using the repository browser.